2010-02-03 17:10:32 +08:00
|
|
|
//=== 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()) {}
|
|
|
|
|
2010-02-05 11:01:53 +08:00
|
|
|
SVal Retrieve(Store store, Loc loc, QualType T);
|
2010-02-05 13:06:13 +08:00
|
|
|
Store Bind(Store store, Loc loc, SVal val);
|
2010-02-03 17:10:32 +08:00
|
|
|
Store Remove(Store St, Loc L);
|
2010-02-05 13:06:13 +08:00
|
|
|
Store BindCompoundLiteral(Store store, const CompoundLiteralExpr* cl,
|
|
|
|
const LocationContext *LC, SVal v);
|
2010-02-03 17:10:32 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store BindDecl(Store store, const VarRegion *VR, SVal initVal);
|
2010-02-03 17:10:32 +08:00
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store BindDeclWithNoInit(Store store, const VarRegion *VR);
|
2010-02-03 17:10:32 +08:00
|
|
|
|
|
|
|
typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols;
|
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E,
|
|
|
|
unsigned Count, InvalidatedSymbols *IS);
|
2010-02-03 17:10:32 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2010-02-05 11:01:53 +08:00
|
|
|
SVal FlatStoreManager::Retrieve(Store store, Loc loc, QualType T) {
|
2010-02-04 10:39:47 +08:00
|
|
|
return UnknownVal();
|
2010-02-03 17:10:32 +08:00
|
|
|
}
|
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store FlatStoreManager::Bind(Store store, Loc loc, SVal val) {
|
|
|
|
return store;
|
2010-02-03 17:10:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Store FlatStoreManager::Remove(Store store, Loc L) {
|
|
|
|
return store;
|
|
|
|
}
|
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store FlatStoreManager::BindCompoundLiteral(Store store,
|
|
|
|
const CompoundLiteralExpr* cl,
|
|
|
|
const LocationContext *LC,
|
|
|
|
SVal v) {
|
|
|
|
return store;
|
2010-02-03 17:10:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
}
|
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store FlatStoreManager::BindDecl(Store store, const VarRegion *VR,
|
|
|
|
SVal initVal) {
|
|
|
|
return store;
|
2010-02-03 17:10:32 +08:00
|
|
|
}
|
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR) {
|
|
|
|
return store;
|
2010-02-03 17:10:32 +08:00
|
|
|
}
|
|
|
|
|
2010-02-05 13:06:13 +08:00
|
|
|
Store FlatStoreManager::InvalidateRegion(Store store, const MemRegion *R,
|
|
|
|
const Expr *E, unsigned Count,
|
|
|
|
InvalidatedSymbols *IS) {
|
|
|
|
return store;
|
2010-02-03 17:10:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void FlatStoreManager::print(Store store, llvm::raw_ostream& Out,
|
|
|
|
const char* nl, const char *sep) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void FlatStoreManager::iterBindings(Store store, BindingsHandler& f) {
|
|
|
|
}
|