//
//===----------------------------------------------------------------------===//
+#ifndef ANALYSIS
+#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)
+#endif
+
+#ifndef ANALYSIS_STORE
+#define ANALYSIS_STORE(NAME, CMDFLAG, DESC)
+#endif
+
ANALYSIS(CFGDump, "cfg-dump",
"Display Control-Flow Graphs", Code)
ANALYSIS(CheckerCFRef, "checker-cfref",
"Run the [Core] Foundation reference count checker", Code)
+
+ANALYSIS_STORE(BasicStore, "basic", "Use basic analyzer store")
+ANALYSIS_STORE(RegionStore, "region", "Use region-based analyzer store")
+
#undef ANALYSIS
+#undef ANALYSIS_STORE
const bool VisGraphviz;
const bool VisUbigraph;
const bool TrimGraph;
- const LangOptions& LOpts;
+ const LangOptions& LOpts;
Diagnostic &Diags;
ASTContext* Ctx;
Preprocessor* PP;
const std::string FName;
llvm::OwningPtr<PathDiagnosticClient> PD;
bool AnalyzeAll;
+ AnalysisStores SM;
AnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
PreprocessorFactory* ppf,
const LangOptions& lopts,
const std::string& fname,
const std::string& htmldir,
+ AnalysisStores sm,
bool visgraphviz, bool visubi, bool trim, bool analyzeAll)
: VisGraphviz(visgraphviz), VisUbigraph(visubi), TrimGraph(trim),
LOpts(lopts), Diags(diags),
Ctx(0), PP(pp), PPF(ppf),
HTMLDir(htmldir),
FName(fname),
- AnalyzeAll(analyzeAll) {}
+ AnalyzeAll(analyzeAll), SM(sm) {}
void addCodeAction(CodeAction action) {
FunctionActions.push_back(action);
Decl* getCodeDecl() const { return D; }
Stmt* getBody() const { return Body; }
+ GRStateManager::StoreManagerCreator getStoreManagerCreator() {
+ switch (C.SM) {
+ default:
+#define ANALYSIS_STORE(NAME, CMDFLAG, DESC)\
+case NAME##Model: return Create##NAME##Manager;
+#include "Analyses.def"
+ }
+ };
+
virtual CFG* getCFG() {
if (!cfg) cfg.reset(CFG::buildCFG(getBody()));
return cfg.get();
// Display progress.
mgr.DisplayFunction();
- GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext(), *L);
+ GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext(), *L,
+ mgr.getStoreManagerCreator());
+
Eng.setTransferFunctions(tf);
if (StandardWarnings) {
//===----------------------------------------------------------------------===//
ASTConsumer* clang::CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
+ AnalysisStores SM,
Diagnostic &diags, Preprocessor* pp,
PreprocessorFactory* ppf,
const LangOptions& lopts,
bool analyzeAll) {
llvm::OwningPtr<AnalysisConsumer>
- C(new AnalysisConsumer(diags, pp, ppf, lopts, fname, htmldir,
+ C(new AnalysisConsumer(diags, pp, ppf, lopts, fname, htmldir, SM,
VisGraphviz, VisUbi, trim, analyzeAll));
for ( ; Beg != End ; ++Beg)
#include "Analyses.def"
NumAnalyses
};
+
+enum AnalysisStores {
+#define ANALYSIS_STORE(NAME, CMDFLAG, DESC) NAME##Model,
+#include "Analyses.def"
+NumStores
+};
ASTConsumer* CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
+ AnalysisStores SM,
Diagnostic &diags, Preprocessor* pp,
PreprocessorFactory* ppf,
const LangOptions& lopts,
const std::string& htmldir,
bool VisualizeGraphViz,
bool VisualizeUbi,
- bool VizTrimGraph,
+ bool VizTrimGraph,
bool AnalyzeAll);
} // end clang namespace
"functions defined in header files"));
static llvm::cl::list<Analyses>
-AnalysisList(llvm::cl::desc("Available Source Code Analyses:"),
+AnalysisList(llvm::cl::desc("SCA Checks/Analyses:"),
llvm::cl::values(
#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)\
clEnumValN(NAME, CMDFLAG, DESC),
#include "Analyses.def"
clEnumValEnd));
+static llvm::cl::opt<AnalysisStores>
+AnalysisStoreOpt(llvm::cl::desc("SCA Low-Level Options (Store):"),
+ llvm::cl::init(BasicStoreModel),
+ llvm::cl::values(
+#define ANALYSIS_STORE(NAME, CMDFLAG, DESC)\
+clEnumValN(NAME##Model, "analyzer-store-" CMDFLAG, DESC),
+#include "Analyses.def"
+clEnumValEnd));
+
//===----------------------------------------------------------------------===//
// Language Options
//===----------------------------------------------------------------------===//
assert (!AnalysisList.empty());
return CreateAnalysisConsumer(&AnalysisList[0],
&AnalysisList[0]+AnalysisList.size(),
+ AnalysisStoreOpt,
Diag, PP, PPF, LangOpts,
AnalyzeSpecificFunction,
OutputFile, VisualizeEGDot, VisualizeEGUbi,
UndefArgsTy MsgExprUndefArgs;
public:
- GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx, LiveVariables& L);
+ GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx, LiveVariables& L,
+ GRStateManager::StoreManagerCreator SMC =
+ CreateBasicStoreManager);
+
~GRExprEngine();
void ExecuteWorkList(unsigned Steps = 150000) {
};
StoreManager* CreateBasicStoreManager(GRStateManager& StMgr);
+StoreManager* CreateRegionStoreManager(GRStateManager& StMgr);
} // end clang namespace
GRExprEngine::GRExprEngine(CFG& cfg, Decl& CD, ASTContext& Ctx,
- LiveVariables& L)
+ LiveVariables& L,
+ GRStateManager::StoreManagerCreator SMC)
: CoreEngine(cfg, CD, Ctx, *this),
G(CoreEngine.getGraph()),
Liveness(L),
Builder(NULL),
- StateMgr(G.getContext(), CreateBasicStoreManager,
+ StateMgr(G.getContext(), SMC,
CreateBasicConstraintManager, G.getAllocator(), G.getCFG(), L),
SymMgr(StateMgr.getSymbolManager()),
CurrentStmt(NULL),
} // end anonymous namespace
+StoreManager* clang::CreateRegionStoreManager(GRStateManager& StMgr) {
+ // return new RegionStoreManager(StMgr);
+ return 0; // Uncomment the above line when RegionStoreManager is not abstract.
+}
+
Loc RegionStoreManager::getElementLoc(const VarDecl* VD, SVal Idx) {
MemRegion* R = MRMgr.getVarRegion(VD);
ElementRegion* ER = MRMgr.getElementRegion(Idx, R);