diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-02-03 09:10:32 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-02-03 09:10:32 +0000 |
commit | 5df3f53616aa7f5857d4466b393dbc372fae79bd (patch) | |
tree | e0e98336c101d1a7933361fac12232c8ab42404a /clang | |
parent | f5e0e3c3a7c80355604d739703cd7d3fe5f8966a (diff) | |
download | bcm5719-llvm-5df3f53616aa7f5857d4466b393dbc372fae79bd.tar.gz bcm5719-llvm-5df3f53616aa7f5857d4466b393dbc372fae79bd.zip |
Add skeleton of flat store manager.
llvm-svn: 95214
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Checker/PathSensitive/Store.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Frontend/Analyses.def | 1 | ||||
-rw-r--r-- | clang/lib/Checker/FlatStore.cpp | 154 |
3 files changed, 156 insertions, 1 deletions
diff --git a/clang/include/clang/Checker/PathSensitive/Store.h b/clang/include/clang/Checker/PathSensitive/Store.h index 7966fed5fb6..08d974b72cc 100644 --- a/clang/include/clang/Checker/PathSensitive/Store.h +++ b/clang/include/clang/Checker/PathSensitive/Store.h @@ -214,7 +214,7 @@ public: StoreManager *CreateBasicStoreManager(GRStateManager& StMgr); StoreManager *CreateRegionStoreManager(GRStateManager& StMgr); StoreManager *CreateFieldsOnlyRegionStoreManager(GRStateManager& StMgr); - +StoreManager *CreateFlatStoreManager(GRStateManager &StMgr); } // end clang namespace #endif diff --git a/clang/include/clang/Frontend/Analyses.def b/clang/include/clang/Frontend/Analyses.def index 7d55673a612..8f183a7b913 100644 --- a/clang/include/clang/Frontend/Analyses.def +++ b/clang/include/clang/Frontend/Analyses.def @@ -61,6 +61,7 @@ ANALYSIS(InlineCall, "inline-call", ANALYSIS_STORE(BasicStore, "basic", "Use basic analyzer store", CreateBasicStoreManager) ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store", CreateRegionStoreManager) +ANALYSIS_STORE(FlatStore, "flat", "Use flat analyzer store", CreateFlatStoreManager) #ifndef ANALYSIS_CONSTRAINTS #define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) diff --git a/clang/lib/Checker/FlatStore.cpp b/clang/lib/Checker/FlatStore.cpp new file mode 100644 index 00000000000..ceb98701071 --- /dev/null +++ b/clang/lib/Checker/FlatStore.cpp @@ -0,0 +1,154 @@ +//=== FlatStore.cpp - Flat region-based store model -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Checker/PathSensitive/GRState.h" +#include "llvm/ADT/ImmutableIntervalMap.h" + +using namespace clang; + +// The actual store type. +typedef llvm::ImmutableIntervalMap<SVal> BindingVal; +typedef llvm::ImmutableMap<const MemRegion *, BindingVal> RegionBindings; + +namespace { +class FlatStoreManager : public StoreManager { + RegionBindings::Factory RBFactory; + BindingVal::Factory BVFactory; + +public: + FlatStoreManager(GRStateManager &mgr) + : StoreManager(mgr), + RBFactory(mgr.getAllocator()), + BVFactory(mgr.getAllocator()) {} + + SValuator::CastResult Retrieve(const GRState *state, Loc loc, QualType T); + const GRState *Bind(const GRState *state, Loc loc, SVal val); + Store Remove(Store St, Loc L); + const GRState *BindCompoundLiteral(const GRState *state, + const CompoundLiteralExpr* cl, + const LocationContext *LC, + SVal v); + + Store getInitialStore(const LocationContext *InitLoc) { + return RBFactory.GetEmptyMap().getRoot(); + } + + SubRegionMap *getSubRegionMap(const GRState *state); + + SVal getLValueVar(const VarDecl *VD, const LocationContext *LC); + + SVal getLValueString(const StringLiteral* sl); + SVal getLValueIvar(const ObjCIvarDecl* decl, SVal base); + SVal getLValueField(const FieldDecl* D, SVal Base); + SVal getLValueElement(QualType elementType, SVal offset, SVal Base); + SVal ArrayToPointer(Loc Array); + void RemoveDeadBindings(GRState &state, Stmt* Loc, + SymbolReaper& SymReaper, + llvm::SmallVectorImpl<const MemRegion*>& RegionRoots); + + const GRState *BindDecl(const GRState *ST, const VarRegion *VR, SVal initVal); + + const GRState *BindDeclWithNoInit(const GRState *ST, const VarRegion *VR); + + typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols; + + const GRState *InvalidateRegion(const GRState *state, + const MemRegion *R, + const Expr *E, unsigned Count, + InvalidatedSymbols *IS); + + void print(Store store, llvm::raw_ostream& Out, const char* nl, + const char *sep); + void iterBindings(Store store, BindingsHandler& f); +}; +} // end anonymous namespace + +StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) { + return new FlatStoreManager(StMgr); +} + +SValuator::CastResult FlatStoreManager::Retrieve(const GRState *state, Loc loc, + QualType T) { + return SValuator::CastResult(state, UnknownVal()); +} + +const GRState *FlatStoreManager::Bind(const GRState *state, Loc loc, SVal val) { + return state; +} + +Store FlatStoreManager::Remove(Store store, Loc L) { + return store; +} + +const GRState *FlatStoreManager::BindCompoundLiteral(const GRState *state, + const CompoundLiteralExpr* cl, + const LocationContext *LC, + SVal v) { + return state; +} + + +SubRegionMap *FlatStoreManager::getSubRegionMap(const GRState *state) { + return 0; +} + +SVal FlatStoreManager::getLValueVar(const VarDecl *VD, + const LocationContext *LC) { + return UnknownVal(); +} + +SVal FlatStoreManager::getLValueString(const StringLiteral* sl) { + return UnknownVal(); +} + +SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) { + return UnknownVal(); +} + +SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) { + return UnknownVal(); +} + +SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset, + SVal Base) { + return UnknownVal(); +} + +SVal FlatStoreManager::ArrayToPointer(Loc Array) { + return Array; +} + +void FlatStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc, + SymbolReaper& SymReaper, + llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) { +} + +const GRState *FlatStoreManager::BindDecl(const GRState *state, + const VarRegion *VR, SVal initVal) { + return state; +} + +const GRState *FlatStoreManager::BindDeclWithNoInit(const GRState *state, + const VarRegion *VR) { + return state; +} + +const GRState *FlatStoreManager::InvalidateRegion(const GRState *state, + const MemRegion *R, + const Expr *E, unsigned Count, + InvalidatedSymbols *IS) { + return state; +} + +void FlatStoreManager::print(Store store, llvm::raw_ostream& Out, + const char* nl, const char *sep) { +} + +void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) { +} |