[PATCH] D104285: [analyzer] Retrieve a value from list initialization of constant array declaration in a global scope.

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 22 10:17:36 PDT 2021


ASDenysPetrov added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1696-1697
+              const auto I = static_cast<uint64_t>(Idx.getExtValue());
+              // Use `getZExtValue` because array extent can not be negative.
+              const uint64_t Extent = CAT->getSize().getZExtValue();
+              // Check for `Idx < 0`, NOT for `I < 0`, because `Idx` CAN be
----------------
martong wrote:
> Do you think it would make sense to `assert(CAT->getSize().isSigned())`?
`getSize` return `APInt` which is //signless// and has no `isSigned` method. But we know that an array extent shall be of type `std​::​size_­t` (http://eel.is/c++draft/dcl.array#1) which is //unsigned// (http://eel.is/c++draft/support.types.layout#3). So we can confidently get the size with `getZExtValue`.


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

https://reviews.llvm.org/D104285



More information about the cfe-commits mailing list