]> granicus.if.org Git - clang/commitdiff
Added boilerplate transfer function support for pointer arithmetic operations.
authorTed Kremenek <kremenek@apple.com>
Fri, 15 Feb 2008 00:52:26 +0000 (00:52 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 15 Feb 2008 00:52:26 +0000 (00:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47147 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp
Analysis/GRSimpleVals.cpp
Analysis/GRSimpleVals.h
include/clang/Analysis/PathSensitive/GRExprEngine.h
include/clang/Analysis/PathSensitive/GRTransferFuncs.h

index 15f1aa2e373cafe23abf6da9c95243fea3d8f72b..bbf06d92fc50eba77b75c5b8eae59d3764633444 100644 (file)
@@ -706,9 +706,17 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B,
         if (isa<LValue>(V1)) {
           // FIXME: Add support for RHS being a non-lvalue.
           const LValue& L1 = cast<LValue>(V1);
-          const LValue& L2 = cast<LValue>(V2);
           
-          Nodify(Dst, B, N2, SetValue(St, B, EvalBinaryOp(ValMgr, Op, L1, L2)));
+          if (isa<LValue>(V2)) {          
+            const LValue& L2 = cast<LValue>(V2);
+            Nodify(Dst, B, N2, SetValue(St, B,
+                                        EvalBinaryOp(ValMgr, Op, L1, L2)));
+          }
+          else {
+            const NonLValue& R2 = cast<NonLValue>(V2);
+            Nodify(Dst, B, N2, SetValue(St, B,
+                                        EvalBinaryOp(ValMgr, Op, L1, R2)));
+          }
         }
         else {
           const NonLValue& R1 = cast<NonLValue>(V1);
index e856c3e5d0854e49be342b7293d9433fcb6ff65c..c9827d9d10501970656f24d49f8598fbc639ac4b 100644 (file)
@@ -162,6 +162,15 @@ NonLValue GRSimpleVals::EvalBinaryOp(ValueManager& ValMgr,
   }
 }
 
+
+// Pointer arithmetic.
+
+LValue GRSimpleVals::EvalBinaryOp(ValueManager& ValMgr,
+                                  BinaryOperator::Opcode Op,
+                                  LValue LHS, NonLValue RHS) {
+  return cast<LValue>(UnknownVal());
+}
+
 // Equality operators for LValues.
 
 
index 0f517fe5eb157520b4df2e7ea81f570185a9d0ae..b00dd3ca39d69a1100c41188e6ea8f67616e59ce 100644 (file)
@@ -44,6 +44,11 @@ public:
                                  BinaryOperator::Opcode Op,
                                  NonLValue LHS, NonLValue RHS);
   
+  // Pointer arithmetic.
+  
+  virtual LValue EvalBinaryOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
+                              LValue LHS, NonLValue RHS);  
+  
   // Equality operators for LValues.
   virtual NonLValue EvalEQ(ValueManager& ValMgr, LValue LHS, LValue RHS);
   virtual NonLValue EvalNE(ValueManager& ValMgr, LValue LHS, LValue RHS);
index 1c88b30b8842b8284d88cb2a6b0d3d62d731b52a..ffb4420965cd07b2724c2586f23abcd9ba3fb08f 100644 (file)
@@ -330,5 +330,10 @@ public:
                              LValue LHS, LValue RHS) {
     return TF->EvalBinaryOp(ValMgr, Op, LHS, RHS);
   }
+  
+  inline RValue EvalBinaryOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
+                             LValue LHS, NonLValue RHS) {
+    return TF->EvalBinaryOp(ValMgr, Op, LHS, RHS);
+  }
 };
 } // end clang namespace
\ No newline at end of file
index b38ac0c91aa33506fe594759718f1a06d070a63c..87ff17037290ccc50d6f238a4a1c9d8df4013ab7 100644 (file)
@@ -47,6 +47,12 @@ public:
                       BinaryOperator::Opcode Op,
                       LValue LHS, LValue RHS);
   
+  
+  // Pointer arithmetic.
+  
+  virtual LValue EvalBinaryOp(ValueManager& ValMgr, BinaryOperator::Opcode Op,
+                              LValue LHS, NonLValue RHS) = 0;
+  
   // Equality operators for LValues.
   virtual NonLValue EvalEQ(ValueManager& ValMgr, LValue LHS, LValue RHS) = 0;
   virtual NonLValue EvalNE(ValueManager& ValMgr, LValue LHS, LValue RHS) = 0;