diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-07 00:52:24 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-07 00:52:24 +0000 |
commit | cad2996edf303978932c621ab02729dc11debb81 (patch) | |
tree | 20682ceefa9a2bdef60a10390b1ba6bb940d304c | |
parent | b1f3fe55d4f7f716bac5ca83e8047d95db1115ad (diff) |
GRExprEngine: When processing compound assignments, do a switch table lookup to get the non-compound opcode from the compound opcode instead of relying on the order of BinaryOperator::opcode values. This unbreaks the misc-ps.c test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63991 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index ea2ae3d92b..b75d66b075 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -2515,12 +2515,19 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, assert (B->isCompoundAssignmentOp()); - if (Op >= BinaryOperator::AndAssign) { - Op = (BinaryOperator::Opcode) (Op - (BinaryOperator::AndAssign - - BinaryOperator::And)); - } - else { - Op = (BinaryOperator::Opcode) (Op - BinaryOperator::MulAssign); + switch (Op) { + default: + assert(0 && "Invalid opcode for compound assignment."); + case BinaryOperator::MulAssign: Op = BinaryOperator::Mul; break; + case BinaryOperator::DivAssign: Op = BinaryOperator::Div; break; + case BinaryOperator::RemAssign: Op = BinaryOperator::Rem; break; + case BinaryOperator::AddAssign: Op = BinaryOperator::Add; break; + case BinaryOperator::SubAssign: Op = BinaryOperator::Sub; break; + case BinaryOperator::ShlAssign: Op = BinaryOperator::Shl; break; + case BinaryOperator::ShrAssign: Op = BinaryOperator::Shr; break; + case BinaryOperator::AndAssign: Op = BinaryOperator::And; break; + case BinaryOperator::XorAssign: Op = BinaryOperator::Xor; break; + case BinaryOperator::OrAssign: Op = BinaryOperator::Or; break; } // Perform a load (the LHS). This performs the checks for |