[all-commits] [llvm/llvm-project] 125590: [analyzer] Fix a few size-type inconsistency relat...
Ding Fei via All-commits
all-commits at lists.llvm.org
Fri Sep 1 06:06:08 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 12559064e05a11e8418425de59d8745f0cfb1122
https://github.com/llvm/llvm-project/commit/12559064e05a11e8418425de59d8745f0cfb1122
Author: dingfei <fding at feysh.com>
Date: 2023-09-01 (Fri, 01 Sep 2023)
Changed paths:
M clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h
M clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
M clang/lib/StaticAnalyzer/Core/DynamicExtent.cpp
M clang/test/Analysis/array-bound-v2-constraint-check.c
M clang/test/Analysis/flexible-array-members.c
M clang/test/Analysis/memory-model.cpp
Log Message:
-----------
[analyzer] Fix a few size-type inconsistency relating to DynamicExtent
Size-type inconsistency (signedness) causes confusion and even bugs.
For example when signed compared to unsigned the result might not
be expected. Summary of this commit:
Related APIs changes:
1. getDynamicExtent() returns signed version of extent;
2. Add getDynamicElementCountWithOffset() for offset version of element count;
3. getElementExtent() could be 0, add defensive checking for
getDynamicElementCount(), if element is of zero-length, try
ConstantArrayType::getSize() as element count;
Related checker changes:
1. ArrayBoundCheckerV2: add testcase for signed <-> unsigned comparison from
type-inconsistency results by getDynamicExtent()
2. ExprInspection: use more general API to report more results
Fixes https://github.com/llvm/llvm-project/issues/64920
Reviewed By: donat.nagy, steakhal
Differential Revision: https://reviews.llvm.org/D158499
More information about the All-commits
mailing list