[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 4 06:47:12 PDT 2021


ASDenysPetrov added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1641
+  // FIXME: Take array dimension into account to prevent exceeding its size.
+  const int64_t I = Idx.getExtValue();
+  uint32_t Code =
----------------
ASDenysPetrov wrote:
> martong wrote:
> > steakhal wrote:
> > > You could use the `uint64_t` type here, and spare the subsequent explicit cast. This operation would be safe since `Idx` must be non-negative here.
> > +1 for using `uint64_t` if possible
> `SL->getCodeUnit` returns `uint32_t`, so I decided to keep the result value consistent if any changes required in the future.
Oh. discard my previous reply. I mistakenly considered a wrong line.
The correct reply:
As you can see, preceding condition `(Idx < 0)` guarantee `Idx` to be non-negative. But if you suggest this to be explicitly visible, then OK, I don't mind. I've just kept it `int64_t` for consistency with return value as well.


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

https://reviews.llvm.org/D107339



More information about the cfe-commits mailing list