r197733 - [analyzer] Always use 'bool' as the SValBuilder condition type in C++.
Jordan Rose
jordan_rose at apple.com
Thu Dec 19 14:32:40 PST 2013
Author: jrose
Date: Thu Dec 19 16:32:39 2013
New Revision: 197733
URL: http://llvm.org/viewvc/llvm-project?rev=197733&view=rev
Log:
[analyzer] Always use 'bool' as the SValBuilder condition type in C++.
We have assertions for this, but a few edge cases had snuck through where
we were still unconditionally using 'int'.
<rdar://problem/15703011>
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/test/Analysis/casts.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=197733&r1=197732&r2=197733&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Thu Dec 19 16:32:39 2013
@@ -118,7 +118,7 @@ ProgramStateRef ExprEngine::getInitialSt
SVal V = state->getSVal(loc::MemRegionVal(R));
SVal Constraint_untested = evalBinOp(state, BO_GT, V,
svalBuilder.makeZeroVal(T),
- getContext().IntTy);
+ svalBuilder.getConditionType());
Optional<DefinedOrUnknownSVal> Constraint =
Constraint_untested.getAs<DefinedOrUnknownSVal>();
Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=197733&r1=197732&r2=197733&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Thu Dec 19 16:32:39 2013
@@ -362,7 +362,7 @@ SVal SValBuilder::evalBinOp(ProgramState
DefinedOrUnknownSVal SValBuilder::evalEQ(ProgramStateRef state,
DefinedOrUnknownSVal lhs,
DefinedOrUnknownSVal rhs) {
- return evalBinOp(state, BO_EQ, lhs, rhs, Context.IntTy)
+ return evalBinOp(state, BO_EQ, lhs, rhs, getConditionType())
.castAs<DefinedOrUnknownSVal>();
}
Modified: cfe/trunk/test/Analysis/casts.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/casts.cpp?rev=197733&r1=197732&r2=197733&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/casts.cpp (original)
+++ cfe/trunk/test/Analysis/casts.cpp Thu Dec 19 16:32:39 2013
@@ -10,3 +10,10 @@ bool PR14634_implicit(int x) {
double y = (double)x;
return y;
}
+
+void intAsBoolAsSwitchCondition(int c) {
+ switch ((bool)c) {
+ case 0:
+ break;
+ }
+}
More information about the cfe-commits
mailing list