diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-30 17:44:46 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-30 17:44:46 +0000 |
commit | ec9a252a9b92c165f5f09070b6c4ed232c55b30b (patch) | |
tree | ce8db211113ff6e0b26187bc185aeeee2dd06aee /clang/lib/Analysis/BasicValueFactory.cpp | |
parent | 1e0d95e17e940e9c9e0c3ba93698718a035f0c20 (diff) | |
download | bcm5719-llvm-ec9a252a9b92c165f5f09070b6c4ed232c55b30b.tar.gz bcm5719-llvm-ec9a252a9b92c165f5f09070b6c4ed232c55b30b.zip |
CompoundVal now uses an ImmutableList<SVal> to store its set of SVals. This change was motivated by the need to allow state-splitting in GRExprEngine::VisitInitListExpr. As a side-benefit, we no longer need to perform any copies of SVals when creating a CompoundSVal, and the profiling of CompoundSVal is now constant time.
llvm-svn: 58437
Diffstat (limited to 'clang/lib/Analysis/BasicValueFactory.cpp')
-rw-r--r-- | clang/lib/Analysis/BasicValueFactory.cpp | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/clang/lib/Analysis/BasicValueFactory.cpp b/clang/lib/Analysis/BasicValueFactory.cpp index 18fdbdfaaa5..5b7041bc43c 100644 --- a/clang/lib/Analysis/BasicValueFactory.cpp +++ b/clang/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); } |