[cfe-commits] r95214 - in /cfe/trunk: include/clang/Checker/PathSensitive/Store.h include/clang/Frontend/Analyses.def lib/Checker/FlatStore.cpp

Zhongxing Xu xuzhongxing at gmail.com
Wed Feb 3 01:10:32 PST 2010


Author: zhongxingxu
Date: Wed Feb  3 03:10:32 2010
New Revision: 95214

URL: http://llvm.org/viewvc/llvm-project?rev=95214&view=rev
Log:
Add skeleton of flat store manager.

Added:
    cfe/trunk/lib/Checker/FlatStore.cpp
Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/Store.h
    cfe/trunk/include/clang/Frontend/Analyses.def

Modified: cfe/trunk/include/clang/Checker/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/Store.h?rev=95214&r1=95213&r2=95214&view=diff

==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/Store.h Wed Feb  3 03:10:32 2010
@@ -214,7 +214,7 @@
 StoreManager *CreateBasicStoreManager(GRStateManager& StMgr);
 StoreManager *CreateRegionStoreManager(GRStateManager& StMgr);
 StoreManager *CreateFieldsOnlyRegionStoreManager(GRStateManager& StMgr);
-
+StoreManager *CreateFlatStoreManager(GRStateManager &StMgr);
 } // end clang namespace
 
 #endif

Modified: cfe/trunk/include/clang/Frontend/Analyses.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Analyses.def?rev=95214&r1=95213&r2=95214&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/Analyses.def (original)
+++ cfe/trunk/include/clang/Frontend/Analyses.def Wed Feb  3 03:10:32 2010
@@ -61,6 +61,7 @@
 
 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)

Added: cfe/trunk/lib/Checker/FlatStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/FlatStore.cpp?rev=95214&view=auto

==============================================================================
--- cfe/trunk/lib/Checker/FlatStore.cpp (added)
+++ cfe/trunk/lib/Checker/FlatStore.cpp Wed Feb  3 03:10:32 2010
@@ -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) {
+}





More information about the cfe-commits mailing list