diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-10-30 04:58:00 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-10-30 04:58:00 +0000 |
commit | 6764b72f6f26b5c03471b9e379a44d379d2d4a9e (patch) | |
tree | ca1267933cd471c1976f4bcd2bc784590f0d14d8 /lib/Analysis/BasicValueFactory.cpp | |
parent | bed311564e4cbaeecd6de20c2f0ab8e348f932b1 (diff) |
Add CompoundVal and CompoundValData for representing the value of InitListExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58418 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicValueFactory.cpp')
-rw-r--r-- | lib/Analysis/BasicValueFactory.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Analysis/BasicValueFactory.cpp b/lib/Analysis/BasicValueFactory.cpp index 0ef34b82b9..18fdbdfaaa 100644 --- a/lib/Analysis/BasicValueFactory.cpp +++ b/lib/Analysis/BasicValueFactory.cpp @@ -18,6 +18,26 @@ 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) { + T.Profile(ID); + ID.AddInteger(N); + for (unsigned i = 0; i < N; ++i) + Vals[i].Profile(ID); +} + typedef std::pair<SVal, uintptr_t> SValData; typedef std::pair<SVal, SVal> SValPair; @@ -106,6 +126,24 @@ BasicValueFactory::getConstraint(SymbolID sym, BinaryOperator::Opcode Op, return *C; } +const CompoundValData* +BasicValueFactory::getCompoundValData(QualType T, const SVal* Vals, + unsigned NumVals) { + llvm::FoldingSetNodeID ID; + CompoundValData::Profile(ID, T, NumVals, Vals); + void* InsertPos; + + CompoundValData* D = CompoundValDataSet.FindNodeOrInsertPos(ID, InsertPos); + + if (!D) { + D = (CompoundValData*) BPAlloc.Allocate<CompoundValData>(); + new (D) CompoundValData(T, Vals, NumVals, BPAlloc); + CompoundValDataSet.InsertNode(D, InsertPos); + } + + return D; +} + const llvm::APSInt* BasicValueFactory::EvaluateAPSInt(BinaryOperator::Opcode Op, const llvm::APSInt& V1, const llvm::APSInt& V2) { |