[PATCH] D104285: [analyzer] Retrieve value by direct index from list initialization of constant array declaration.

Chris Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 17 10:36:51 PDT 2021


chrish_ericsson_atx added a comment.

In D104285#2823305 <https://reviews.llvm.org/D104285#2823305>, @chrish_ericsson_atx wrote:

> I'm not sure about whether or not this patch would only work for constant arrays with initializer lists.  If it does only work for such arrays, then I wonder whether the fix is broad enough -- I haven't tested (yet), but I think the presence of the initializer list in the test case is not necessary to trigger the spurious warnings about garbage/undefined values.  I'll try it tomorrow morning...

I tested with an unpatched build using a reproducer without an initializer list, and didn't get the spurious warnings -- so your approach seems correct to me now.   I've also tested your patch and I believe it gives correct behavior.



================
Comment at: clang/lib/AST/Type.cpp:149
+    Extents.push_back(*CAT->getSize().getRawData());
+  } while (CAT = dyn_cast<ConstantArrayType>(CAT->getElementType()));
+  return Extents;
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104285



More information about the cfe-commits mailing list