aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/PathSensitive/BasicValueFactory.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-10-30 17:44:46 +0000
committerTed Kremenek <kremenek@apple.com>2008-10-30 17:44:46 +0000
commit632e8b84976f683b365eddfacd04ea5d6f4d8cdf (patch)
tree822b1d867825a92a45e0fa198bd7694f83d04fdf /include/clang/Analysis/PathSensitive/BasicValueFactory.h
parent56f6e3f3d289feded4412967599452f3a0aa57d6 (diff)
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/PathSensitive/BasicValueFactory.h')
-rw-r--r--include/clang/Analysis/PathSensitive/BasicValueFactory.h41
1 files changed, 22 insertions, 19 deletions
diff --git a/include/clang/Analysis/PathSensitive/BasicValueFactory.h b/include/clang/Analysis/PathSensitive/BasicValueFactory.h
index 8d4ff9e541..82ed8558be 100644
--- a/include/clang/Analysis/PathSensitive/BasicValueFactory.h
+++ b/include/clang/Analysis/PathSensitive/BasicValueFactory.h
@@ -17,33 +17,26 @@
#define LLVM_CLANG_ANALYSIS_BASICVALUEFACTORY_H
#include "clang/Analysis/PathSensitive/SymbolManager.h"
+#include "clang/Analysis/PathSensitive/SVals.h"
#include "clang/AST/ASTContext.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/APSInt.h"
-
-namespace llvm {
- class BumpPtrAllocator;
-}
+#include "llvm/ADT/ImmutableList.h"
namespace clang {
-class SVal;
-
class CompoundValData : public llvm::FoldingSetNode {
QualType T;
- unsigned NumVals;
- SVal* Vals;
+ llvm::ImmutableList<SVal> L;
public:
- CompoundValData(QualType t, const SVal* vals, unsigned n,
- llvm::BumpPtrAllocator& A);
+ CompoundValData(QualType t, llvm::ImmutableList<SVal> l)
+ : T(t), L(l) {}
- static void Profile(llvm::FoldingSetNodeID& ID, QualType T, unsigned N,
- const SVal* Vals);
+ static void Profile(llvm::FoldingSetNodeID& ID, QualType T,
+ llvm::ImmutableList<SVal> L);
- void Profile(llvm::FoldingSetNodeID& ID) {
- Profile(ID, T, NumVals, Vals);
- }
+ void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, T, L); }
};
class BasicValueFactory {
@@ -62,11 +55,13 @@ class BasicValueFactory {
void* PersistentSVals;
void* PersistentSValPairs;
- llvm::FoldingSet<CompoundValData> CompoundValDataSet;
+ llvm::ImmutableList<SVal>::Factory SValListFactory;
+ llvm::FoldingSet<CompoundValData> CompoundValDataSet;
public:
BasicValueFactory(ASTContext& ctx, llvm::BumpPtrAllocator& Alloc)
- : Ctx(ctx), BPAlloc(Alloc), PersistentSVals(0), PersistentSValPairs(0) {}
+ : Ctx(ctx), BPAlloc(Alloc), PersistentSVals(0), PersistentSValPairs(0),
+ SValListFactory(Alloc) {}
~BasicValueFactory();
@@ -87,8 +82,16 @@ public:
const SymIntConstraint& getConstraint(SymbolID sym, BinaryOperator::Opcode Op,
const llvm::APSInt& V);
- const CompoundValData* getCompoundValData(QualType T, const SVal* Vals,
- unsigned NumVals);
+ const CompoundValData* getCompoundValData(QualType T,
+ llvm::ImmutableList<SVal> Vals);
+
+ llvm::ImmutableList<SVal> getEmptySValList() {
+ return SValListFactory.GetEmptyList();
+ }
+
+ llvm::ImmutableList<SVal> consVals(SVal X, llvm::ImmutableList<SVal> L) {
+ return SValListFactory.Add(X, L);
+ }
const llvm::APSInt* EvaluateAPSInt(BinaryOperator::Opcode Op,
const llvm::APSInt& V1,