]> granicus.if.org Git - clang/commitdiff
[analyzer]Fixup r146336.
authorAnna Zaks <ganna@apple.com>
Sat, 10 Dec 2011 23:42:38 +0000 (23:42 +0000)
committerAnna Zaks <ganna@apple.com>
Sat, 10 Dec 2011 23:42:38 +0000 (23:42 +0000)
Forgot to commit the Header files.
Rename generateUnknownVal -> makeGenericVal.

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

include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
lib/StaticAnalyzer/Core/SValBuilder.cpp
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

index fd29e45c3d1510abcb3ff818dfb29c88070e61bd..76df8c28e56dd3b6fd932fb6c2b326fda2dc201a 100644 (file)
@@ -109,7 +109,7 @@ public:
   /// handle the given binary expression. Depending on the state, decides to
   /// either keep the expression or forget the history and generate an
   /// UnknownVal.
-  SVal generateUnknownVal(const ProgramState *state, BinaryOperator::Opcode op,
+  SVal makeGenericVal(const ProgramState *state, BinaryOperator::Opcode op,
                           NonLoc lhs, NonLoc rhs, QualType resultTy);
 
   SVal evalBinOp(const ProgramState *state, BinaryOperator::Opcode op,
@@ -253,6 +253,9 @@ public:
   NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
                     const llvm::APSInt& rhs, QualType type);
 
+  NonLoc makeNonLoc(const llvm::APSInt& rhs, BinaryOperator::Opcode op,
+                    const SymExpr *lhs, QualType type);
+
   NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
                     const SymExpr *rhs, QualType type);
 
index 0d311b818364812f7c213c0eef4975de29d8624e..2a56c541ee9713871bc794108b810d9c59cfeb8a 100644 (file)
@@ -48,7 +48,7 @@ public:
               MetadataKind,
               BEGIN_SYMBOLS = RegionValueKind,
               END_SYMBOLS = MetadataKind,
-              SymIntKind, SymSymKind, CastSymbolKind };
+              SymIntKind, IntSymKind, SymSymKind, CastSymbolKind };
 private:
   Kind K;
 
@@ -379,6 +379,47 @@ public:
   }
 };
 
+/// IntSymExpr - Represents symbolic expression like 3 - 'x'.
+class IntSymExpr : public SymExpr {
+  const llvm::APSInt& LHS;
+  BinaryOperator::Opcode Op;
+  const SymExpr *RHS;
+  QualType T;
+
+public:
+  IntSymExpr(const llvm::APSInt& lhs, BinaryOperator::Opcode op,
+             const SymExpr *rhs, QualType t)
+    : SymExpr(IntSymKind), LHS(lhs), Op(op), RHS(rhs), T(t) {}
+
+  QualType getType(ASTContext &C) const { return T; }
+
+  BinaryOperator::Opcode getOpcode() const { return Op; }
+
+  void dumpToStream(raw_ostream &os) const;
+
+  const SymExpr *getRHS() const { return RHS; }
+  const llvm::APSInt &getLHS() const { return LHS; }
+
+  static void Profile(llvm::FoldingSetNodeID& ID, const llvm::APSInt& lhs,
+                      BinaryOperator::Opcode op, const SymExpr *rhs,
+                      QualType t) {
+    ID.AddInteger((unsigned) IntSymKind);
+    ID.AddPointer(&lhs);
+    ID.AddInteger(op);
+    ID.AddPointer(rhs);
+    ID.Add(t);
+  }
+
+  void Profile(llvm::FoldingSetNodeID& ID) {
+    Profile(ID, LHS, Op, RHS, T);
+  }
+
+  // Implement isa<T> support.
+  static inline bool classof(const SymExpr *SE) {
+    return SE->getKind() == IntSymKind;
+  }
+};
+
 /// SymSymExpr - Represents symbolic expression like 'x' + 'y'.
 class SymSymExpr : public SymExpr {
   const SymExpr *LHS;
@@ -479,6 +520,10 @@ public:
     return getSymIntExpr(&lhs, op, rhs, t);
   }
 
+  const IntSymExpr *getIntSymExpr(const llvm::APSInt& lhs,
+                                  BinaryOperator::Opcode op,
+                                  const SymExpr *rhs, QualType t);
+
   const SymSymExpr *getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op,
                                   const SymExpr *rhs, QualType t);
 
index 81f84f90ae8d1f5c84ba6eee1d2b4899da7b4ff3..cc2a8cb4d611bdceff0f688dcfba5332893df5f1 100644 (file)
@@ -167,7 +167,7 @@ DefinedSVal SValBuilder::getBlockPointer(const BlockDecl *block,
 
 //===----------------------------------------------------------------------===//
 
-SVal SValBuilder::generateUnknownVal(const ProgramState *State,
+SVal SValBuilder::makeGenericVal(const ProgramState *State,
                                      BinaryOperator::Opcode Op,
                                      NonLoc LHS, NonLoc RHS,
                                      QualType ResultTy) {
index 70901aa60892e9b75798dad37f325fcfc72bf576..4826c88aeabf910839d8f7c0fc3867138bb44f3b 100644 (file)
@@ -303,7 +303,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
   while (1) {
     switch (lhs.getSubKind()) {
     default:
-      return generateUnknownVal(state, op, lhs, rhs, resultTy);
+      return makeGenericVal(state, op, lhs, rhs, resultTy);
     case nonloc::LocAsIntegerKind: {
       Loc lhsL = cast<nonloc::LocAsInteger>(lhs).getLoc();
       switch (rhs.getSubKind()) {
@@ -326,7 +326,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
               return makeTruthVal(true, resultTy);
             default:
               // This case also handles pointer arithmetic.
-              return generateUnknownVal(state, op, lhs, rhs, resultTy);
+              return makeGenericVal(state, op, lhs, rhs, resultTy);
           }
       }
     }
@@ -388,9 +388,9 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
             if (lhsValue == 0)
               // At this point lhs and rhs have been swapped.
               return rhs;
-            return generateUnknownVal(state, op, rhs, lhs, resultTy);
+            return makeGenericVal(state, op, rhs, lhs, resultTy);
           default:
-            return generateUnknownVal(state, op, rhs, lhs, resultTy);
+            return makeGenericVal(state, op, rhs, lhs, resultTy);
         }
       }
     }
@@ -405,7 +405,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
             dyn_cast<SymIntExpr>(selhs->getSymbol());
 
         if (!symIntExpr)
-          return generateUnknownVal(state, op, lhs, rhs, resultTy);
+          return makeGenericVal(state, op, lhs, rhs, resultTy);
 
         // Is this a logical not? (!x is represented as x == 0.)
         if (op == BO_EQ && rhs.isZeroConstant()) {
@@ -453,7 +453,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
         // For now, only handle expressions whose RHS is a constant.
         const nonloc::ConcreteInt *rhsInt = dyn_cast<nonloc::ConcreteInt>(&rhs);
         if (!rhsInt)
-          return generateUnknownVal(state, op, lhs, rhs, resultTy);
+          return makeGenericVal(state, op, lhs, rhs, resultTy);
 
         // If both the LHS and the current expression are additive,
         // fold their constants.
@@ -538,7 +538,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
               resultTy);
         }
 
-        return generateUnknownVal(state, op, lhs, rhs, resultTy);
+        return makeGenericVal(state, op, lhs, rhs, resultTy);
       }
     }
     }