[cfe-commits] r63991 - /cfe/trunk/lib/Analysis/GRExprEngine.cpp

Ted Kremenek kremenek at apple.com
Fri Feb 6 16:52:24 PST 2009


Author: kremenek
Date: Fri Feb  6 18:52:24 2009
New Revision: 63991

URL: http://llvm.org/viewvc/llvm-project?rev=63991&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=63991&r1=63990&r2=63991&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Fri Feb  6 18:52:24 2009
@@ -2515,12 +2515,19 @@
     
       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





More information about the cfe-commits mailing list