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

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 11 07:39:17 PDT 2021


steakhal 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() ||
----------------
I think you supposed to use the `getCanonicalDecl()` instead.


================
Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1673
+            const QualType T = VD->getType();
+            if (const ConstantArrayType *CAT = Ctx.getAsConstantArrayType(T)) {
+              // Support one-dimensional array.
----------------
What does the function return if this branch is not taken?
Shouldn't you handle `IncompleteArrayType` as well?


================
Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1718
     }
   }
 
----------------
I would favor not adding another level of indentation xD


================
Comment at: clang/test/Analysis/initialization.c:101
+
+const int glob_arr3[]; // VLA
+const int glob_arr3[4] = {1, 2, 3};
----------------
Why is this a VLA? I thought it's just an `IncompleteArrayType`.
Could you please make sure that this is actually a VLA?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111542



More information about the cfe-commits mailing list