[PATCH] D111542: [analyzer] Retrieve incomplete array extent from its redeclaration.
Denys Petrov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 12 04:40:01 PDT 2021
ASDenysPetrov 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() ||
----------------
NoQ wrote:
> 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.
> Aha ok, can you try iterating over redecls()?
Do you assume that in a list `{redecl1, redecl2, redecl3}` **redecl2** may be our guy but **1** and **3** may not?
> Separately, I suspect that this should be performed before the VarRegion is constructed in the first place.
I'm not sure I got what you mean, but as I undestood that it is not be a part of this fix, right?
================
Comment at: clang/test/Analysis/initialization.c:102
+const int glob_arr3[]; // Incomplete array declaration
+const int glob_arr3[4] = {1, 2, 3}; // Incomplete Array redeclaration
+void foo() {
----------------
balazske wrote:
> It is possible to add a line `const int glob_arr3[];` again and then it may not work?
Yes. I tryed. It works. Thanks! But I'll add a test case.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111542/new/
https://reviews.llvm.org/D111542
More information about the cfe-commits
mailing list