[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 11 19:56:10 PDT 2021


NoQ added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1663
     // We can trust a const value or a value of a global initializer in main().
-    const VarDecl *VD = VR->getDecl();
+    const VarDecl *VD = VR->getDecl()->getMostRecentDecl();
     if (VD->getType().isConstQualified() ||
----------------
ASDenysPetrov wrote:
> steakhal wrote:
> > I think you supposed to use the `getCanonicalDecl()` instead.
> Using `getCanonicalDecl` does not fix the issue. I've checked.
Aha ok, can you try iterating over `redecls()`?

Separately, I suspect that this should be performed before the `VarRegion` is constructed in the first place. Maybe in its constructor we should `assert(VD->isThisDeclarationADefinition())` or something like that.


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

https://reviews.llvm.org/D111542



More information about the cfe-commits mailing list