[cfe-commits] r146337 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h lib/StaticAnalyzer/Core/SValBuilder.cpp lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Anna Zaks ganna at apple.com
Sat Dec 10 15:42:38 PST 2011


Author: zaks
Date: Sat Dec 10 17:42:38 2011
New Revision: 146337

URL: http://llvm.org/viewvc/llvm-project?rev=146337&view=rev
Log:
[analyzer]Fixup r146336.

Forgot to commit the Header files. 
Rename generateUnknownVal -> makeGenericVal.

Modified:
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
    cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
    cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
    cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h?rev=146337&r1=146336&r2=146337&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h Sat Dec 10 17:42:38 2011
@@ -109,7 +109,7 @@
   /// 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 @@
   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);
 

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h?rev=146337&r1=146336&r2=146337&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h Sat Dec 10 17:42:38 2011
@@ -48,7 +48,7 @@
               MetadataKind,
               BEGIN_SYMBOLS = RegionValueKind,
               END_SYMBOLS = MetadataKind,
-              SymIntKind, SymSymKind, CastSymbolKind };
+              SymIntKind, IntSymKind, SymSymKind, CastSymbolKind };
 private:
   Kind K;
 
@@ -379,6 +379,47 @@
   }
 };
 
+/// 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 @@
     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);
 

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp?rev=146337&r1=146336&r2=146337&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp Sat Dec 10 17:42:38 2011
@@ -167,7 +167,7 @@
 
 //===----------------------------------------------------------------------===//
 
-SVal SValBuilder::generateUnknownVal(const ProgramState *State,
+SVal SValBuilder::makeGenericVal(const ProgramState *State,
                                      BinaryOperator::Opcode Op,
                                      NonLoc LHS, NonLoc RHS,
                                      QualType ResultTy) {

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=146337&r1=146336&r2=146337&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Sat Dec 10 17:42:38 2011
@@ -303,7 +303,7 @@
   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 @@
               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 @@
             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 @@
             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 @@
         // 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 @@
               resultTy);
         }
 
-        return generateUnknownVal(state, op, lhs, rhs, resultTy);
+        return makeGenericVal(state, op, lhs, rhs, resultTy);
       }
     }
     }





More information about the cfe-commits mailing list