[PATCH] D131009: [analyzer] Fixing a bug raising false positives of stack block object leaking under ARC

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 23 18:46:00 PDT 2022


NoQ added a comment.

Aha perfect, now the entire static analyzer knows how to work with these regions!

I have one tiny remark and I think we can commit.



================
Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1079
   else {
-    if (LC) {
+    bool IsArcManagedBlock = BD->getASTContext().getLangOpts().ObjCAutoRefCount;
+
----------------
`MemRegionManager` maintains a reference to the current `ASTContext`, it's slightly easier to use it directly or through `getContext()`.

There's also a general recommendation to avoid `Decl::getASTContext()` because it isn't an O(1) operation; instead, it traverses through parent decls all the way up to `TranslationUnitDecl` which maintains the actual reference to `ASTContext`. I'm not sure how bad this is, but if it can be easily avoided we probably should.


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

https://reviews.llvm.org/D131009



More information about the cfe-commits mailing list