[PATCH] D100852: [analyzer] Track leaking object through stores

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 21 01:08:37 PDT 2021


NoQ added a comment.

I think this is already way better than before. I see that `OSDynamicCast` isn't supported yet and we seem to hit the same wall as D97183 <https://reviews.llvm.org/D97183> because inter-operation between `trackExpressionValue` and the checkers isn't implemented yet.



================
Comment at: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:636
     if (isa<NonParamVarRegion>(R))
-      Result.push_back(R);
+      Result.emplace_back(R, Val);
 
----------------
Because we already know that `Val.getAsLocSymbol()` is equal to `Sym`, we can be certain that `Val` is either a `&SymRegion{Sym}` (i.e., literally this symbol in its pristine representation) or, in some rare cases, a `LocAsInteger` over that (which is a case i'm not sure we even want to handle). I dunno if we really need to return it here. Maybe it's easier to re-construct it in place as `SValBuilder.makeLoc(Sym)`.


================
Comment at: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp:978
+
+    if (auto KV = AllVarBindings[0].second.getAs<KnownSVal>())
+      // Because 'AllocBindingToReport' is not the the same as
----------------
In particular, this check is always true and you can use `castAs`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100852/new/

https://reviews.llvm.org/D100852



More information about the cfe-commits mailing list