[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.

Matthew Voss via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 12 12:42:01 PDT 2018


ormris added inline comments.


================
Comment at: lib/StaticAnalyzer/Core/LoopWidening.cpp:89
+                    new Callback(LCtx, MRMgr, ITraits));
+  Finder.matchAST(ASTCtx);
+
----------------
ormris wrote:
> NoQ wrote:
> > NoQ wrote:
> > > george.karpenkov wrote:
> > > > ormris wrote:
> > > > > george.karpenkov wrote:
> > > > > > IMO using the iterator directly (e.g. like it was done in https://github.com/llvm-mirror/clang/blob/master/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp#L213) leads to a much cleaner code and saves you from having to define a callback class.
> > > > > Hmm... I think that's a better approach. Let me see if I can get that working.
> > > > @ormris Yeah I'm really not sure why all examples use the callback API by default.
> > > Also, please match only the local AST, i.e. the body of the function under analysis, which can be obtained as `LCtx->getDecl()->getBody()`. There's no need to scan the whole translation unit.
> > Actually not sure, would widening screw the previous stack frames as well? We should test that, i guess. And even then, it's better to match a few stack frames in the current stack trace than to match the whole translation unit.
> I can't seem to get the new syntax to work. The following assert(0) is never triggered.
> 
> ```
>   auto Matches = match(varDecl(hasType(referenceType())).bind(MatchRef),
>                        *LCtx->getDecl()->getBody(), ASTCtx);
>   for (BoundNodes Match : Matches) {
>     assert(0 && "anything");
>     const VarDecl *VD = Match.getNodeAs<VarDecl>(MatchRef);
>     const VarRegion *VarMem = MRMgr.getVarRegion(VD, LCtx);
>     ITraits.setTrait(VarMem,
>                      RegionAndSymbolInvalidationTraits::TK_PreserveContents);
>   }
> 
> ```
It appears that "decl()" produces no matches...


Repository:
  rC Clang

https://reviews.llvm.org/D47044





More information about the cfe-commits mailing list