summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/GRExprEngine.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-17 22:17:56 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-17 22:17:56 +0000
commit9eae403cde52bcc0e29af19d91382350acf73177 (patch)
treeba748d5de8ab4f3df3328c01b1320c5dac5c6378 /clang/lib/Analysis/GRExprEngine.cpp
parent58021a617bfe01ec15fd2e477e4c5fc2eccc4321 (diff)
downloadbcm5719-llvm-9eae403cde52bcc0e29af19d91382350acf73177.tar.gz
bcm5719-llvm-9eae403cde52bcc0e29af19d91382350acf73177.zip
Fix integer overflow bug when processing switch statements.
llvm-svn: 48469
Diffstat (limited to 'clang/lib/Analysis/GRExprEngine.cpp')
-rw-r--r--clang/lib/Analysis/GRExprEngine.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index d27c41c4ef0..08c7113cab4 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/lib/Analysis/GRExprEngine.cpp
@@ -288,13 +288,14 @@ void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) {
assert (V1 <= V2);
}
- else V2 = V1;
+ else
+ V2 = V1;
// FIXME: Eventually we should replace the logic below with a range
// comparison, rather than concretize the values within the range.
// This should be easy once we have "ranges" for NonLVals.
- do {
+ do {
nonlval::ConcreteInt CaseVal(BasicVals.getValue(V1));
RVal Res = EvalBinOp(BinaryOperator::EQ, CondV, CaseVal);
@@ -323,10 +324,14 @@ void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) {
if (isFeasible)
DefaultSt = StNew;
- // Concretize the next value in the range.
+ // Concretize the next value in the range.
+ if (V1 == V2)
+ break;
+
++V1;
+ assert (V1 < V2);
- } while (V1 < V2);
+ } while (true);
}
// If we reach here, than we know that the default branch is
OpenPOWER on IntegriCloud