]> granicus.if.org Git - clang/commitdiff
Implemented transfer functions for Statement-Expressions and Commas.
authorTed Kremenek <kremenek@apple.com>
Fri, 8 Feb 2008 07:05:39 +0000 (07:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 8 Feb 2008 07:05:39 +0000 (07:05 +0000)
Fixed bug in dispatching to the correct transfer function for |=, &=, and ^|.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46880 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRConstants.cpp

index 8bf7a2ff3d92986c93df366fdb418292c8e63058..66a320b16d3d2c3542d78250b464a64ebb143489 100644 (file)
@@ -917,8 +917,10 @@ void GRConstants::VisitBinaryOperator(BinaryOperator* B,
           const LValue& L1 = cast<LValue>(V1);
           RValue Result = cast<NonLValue>(UnknownVal());
           
-          Op = (BinaryOperator::Opcode)
-                  (((unsigned) Op) - ((unsigned) BinaryOperator::MulAssign));
+          if (Op >= BinaryOperator::AndAssign)
+            ((int&) Op) -= (BinaryOperator::AndAssign - BinaryOperator::And);
+          else
+            ((int&) Op) -= BinaryOperator::MulAssign;
           
           if (isa<LValue>(V2)) {
             // FIXME: Add support for Non-LValues on RHS.
@@ -959,6 +961,12 @@ void GRConstants::Visit(Stmt* S, GRConstants::NodeTy* Pred,
         VisitLogicalExpr(cast<BinaryOperator>(S), Pred, Dst);
         break;
       }
+      else if (cast<BinaryOperator>(S)->getOpcode() == BinaryOperator::Comma) {
+        StateTy St = Pred->getState();
+        Stmt* LastStmt = cast<BinaryOperator>(S)->getRHS();
+        Nodify(Dst, S, Pred, SetValue(St, S, GetValue(St, LastStmt)));
+        break;
+      }
       
       // Fall-through.
       
@@ -966,6 +974,13 @@ void GRConstants::Visit(Stmt* S, GRConstants::NodeTy* Pred,
       VisitBinaryOperator(cast<BinaryOperator>(S), Pred, Dst);
       break;
       
+    case Stmt::StmtExprClass: {
+      StateTy St = Pred->getState();
+      Stmt* LastStmt = *(cast<StmtExpr>(S)->getSubStmt()->body_rbegin());
+      Nodify(Dst, S, Pred, SetValue(St, S, GetValue(St, LastStmt)));
+      break;      
+    }
+      
     case Stmt::UnaryOperatorClass:
       VisitUnaryOperator(cast<UnaryOperator>(S), Pred, Dst);
       break;