[PATCH] D16178: [analyzer] A quick fix on top of D12901/r257464
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 18 02:22:08 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL258039: [analyzer] Fix an off-by-one in evalIntegralCast() (authored by dergachev).
Changed prior to commit:
http://reviews.llvm.org/D16178?vs=44842&id=45159#toc
Repository:
rL LLVM
http://reviews.llvm.org/D16178
Files:
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/test/Analysis/bool-assignment.c
Index: cfe/trunk/test/Analysis/bool-assignment.c
===================================================================
--- cfe/trunk/test/Analysis/bool-assignment.c
+++ cfe/trunk/test/Analysis/bool-assignment.c
@@ -42,6 +42,15 @@
BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
return;
}
+ if (y > 200 && y < 250) {
+ // FIXME: Currently we are loosing this warning due to a SymbolCast in RHS.
+ BOOL x = y; // no-warning
+ return;
+ }
+ if (y >= 127 && y < 150) {
+ BOOL x = y; // expected-warning{{Assignment of a non-Boolean value}}
+ return;
+ }
if (y > 1) {
BOOL x = y; // expected-warning {{Assignment of a non-Boolean value}}
return;
Index: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -451,7 +451,7 @@
NonLoc FromVal = val.castAs<NonLoc>();
QualType CmpTy = getConditionType();
NonLoc CompVal =
- evalBinOpNN(state, BO_LT, FromVal, ToTypeMaxVal, CmpTy).castAs<NonLoc>();
+ evalBinOpNN(state, BO_LE, FromVal, ToTypeMaxVal, CmpTy).castAs<NonLoc>();
ProgramStateRef IsNotTruncated, IsTruncated;
std::tie(IsNotTruncated, IsTruncated) = state->assume(CompVal);
if (!IsNotTruncated && IsTruncated) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16178.45159.patch
Type: text/x-patch
Size: 1379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160118/2bb80cb2/attachment.bin>
More information about the cfe-commits
mailing list