diff options
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Analysis/PathSensitive/BasicStore.h | 9 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/GRState.h | 17 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/Store.h | 75 |
3 files changed, 85 insertions, 16 deletions
diff --git a/include/clang/Analysis/PathSensitive/BasicStore.h b/include/clang/Analysis/PathSensitive/BasicStore.h index d9d3208ac5..0c7e8ece2a 100644 --- a/include/clang/Analysis/PathSensitive/BasicStore.h +++ b/include/clang/Analysis/PathSensitive/BasicStore.h @@ -16,14 +16,9 @@ #include "clang/Analysis/PathSensitive/Store.h" -namespace llvm { - class BumpPtrAllocator; - class ASTContext; -} - namespace clang { - StoreManager* CreateBasicStoreManager(llvm::BumpPtrAllocator& Alloc, - ASTContext& Ctx); + class GRStateManager; + StoreManager* CreateBasicStoreManager(GRStateManager& StMgr); } #endif diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index aca5a66a52..0ecfb27c16 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -288,15 +288,17 @@ private: const GRState* BindVar(const GRState* St, VarDecl* D, RVal V) { return SetRVal(St, lval::DeclVal(D), V); } - - typedef ConstraintManager* (*ConstraintManagerCreater)(GRStateManager&); -public: - GRStateManager(ASTContext& Ctx, StoreManager* stmgr, - ConstraintManagerCreater CreateConstraintManager, +public: + + typedef ConstraintManager* (*ConstraintManagerCreator)(GRStateManager&); + typedef StoreManager* (*StoreManagerCreator)(GRStateManager&); + + GRStateManager(ASTContext& Ctx, + StoreManagerCreator CreateStoreManager, + ConstraintManagerCreator CreateConstraintManager, llvm::BumpPtrAllocator& alloc, CFG& c, LiveVariables& L) : EnvMgr(alloc), - StMgr(stmgr), ISetFactory(alloc), GDMFactory(alloc), BasicVals(Ctx, alloc), @@ -304,7 +306,8 @@ public: Alloc(alloc), cfg(c), Liveness(L) { - ConstraintMgr.reset((*CreateConstraintManager)(*this)); + StMgr.reset((*CreateStoreManager)(*this)); + ConstraintMgr.reset((*CreateConstraintManager)(*this)); } ~GRStateManager(); diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h index 42ee328f60..0014c6dfb5 100644 --- a/include/clang/Analysis/PathSensitive/Store.h +++ b/include/clang/Analysis/PathSensitive/Store.h @@ -15,7 +15,6 @@ #define LLVM_CLANG_ANALYSIS_STORE_H #include "clang/Analysis/PathSensitive/RValues.h" -#include "clang/Analysis/PathSensitive/Regions.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/DenseSet.h" @@ -25,6 +24,78 @@ namespace clang { typedef const void* Store; + +namespace store { + typedef const void* Binding; + typedef const void* Region; + + class RegionExtent { + public: + enum Kind { Unknown = 0, Int = 0, Sym = 1 }; + + protected: + const uintptr_t Raw; + RegionExtent(uintptr_t raw, Kind k) : Raw(raw | k) {} + uintptr_t getData() const { return Raw & ~0x1; } + + public: + // Folding-set profiling. + void Profile(llvm::FoldingSetNodeID& ID) const { + ID.AddPointer((void*) Raw); + } + // Comparing extents. + bool operator==(const RegionExtent& R) const { + return Raw == R.Raw; + } + bool operator!=(const RegionExtent& R) const { + return Raw != R.Raw; + } + // Implement isa<T> support. + Kind getKind() const { return Kind(Raw & 0x1); } + uintptr_t getRaw() const { return Raw; } + + static inline bool classof(const RegionExtent*) { + return true; + } + }; + + class UnknownExtent : public RegionExtent { + public: + UnknownExtent() : RegionExtent(0,Unknown) {} + + // Implement isa<T> support. + static inline bool classof(const RegionExtent* E) { + return E->getRaw() == 0; + } + }; + + class IntExtent : public RegionExtent { + public: + IntExtent(const llvm::APSInt& X) : RegionExtent((uintptr_t) &X, Int) {} + + const llvm::APSInt& getInt() const { + return *((llvm::APSInt*) getData()); + } + + // Implement isa<T> support. + static inline bool classof(const RegionExtent* E) { + return E->getKind() == Int && E->getRaw() != 0; + } + }; + + class SymExtent : public RegionExtent { + public: + SymExtent(SymbolID S) : RegionExtent(S.getNumber() << 1, Sym) {} + + SymbolID getSymbol() const { return SymbolID(getData() >> 1); } + + // Implement isa<T> support. + static inline bool classof(const RegionExtent* E) { + return E->getKind() == Sym; + } + }; +} // end store namespace + class GRStateManager; class LiveVariables; class Stmt; @@ -54,7 +125,7 @@ public: const char* nl, const char *sep) = 0; /// getExtent - Returns the size of the region in bits. - virtual RegionExtent getExtent(GRStateManager& SM, Region R) = 0; + virtual store::RegionExtent getExtent(store::Region R) =0; }; } // end clang namespace |