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 | 5d7662cfe039ba460ae14815cd3b7f179f80fe68 (patch) | |
tree | 209e25cb932dc1f7ec6c09f30e1b6534513acac1 /clang/lib/Analysis/GRExprEngine.cpp | |
parent | 19179ad680ed702a5fd0ca3b1b37417132b3d02b (diff) | |
download | bcm5719-llvm-5d7662cfe039ba460ae14815cd3b7f179f80fe68.tar.gz bcm5719-llvm-5d7662cfe039ba460ae14815cd3b7f179f80fe68.zip |
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.
llvm-svn: 63991
Diffstat (limited to 'clang/lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | clang/lib/Analysis/GRExprEngine.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index ea2ae3d92be..b75d66b0756 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/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 |