martong updated this revision to Diff 437938.
martong added a comment.
- Rebase on dependent patch
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D126779/new/
https://reviews.llvm.org/D126779
Files:
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
clang/test/Analysis/produce-symbolcast_x86.cpp
Index: clang/test/Analysis/produce-symbolcast_x86.cpp
===================================================================
--- clang/test/Analysis/produce-symbolcast_x86.cpp
+++ clang/test/Analysis/produce-symbolcast_x86.cpp
@@ -11,6 +11,15 @@
template <typename T>
void clang_analyzer_dump(T);
+void test_double(int n) {
+ double D = n / 30;
+ clang_analyzer_dump(D); // expected-warning{{(double) ((reg_$0<int n>) /
30)}}
+ char C = D;
+ clang_analyzer_dump(C); // expected-warning{{(char) ((double) ((reg_$0<int
n>) / 30))}}
+ int I = C; // assertion should not fail here!
+ clang_analyzer_dump(I); // expected-warning{{(int) ((char) ((double)
((reg_$0<int n>) / 30)))}}
+}
+
void test_schar(schar x) {
clang_analyzer_dump(x); // expected-warning{{reg_$0<schar x>}}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -1104,6 +1104,10 @@
SymbolRef RootSym = cast<SymbolCast>(SE)->getOperand();
QualType RT = RootSym->getType().getCanonicalType();
+ // FIXME support simplification from non-integers.
+ if (!RT->isIntegralOrEnumerationType())
+ return makeNonLoc(SE, T, CastTy);
+
BasicValueFactory &BVF = getBasicValueFactory();
APSIntType CTy = BVF.getAPSIntType(CastTy);
APSIntType TTy = BVF.getAPSIntType(T);
Index: clang/test/Analysis/produce-symbolcast_x86.cpp
===================================================================
--- clang/test/Analysis/produce-symbolcast_x86.cpp
+++ clang/test/Analysis/produce-symbolcast_x86.cpp
@@ -11,6 +11,15 @@
template <typename T>
void clang_analyzer_dump(T);
+void test_double(int n) {
+ double D = n / 30;
+ clang_analyzer_dump(D); // expected-warning{{(double) ((reg_$0<int n>) / 30)}}
+ char C = D;
+ clang_analyzer_dump(C); // expected-warning{{(char) ((double) ((reg_$0<int n>) / 30))}}
+ int I = C; // assertion should not fail here!
+ clang_analyzer_dump(I); // expected-warning{{(int) ((char) ((double) ((reg_$0<int n>) / 30)))}}
+}
+
void test_schar(schar x) {
clang_analyzer_dump(x); // expected-warning{{reg_$0<schar x>}}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -1104,6 +1104,10 @@
SymbolRef RootSym = cast<SymbolCast>(SE)->getOperand();
QualType RT = RootSym->getType().getCanonicalType();
+ // FIXME support simplification from non-integers.
+ if (!RT->isIntegralOrEnumerationType())
+ return makeNonLoc(SE, T, CastTy);
+
BasicValueFactory &BVF = getBasicValueFactory();
APSIntType CTy = BVF.getAPSIntType(CastTy);
APSIntType TTy = BVF.getAPSIntType(T);
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits