summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/BasicValueFactory.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2008-10-30 04:58:00 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2008-10-30 04:58:00 +0000
commitef5f25a05f4eb155d06067ee380d13fd26ff36c5 (patch)
tree160008111a0e1bbd582b4e981d1855e5f0f58447 /clang/lib/Analysis/BasicValueFactory.cpp
parent51ac923ca35a7d5e8e9e70f2447305b21fece642 (diff)
downloadbcm5719-llvm-ef5f25a05f4eb155d06067ee380d13fd26ff36c5.tar.gz
bcm5719-llvm-ef5f25a05f4eb155d06067ee380d13fd26ff36c5.zip
Add CompoundVal and CompoundValData for representing the value of InitListExpr.
llvm-svn: 58418
Diffstat (limited to 'clang/lib/Analysis/BasicValueFactory.cpp')
-rw-r--r--clang/lib/Analysis/BasicValueFactory.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/clang/lib/Analysis/BasicValueFactory.cpp b/clang/lib/Analysis/BasicValueFactory.cpp
index 0ef34b82b9d..18fdbdfaaa5 100644
--- a/clang/lib/Analysis/BasicValueFactory.cpp
+++ b/clang/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) {
OpenPOWER on IntegriCloud