diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-03-17 22:17:56 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-03-17 22:17:56 +0000 |
commit | 14a1140c9f4e20b12a54db8745b74699b9872cd2 (patch) | |
tree | f0c20c158f973c3e702d021fc97d556f22d555a3 /lib/Analysis/GRExprEngine.cpp | |
parent | 7ffa0aad4c0ee33a5bbcb5c6499206a3e1f0ae8f (diff) |
Fix integer overflow bug when processing switch statements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48469 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index d27c41c4ef..08c7113cab 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/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 |