[PATCH] D158707: [analyzer] Fix a few size-type signedness inconsistency related to DynamicExtent

Ding Fei via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 20:10:28 PDT 2023


danix800 updated this revision to Diff 553335.
danix800 edited the summary of this revision.
danix800 added a comment.

1. `getDynamicExtent()` can return both signed/unsigned results. They are converted to signed version as `ArrayIndexType` to keep consistency. All other APIs return this version

(even for static type size). Testcases are not affected. `ArrayBoundV2` doesn't need explicit `unsigned`-to-`signed` casts to avoid `signed<->unsigned` comparison;

2. `getElementExtent()` could be 0, add more defensive checking;
3. `MPIChecker` added more defensive checking, e.g: `ElementCount` doesn't have to be `ConcreteInt` so avoid direct `ElementCount.castAs<nonloc::ConcreteInt>()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158707

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicExtent.cpp
  clang/test/Analysis/array-bound-v2-constraint-check.c
  clang/test/Analysis/flexible-array-members.c
  clang/test/Analysis/memory-model.cpp
  clang/test/Analysis/mpichecker.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158707.553335.patch
Type: text/x-patch
Size: 19213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230825/891cb28f/attachment-0001.bin>


More information about the cfe-commits mailing list