diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-01-08 18:54:04 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-01-08 18:54:04 +0000 |
commit | b92304b42f7f7b9b294d9e7dd7ab96002dff5b97 (patch) | |
tree | f832e4e4ce978dd6d3f74a8b47eb1a8ad7b48da1 /clang/lib/Analysis/GRExprEngine.cpp | |
parent | af07fbe210b4a36cf19d213a4edd8a7e7fca0842 (diff) | |
download | bcm5719-llvm-b92304b42f7f7b9b294d9e7dd7ab96002dff5b97.tar.gz bcm5719-llvm-b92304b42f7f7b9b294d9e7dd7ab96002dff5b97.zip |
Fix handling in GRExprEngine of 'default' branch in switch statements
when the default case is winnowed down to be infeasible. When all
cases were ruled out (and the analysis state for the default case
would be infeasible) we would still consider the default case
possible. This fixes PR 5969.
llvm-svn: 93017
Diffstat (limited to 'clang/lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | clang/lib/Analysis/GRExprEngine.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index 3c2512215a3..0336ae5ada3 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -1221,7 +1221,8 @@ void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) { do { nonloc::ConcreteInt CaseVal(getBasicVals().getValue(V1.Val.getInt())); - DefinedOrUnknownSVal Res = SVator.EvalEQ(DefaultSt, CondV, CaseVal); + DefinedOrUnknownSVal Res = SVator.EvalEQ(DefaultSt ? DefaultSt : state, + CondV, CaseVal); // Now "assume" that the case matches. if (const GRState* stateNew = state->Assume(Res, true)) { @@ -1236,11 +1237,17 @@ void GRExprEngine::ProcessSwitch(GRSwitchNodeBuilder& builder) { // Now "assume" that the case doesn't match. Add this state // to the default state (if it is feasible). - if (const GRState *stateNew = DefaultSt->Assume(Res, false)) { - defaultIsFeasible = true; - DefaultSt = stateNew; + if (DefaultSt) { + if (const GRState *stateNew = DefaultSt->Assume(Res, false)) { + defaultIsFeasible = true; + DefaultSt = stateNew; + } + else { + defaultIsFeasible = false; + DefaultSt = NULL; + } } - + // Concretize the next value in the range. if (V1.Val.getInt() == V2.Val.getInt()) break; |