]> granicus.if.org Git - clang/commitdiff
GRExprEngine: When processing compound assignments, do a switch table lookup to get...
authorTed Kremenek <kremenek@apple.com>
Sat, 7 Feb 2009 00:52:24 +0000 (00:52 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 7 Feb 2009 00:52:24 +0000 (00:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63991 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/GRExprEngine.cpp

index ea2ae3d92bef994bbe610275f3bcd6ce605a0605..b75d66b075619a1d0298325307facac1b20c9627 100644 (file)
@@ -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