[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:351-352 + case OO_##Name: \ +BinOpIt = BinOps.find(Spelling); \ +UnOpIt

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-26 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 354695. RedDocMD added a comment. First try at implementing conversion function from OverloadedOperatorKind to BinaryOperatorKind Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104616/new/ https://reviews.llvm

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-26 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added inline comments. Comment at: clang/test/Analysis/smart-ptr.cpp:466 + + clang_analyzer_eval(ptr == ptr); // expected-warning{{TRUE}} + clang_analyzer_eval(ptr > ptr); // expected-warning{{FALSE}} xazax.hun wrote: > RedDocMD wrote: > > xazax.hun w

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:336 + BinaryOperatorKind BOK; + switch (OOK) { + case OO_EqualEqual: Btw, if we do not have a helper yet to translate between these enums in the analyer, we sh

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:329 + return *Ptr; +return C.getSValBuilder().conjureSymbolVal( +E, C.getLocationContext(), In case we conjure a new symbol, we want this stored i

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 354460. RedDocMD added a comment. Removed dump statement Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104616/new/ https://reviews.llvm.org/D104616 Files: clang/lib/StaticAnalyzer/Checkers/SmartPtr.h clan

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added inline comments. Comment at: clang/test/Analysis/smart-ptr.cpp:466 + + clang_analyzer_eval(ptr == ptr); // expected-warning{{TRUE}} + clang_analyzer_eval(ptr > ptr); // expected-warning{{FALSE}} xazax.hun wrote: > Putting tests like this on the

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 354459. RedDocMD added a comment. Refactored code, removed duplications, fixed tests, added some more Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104616/new/ https://reviews.llvm.org/D104616 Files: clang/

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-25 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD marked 4 inline comments as done. RedDocMD added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:301 + const OverloadedOperatorKind OOK = FD->getOverloadedOperator(); + if (!(OOK == OO_Equal || OOK == OO_ExclaimEqual || OOK == OO_Les

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-24 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments. Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:301 + const OverloadedOperatorKind OOK = FD->getOverloadedOperator(); + if (!(OOK == OO_Equal || OOK == OO_ExclaimEqual || OOK == OO_Less || +OOK == OO_LessEqual || OOK =

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-24 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment. We have a failing test here (test at line 473). Which makes me wonder if the `handleComparision` function is at all called. This is something I need to check. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104616/new/ htt

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-24 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 354323. RedDocMD added a comment. Removed re-invention, added tests Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104616/new/ https://reviews.llvm.org/D104616 Files: clang/lib/StaticAnalyzer/Checkers/SmartP

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-24 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment. In D104616#2835061 , @xazax.hun wrote: > In D104616#2835030 , @RedDocMD > wrote: > >> Looks like I have wasted a good deal of effort. :( > > Sorry about that! :( If we learned anything n

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment. In D104616#2835030 , @RedDocMD wrote: > Looks like I have wasted a good deal of effort. :( Sorry about that! :( If we learned anything new in the process it was not wasted effort though. Repository: rG LLVM Github Monorepo

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-22 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment. In D104616#2834770 , @xazax.hun wrote: > In D104616#2834714 , @NoQ wrote: > >> Why not simply delegate this job to `assume(evalBinOp(...))` over raw >> pointer values, which already has

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment. In D104616#2834714 , @NoQ wrote: > Why not simply delegate this job to `assume(evalBinOp(...))` over raw pointer > values, which already has all this logic written down nicely? This is what I had in mind, I just did not want t

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment. In D104616#2830349 , @xazax.hun wrote: > In D104616#2829705 , @RedDocMD > wrote: > >> If `(ptr1 == ptr2)` is false, we can't say anything really. > > Well, I think it depends. If one of the p

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment. Looks like a solid start! Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:301 + + bool addTransition = false; + ProgramStateRef State = C.getState(); nit: variable names should be capitalized C

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-22 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD updated this revision to Diff 353709. RedDocMD added a comment. Logic for handling special cases, when both are unique_ptr Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104616/new/ https://reviews.llvm.org/D104616 Files: clang/lib/Stati

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment. In D104616#2829705 , @RedDocMD wrote: > If `(ptr1 == ptr2)` is false, we can't say anything really. Well, I think it depends. If one of the pointers is null, for some platforms, we can. E.g. null < non-null is probably true on

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-21 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment. In D104616#2829705 , @RedDocMD wrote: > The only method that I think can be realistically modelled is `==` (and thus > `!=`). If both the operands refer to the same `unique_ptr`, we know `==` > returns true. If they are not t

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-20 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment. The only method that I think can be realistically modelled is `==` (and thus `!=`). If both the operands refer to the same `unique_ptr`, we know `==` returns true. If they are not the same, the only way `==` can return true if the two smart pointers were initialized fr

[PATCH] D104616: [analyzer][WIP] Model comparision methods of std::unique_ptr

2021-06-20 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD created this revision. RedDocMD added reviewers: NoQ, vsavchenko, xazax.hun, teemperor. Herald added subscribers: manas, steakhal, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware. RedDocMD requested review of this re