diff options
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/BasicValueFactory.cpp | 29 | ||||
-rw-r--r-- | lib/Analysis/SVals.cpp | 11 |
2 files changed, 15 insertions, 25 deletions
diff --git a/lib/Analysis/BasicValueFactory.cpp b/lib/Analysis/BasicValueFactory.cpp index 18fdbdfaaa..5b7041bc43 100644 --- a/lib/Analysis/BasicValueFactory.cpp +++ b/lib/Analysis/BasicValueFactory.cpp @@ -14,34 +14,18 @@ //===----------------------------------------------------------------------===// #include "clang/Analysis/PathSensitive/BasicValueFactory.h" -#include "clang/Analysis/PathSensitive/SVals.h" using namespace clang; -CompoundValData::CompoundValData(QualType t, const SVal* vals, unsigned n, - llvm::BumpPtrAllocator& A) - : T(t), NumVals(n) { - - Vals = (SVal*) A.Allocate<SVal>(n); - - new (Vals) SVal[n]; - - for (unsigned i = 0; i < n; ++i) - Vals[i] = vals[i]; -} - void CompoundValData::Profile(llvm::FoldingSetNodeID& ID, QualType T, - unsigned N, const SVal* Vals) { + llvm::ImmutableList<SVal> L) { T.Profile(ID); - ID.AddInteger(N); - for (unsigned i = 0; i < N; ++i) - Vals[i].Profile(ID); + ID.AddPointer(L.getInternalPointer()); } typedef std::pair<SVal, uintptr_t> SValData; typedef std::pair<SVal, SVal> SValPair; - namespace llvm { template<> struct FoldingSetTrait<SValData> { static inline void Profile(const SValData& X, llvm::FoldingSetNodeID& ID) { @@ -127,17 +111,18 @@ BasicValueFactory::getConstraint(SymbolID sym, BinaryOperator::Opcode Op, } const CompoundValData* -BasicValueFactory::getCompoundValData(QualType T, const SVal* Vals, - unsigned NumVals) { +BasicValueFactory::getCompoundValData(QualType T, + llvm::ImmutableList<SVal> Vals) { + llvm::FoldingSetNodeID ID; - CompoundValData::Profile(ID, T, NumVals, Vals); + CompoundValData::Profile(ID, T, Vals); void* InsertPos; CompoundValData* D = CompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos); if (!D) { D = (CompoundValData*) BPAlloc.Allocate<CompoundValData>(); - new (D) CompoundValData(T, Vals, NumVals, BPAlloc); + new (D) CompoundValData(T, Vals); CompoundValDataSet.InsertNode(D, InsertPos); } diff --git a/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp index 8d5b8ab574..b323087f5c 100644 --- a/lib/Analysis/SVals.cpp +++ b/lib/Analysis/SVals.cpp @@ -245,9 +245,9 @@ NonLoc NonLoc::MakeIntTruthVal(BasicValueFactory& BasicVals, bool b) { return nonloc::ConcreteInt(BasicVals.getTruthValue(b)); } -NonLoc NonLoc::MakeCompoundVal(QualType T, SVal* Vals, unsigned NumSVals, +NonLoc NonLoc::MakeCompoundVal(QualType T, llvm::ImmutableList<SVal> Vals, BasicValueFactory& BasicVals) { - return nonloc::CompoundVal(BasicVals.getCompoundValData(T, Vals, NumSVals)); + return nonloc::CompoundVal(BasicVals.getCompoundValData(T, Vals)); } SVal SVal::GetSymbolValue(SymbolManager& SymMgr, VarDecl* D) { @@ -260,6 +260,11 @@ SVal SVal::GetSymbolValue(SymbolManager& SymMgr, VarDecl* D) { return nonloc::SymbolVal(SymMgr.getSymbol(D)); } +nonloc::LocAsInteger nonloc::LocAsInteger::Make(BasicValueFactory& Vals, Loc V, + unsigned Bits) { + return LocAsInteger(Vals.getPersistentSValWithData(V, Bits)); +} + //===----------------------------------------------------------------------===// // Utility methods for constructing Locs. //===----------------------------------------------------------------------===// @@ -353,7 +358,7 @@ void NonLoc::print(std::ostream& Out) const { Out << " [as " << C.getNumBits() << " bit integer]"; break; } - + default: assert (false && "Pretty-printed not implemented for this NonLoc."); break; |