[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()
Deep Majumder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 25 05:16:32 PDT 2021
RedDocMD marked 2 inline comments as done.
RedDocMD added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:87
+ const ProgramStateRef BugState;
+ llvm::SmallPtrSet<const Expr *, 16> DoneExprs;
+
----------------
steakhal wrote:
> I'm not sure if we should expect 16 unique places where `uptr::get()` called on a path. I would guess 4 or 2 is more than enough.
Ok
================
Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:106-109
+ if (const auto *DS = llvm::dyn_cast<DeclStmt>(S)) {
+ for (const Decl *D : DS->getDeclGroup()) {
+ if (const VarDecl *VD = llvm::dyn_cast<VarDecl>(D)) {
+ const Expr *Init = VD->getInit();
----------------
steakhal wrote:
> So you are trying to find the assignment, where the inner pointer is assigned to a variable.
> This visitor logic seems to be somewhat convoluted.
>
> What you want to achieve is slightly similar to `FindLastStoreBRVisitor`. You should have a look at that.
That is what I had done before. @NoQ pointed out why this wouldn't work in a previous comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97183/new/
https://reviews.llvm.org/D97183
More information about the cfe-commits
mailing list