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

Zhongxing Xu xuzhongxing at gmail.com
Wed Oct 21 04:42:22 PDT 2009


Author: zhongxingxu
Date: Wed Oct 21 06:42:22 2009
New Revision: 84757

URL: http://llvm.org/viewvc/llvm-project?rev=84757&view=rev
Log:
Simplify some code. No functionality change.

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=84757&r1=84756&r2=84757&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Oct 21 06:42:22 2009
@@ -2787,66 +2787,55 @@
       SVal RightV = state->getSVal(RHS);
 
       BinaryOperator::Opcode Op = B->getOpcode();
-      switch (Op) {
-        case BinaryOperator::Assign: {
 
-          // EXPERIMENTAL: "Conjured" symbols.
-          // FIXME: Handle structs.
-          QualType T = RHS->getType();
-
-          if ((RightV.isUnknown() ||
-               !getConstraintManager().canReasonAbout(RightV))
-              && (Loc::IsLocType(T) ||
-                  (T->isScalarType() && T->isIntegerType()))) {
-            unsigned Count = Builder->getCurrentBlockCount();
-            RightV = ValMgr.getConjuredSymbolVal(NULL, B->getRHS(), Count);
+      if (Op == BinaryOperator::Assign) {
+        // EXPERIMENTAL: "Conjured" symbols.
+        // FIXME: Handle structs.
+        QualType T = RHS->getType();
+        
+        if ((RightV.isUnknown()||!getConstraintManager().canReasonAbout(RightV))
+            && (Loc::IsLocType(T) || (T->isScalarType()&&T->isIntegerType()))) {
+          unsigned Count = Builder->getCurrentBlockCount();
+          RightV = ValMgr.getConjuredSymbolVal(NULL, B->getRHS(), Count);
+        }
+        
+        // Simulate the effects of a "store":  bind the value of the RHS
+        // to the L-Value represented by the LHS.
+        EvalStore(Dst, B, LHS, *I2, state->BindExpr(B, RightV), LeftV, RightV);
+        continue;
+      }
+      
+      if (!B->isAssignmentOp()) {
+        // Process non-assignments except commas or short-circuited
+        // logical expressions (LAnd and LOr).
+        SVal Result = EvalBinOp(state, Op, LeftV, RightV, B->getType());
+        
+        if (Result.isUnknown()) {
+          if (OldSt != state) {
+            // Generate a new node if we have already created a new state.
+            MakeNode(Dst, B, *I2, state);
           }
-
-          // Simulate the effects of a "store":  bind the value of the RHS
-          // to the L-Value represented by the LHS.
-          EvalStore(Dst, B, LHS, *I2, state->BindExpr(B, RightV),
-                    LeftV, RightV);
+          else
+            Dst.Add(*I2);
+          
           continue;
         }
-
-          // FALL-THROUGH.
-
-        default: {
-
-          if (B->isAssignmentOp())
-            break;
-
-          // Process non-assignments except commas or short-circuited
-          // logical expressions (LAnd and LOr).
-          SVal Result = EvalBinOp(state, Op, LeftV, RightV, B->getType());
-
-          if (Result.isUnknown()) {
-            if (OldSt != state) {
-              // Generate a new node if we have already created a new state.
-              MakeNode(Dst, B, *I2, state);
-            }
-            else
-              Dst.Add(*I2);
-
-            continue;
-          }
-
-          state = state->BindExpr(B, Result);
-
-          if (Result.isUndef()) {
-            // The operands were *not* undefined, but the result is undefined.
-            // This is a special node that should be flagged as an error.
-            if (ExplodedNode *UndefNode = Builder->generateNode(B, state, *I2)){
-              UndefNode->markAsSink();
-              UndefResults.insert(UndefNode);
-            }
-            continue;
+        
+        state = state->BindExpr(B, Result);
+        
+        if (Result.isUndef()) {
+          // The operands were *not* undefined, but the result is undefined.
+          // This is a special node that should be flagged as an error.
+          if (ExplodedNode *UndefNode = Builder->generateNode(B, state, *I2)){
+            UndefNode->markAsSink();
+            UndefResults.insert(UndefNode);
           }
-
-          // Otherwise, create a new node.
-          MakeNode(Dst, B, *I2, state);
           continue;
         }
+        
+        // Otherwise, create a new node.
+        MakeNode(Dst, B, *I2, state);
+        continue;
       }
 
       assert (B->isCompoundAssignmentOp());
@@ -2874,7 +2863,6 @@
 
       for (ExplodedNodeSet::iterator I3=Tmp3.begin(), E3=Tmp3.end(); I3!=E3;
            ++I3) {
-
         state = GetState(*I3);
         SVal V = state->getSVal(LHS);
 





More information about the cfe-commits mailing list