]> granicus.if.org Git - clang/commitdiff
Remove unnecessary ASTContext& parameter from SymExpr::getType().
authorTed Kremenek <kremenek@apple.com>
Wed, 26 Sep 2012 06:00:14 +0000 (06:00 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 26 Sep 2012 06:00:14 +0000 (06:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164661 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
lib/StaticAnalyzer/Core/ConstraintManager.cpp
lib/StaticAnalyzer/Core/MemRegion.cpp
lib/StaticAnalyzer/Core/ProgramState.cpp
lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
lib/StaticAnalyzer/Core/SymbolManager.cpp

index 7dbd74ca907748ce59d8a406c919080a636e4b7b..a68732c081fac60da060d3c472a87a5162522840 100644 (file)
@@ -72,7 +72,7 @@ public:
   virtual ~SValBuilder() {}
 
   bool haveSameType(const SymExpr *Sym1, const SymExpr *Sym2) {
-    return haveSameType(Sym1->getType(Context), Sym2->getType(Context));
+    return haveSameType(Sym1->getType(), Sym2->getType());
   }
 
   bool haveSameType(QualType Ty1, QualType Ty2) {
index ab619fa8aff9d401882df8109ef0612e0f3e72be..1b8fba262cb9ab34ddf2ea07bc6e0606f8b5eae3 100644 (file)
@@ -65,7 +65,7 @@ public:
 
   virtual void dumpToStream(raw_ostream &os) const {}
 
-  virtual QualType getType(ASTContext&) const = 0;
+  virtual QualType getType() const = 0;
   virtual void Profile(llvm::FoldingSetNodeID& profile) = 0;
 
   // Implement isa<T> support.
@@ -144,7 +144,7 @@ public:
 
   virtual void dumpToStream(raw_ostream &os) const;
 
-  QualType getType(ASTContext&) const;
+  QualType getType() const;
 
   // Implement isa<T> support.
   static inline bool classof(const SymExpr *SE) {
@@ -173,7 +173,7 @@ public:
   unsigned getCount() const { return Count; }
   const void *getTag() const { return SymbolTag; }
 
-  QualType getType(ASTContext&) const;
+  QualType getType() const;
 
   virtual void dumpToStream(raw_ostream &os) const;
 
@@ -211,7 +211,7 @@ public:
   SymbolRef getParentSymbol() const { return parentSymbol; }
   const TypedValueRegion *getRegion() const { return R; }
 
-  QualType getType(ASTContext&) const;
+  QualType getType() const;
 
   virtual void dumpToStream(raw_ostream &os) const;
 
@@ -244,7 +244,7 @@ public:
 
   const SubRegion *getRegion() const { return R; }
 
-  QualType getType(ASTContext&) const;
+  QualType getType() const;
 
   virtual void dumpToStream(raw_ostream &os) const;
 
@@ -283,7 +283,7 @@ public:
   unsigned getCount() const { return Count; }
   const void *getTag() const { return Tag; }
 
-  QualType getType(ASTContext&) const;
+  QualType getType() const;
 
   virtual void dumpToStream(raw_ostream &os) const;
 
@@ -320,7 +320,7 @@ public:
   SymbolCast(const SymExpr *In, QualType From, QualType To) :
     SymExpr(CastSymbolKind), Operand(In), FromTy(From), ToTy(To) { }
 
-  QualType getType(ASTContext &C) const { return ToTy; }
+  QualType getType() const { return ToTy; }
 
   const SymExpr *getOperand() const { return Operand; }
 
@@ -358,7 +358,7 @@ public:
 
   // FIXME: We probably need to make this out-of-line to avoid redundant
   // generation of virtual functions.
-  QualType getType(ASTContext &C) const { return T; }
+  QualType getType() const { return T; }
 
   BinaryOperator::Opcode getOpcode() const { return Op; }
 
@@ -399,7 +399,7 @@ public:
              const SymExpr *rhs, QualType t)
     : SymExpr(IntSymKind), LHS(lhs), Op(op), RHS(rhs), T(t) {}
 
-  QualType getType(ASTContext &C) const { return T; }
+  QualType getType() const { return T; }
 
   BinaryOperator::Opcode getOpcode() const { return Op; }
 
@@ -446,7 +446,7 @@ public:
 
   // FIXME: We probably need to make this out-of-line to avoid redundant
   // generation of virtual functions.
-  QualType getType(ASTContext &C) const { return T; }
+  QualType getType() const { return T; }
 
   virtual void dumpToStream(raw_ostream &os) const;
 
@@ -540,7 +540,7 @@ public:
                                   const SymExpr *rhs, QualType t);
 
   QualType getType(const SymExpr *SE) const {
-    return SE->getType(Ctx);
+    return SE->getType();
   }
 
   /// \brief Add artificial symbol dependency.
index 075c771f0df9da3e7f70fd3c1a95b07269c6d138..5dd1392bdecc4b212ec66c6d8f67cb7131009533 100644 (file)
@@ -33,8 +33,7 @@ ConditionTruthVal ConstraintManager::isNull(ProgramStateRef State,
   // Disable recursive notification of clients.
   llvm::SaveAndRestore<bool> DisableNotify(NotifyAssumeClients, false);
   
-  ProgramStateManager &Mgr = State->getStateManager();
-  QualType Ty = Sym->getType(Mgr.getContext());
+  QualType Ty = Sym->getType();
   DefinedSVal V = Loc::isLocType(Ty) ? getLocFromSymbol(State, Sym)
                                      : nonloc::SymbolVal(Sym);
   const ProgramStatePair &P = assumeDual(State, V);
index 48d459452dae12aca2bc7afa9edf99da8f241877..7c66739558a3a78ea0acdd796cfe4fd4f4dbf25f 100644 (file)
@@ -1109,7 +1109,7 @@ RegionOffset MemRegion::getAsOffset() const {
         // If our base region is symbolic, we don't know what type it really is.
         // Pretend the type of the symbol is the true dynamic type.
         // (This will at least be self-consistent for the life of the symbol.)
-        Ty = SR->getSymbol()->getType(getContext())->getPointeeType();
+        Ty = SR->getSymbol()->getType()->getPointeeType();
       }
       
       const CXXRecordDecl *Child = Ty->getAsCXXRecordDecl();
index 56c6c04df0c18d7c8e5e4d966159fc89c6a41d0a..2d925775ad1480c4dc440fb840ce5b537557538c 100644 (file)
@@ -737,7 +737,7 @@ DynamicTypeInfo ProgramState::getDynamicTypeInfo(const MemRegion *Reg) const {
 
   if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(Reg)) {
     SymbolRef Sym = SR->getSymbol();
-    return DynamicTypeInfo(Sym->getType(getStateManager().getContext()));
+    return DynamicTypeInfo(Sym->getType());
   }
 
   return DynamicTypeInfo();
index 3c31ecbedcbb0233307f4841c92c0abcad7c5c6e..5da4fa47daebfa9152018ef2a8d1ae0c545eb004 100644 (file)
@@ -373,7 +373,7 @@ RangeConstraintManager::GetRange(ProgramStateRef state, SymbolRef sym) {
   // Lazily generate a new RangeSet representing all possible values for the
   // given symbol type.
   BasicValueFactory &BV = getBasicVals();
-  QualType T = sym->getType(BV.getContext());
+  QualType T = sym->getType();
 
   RangeSet Result(F, BV.getMinValue(T), BV.getMaxValue(T));
 
index e0c966e36c2b5f9daaa9d2b4b5dff6cc00903d7a..aadb963e50f631e7aeb647bcde6bc1fc8db483df 100644 (file)
@@ -1050,7 +1050,7 @@ SVal RegionStoreManager::getBinding(Store store, Loc L, QualType T) {
         T = TR->getLocationType();
       else {
         const SymbolicRegion *SR = cast<SymbolicRegion>(MR);
-        T = SR->getSymbol()->getType(Ctx);
+        T = SR->getSymbol()->getType();
       }
     }
     MR = GetElementZeroRegion(MR, T);
@@ -1574,7 +1574,7 @@ StoreRef RegionStoreManager::Bind(Store store, Loc L, SVal V) {
   if (const SymbolicRegion *SR = dyn_cast<SymbolicRegion>(R)) {
     // Binding directly to a symbolic region should be treated as binding
     // to element 0.
-    QualType T = SR->getSymbol()->getType(Ctx);
+    QualType T = SR->getSymbol()->getType();
     if (T->isAnyPointerType() || T->isReferenceType())
       T = T->getPointeeType();
 
index bfd55f7dde4dd748e3ad45692e10d1dac631ac75..052075695b0a0328730deea9392436fdfe878921 100644 (file)
@@ -140,7 +140,7 @@ ProgramStateRef
 SimpleConstraintManager::assumeAuxForSymbol(ProgramStateRef State,
                                             SymbolRef Sym, bool Assumption) {
   BasicValueFactory &BVF = getBasicVals();
-  QualType T = Sym->getType(BVF.getContext());
+  QualType T = Sym->getType();
 
   // None of the constraint solvers currently support non-integer types.
   if (!T->isIntegerType())
@@ -190,7 +190,7 @@ ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef state,
       BinaryOperator::Opcode op = SE->getOpcode();
       // Implicitly compare non-comparison expressions to 0.
       if (!BinaryOperator::isComparisonOp(op)) {
-        QualType T = SE->getType(BasicVals.getContext());
+        QualType T = SE->getType();
         const llvm::APSInt &zero = BasicVals.getValue(0, T);
         op = (Assumption ? BO_NE : BO_EQ);
         return assumeSymRel(state, SE, op, zero);
@@ -239,11 +239,9 @@ ProgramStateRef SimpleConstraintManager::assumeSymRel(ProgramStateRef state,
   assert(BinaryOperator::isComparisonOp(op) &&
          "Non-comparison ops should be rewritten as comparisons to zero.");
 
-  BasicValueFactory &BVF = getBasicVals();
-  ASTContext &Ctx = BVF.getContext();
-
   // Get the type used for calculating wraparound.
-  APSIntType WraparoundType = BVF.getAPSIntType(LHS->getType(Ctx));
+  BasicValueFactory &BVF = getBasicVals();
+  APSIntType WraparoundType = BVF.getAPSIntType(LHS->getType());
 
   // We only handle simple comparisons of the form "$sym == constant"
   // or "($sym+constant1) == constant2".
index 967e95bb60330334ae2a38ec711dd3140e8e2b12..fbc6ba055105c5f64235b2805e45559a368e9adf 100644 (file)
@@ -81,7 +81,7 @@ SVal SimpleSValBuilder::evalCastFromNonLoc(NonLoc val, QualType castTy) {
   }
 
   if (const SymExpr *se = val.getAsSymbolicExpression()) {
-    QualType T = Context.getCanonicalType(se->getType(Context));
+    QualType T = Context.getCanonicalType(se->getType());
     // If types are the same or both are integers, ignore the cast.
     // FIXME: Remove this hack when we support symbolic truncation/extension.
     // HACK: If both castTy and T are integers, ignore the cast.  This is
@@ -276,7 +276,7 @@ SVal SimpleSValBuilder::MakeSymIntVal(const SymExpr *LHS,
     // with the given constant.
     // FIXME: This is an approximation of Sema::UsualArithmeticConversions.
     ASTContext &Ctx = getContext();
-    QualType SymbolType = LHS->getType(Ctx);
+    QualType SymbolType = LHS->getType();
     uint64_t ValWidth = RHS.getBitWidth();
     uint64_t TypeWidth = Ctx.getTypeSize(SymbolType);
 
@@ -461,7 +461,7 @@ SVal SimpleSValBuilder::evalBinOpNN(ProgramStateRef state,
           case BO_NE:
             // Negate the comparison and make a value.
             opc = NegateComparison(opc);
-            assert(symIntExpr->getType(Context) == resultTy);
+            assert(symIntExpr->getType() == resultTy);
             return makeNonLoc(symIntExpr->getLHS(), opc,
                 symIntExpr->getRHS(), resultTy);
           }
index 5334b03b3fc40c02ff1a45bc36ca43c309b3ee2a..9a1194592418b06708c5dcacaef173b87ddb6535 100644 (file)
@@ -324,23 +324,24 @@ const SymSymExpr *SymbolManager::getSymSymExpr(const SymExpr *lhs,
   return cast<SymSymExpr>(data);
 }
 
-QualType SymbolConjured::getType(ASTContext&) const {
+QualType SymbolConjured::getType() const {
   return T;
 }
 
-QualType SymbolDerived::getType(ASTContext &Ctx) const {
+QualType SymbolDerived::getType() const {
   return R->getValueType();
 }
 
-QualType SymbolExtent::getType(ASTContext &Ctx) const {
+QualType SymbolExtent::getType() const {
+  ASTContext &Ctx = R->getMemRegionManager()->getContext();
   return Ctx.getSizeType();
 }
 
-QualType SymbolMetadata::getType(ASTContext&) const {
+QualType SymbolMetadata::getType() const {
   return T;
 }
 
-QualType SymbolRegionValue::getType(ASTContext &C) const {
+QualType SymbolRegionValue::getType() const {
   return R->getValueType();
 }