}
}
-//===----------------------------------------------------------------------===//
-// GRSimpleVals - Perform intra-procedural, path-sensitive constant propagation.
-
-namespace {
-class GRSimpleValsVisitor : public CheckerConsumer {
-public:
- GRSimpleValsVisitor(Diagnostic &diags, Preprocessor* pp,
- PreprocessorFactory* ppf,
- const std::string& fname, const std::string& htmldir,
- bool visualize, bool trim, bool analyzeAll)
- : CheckerConsumer(diags, pp, ppf, fname, htmldir, visualize,
- trim, analyzeAll) {}
-
- virtual const char* getCheckerName() { return "GRSimpleVals"; }
-
- virtual void getTransferFunctions(std::vector<GRTransferFuncs*>& TFs) {
- return TFs.push_back(MakeGRSimpleValsTF());
- }
-};
-} // end anonymous namespace
-
-ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags,
- Preprocessor* PP,
- PreprocessorFactory* PPF,
- const std::string& FunctionName,
- const std::string& HTMLDir,
- bool Visualize, bool TrimGraph,
- bool AnalyzeAll) {
-
- return new GRSimpleValsVisitor(Diags, PP, PPF, FunctionName, HTMLDir,
- Visualize, TrimGraph, AnalyzeAll);
-}
-
//===----------------------------------------------------------------------===//
// AST Serializer
ASTConsumer *CreateLiveVarAnalyzer(const std::string& fname);
-ASTConsumer *CreateGRSimpleVals(Diagnostic &Diags,
- Preprocessor* PP, PreprocessorFactory* PPF,
- const std::string& Function,
- const std::string& HTMLDir, bool Visualize,
- bool TrimGraph, bool AnalyzeAll);
-
ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
const std::string& OutFile,
Diagnostic &Diags,
}
-static void ActionRefLeakCheckerAux(AnalysisManager& mgr, bool GCEnabled,
- bool StandardWarnings) {
-
+static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf) {
+
+ llvm::OwningPtr<GRTransferFuncs> TF(tf);
+
// Construct the analysis engine.
- GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext());
+ GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext());
+ Eng.setTransferFunctions(tf);
- // Construct the transfer function object.
- llvm::OwningPtr<GRTransferFuncs>
- TF(MakeCFRefCountTF(mgr.getContext(), GCEnabled, StandardWarnings,
- mgr.getLangOptions()));
-
- Eng.setTransferFunctions(TF.get());
-
// Execute the worklist algorithm.
Eng.ExecuteWorkList();
-
+
// Display warnings.
- Eng.EmitWarnings(mgr.getDiagnostic(), mgr.getPathDiagnosticClient());
+ Eng.EmitWarnings(mgr.getDiagnostic(), mgr.getPathDiagnosticClient());
+}
+
+static void ActionRefLeakCheckerAux(AnalysisManager& mgr, bool GCEnabled,
+ bool StandardWarnings) {
+
+ GRTransferFuncs* TF = MakeCFRefCountTF(mgr.getContext(),
+ GCEnabled,
+ StandardWarnings,
+ mgr.getLangOptions());
+
+ ActionGRExprEngine(mgr, TF);
}
static void ActionRefLeakChecker(AnalysisManager& mgr) {
}
}
+static void ActionSimpleChecks(AnalysisManager& mgr) {
+ ActionGRExprEngine(mgr, MakeGRSimpleValsTF());
+}
+
//===----------------------------------------------------------------------===//
// AnalysisConsumer creation.
//===----------------------------------------------------------------------===//
C->addCodeAction(&ActionRefLeakChecker);
break;
+ case CheckerSimple:
+ C->addCodeAction(&ActionSimpleChecks);
+ break;
+
default: break;
}
enum Analyses {
WarnDeadStores,
WarnUninitVals,
- CheckerCFRef
+ CheckerCFRef,
+ CheckerSimple
};
ASTConsumer* CreateAnalysisConsumer(Analyses* Beg, Analyses* End,
ParseCFGDump, // Parse ASTS. Build CFGs. Print CFGs.
ParseCFGView, // Parse ASTS. Build CFGs. View CFGs.
AnalysisLiveVariables, // Print results of live-variable analysis.
- AnalysisGRSimpleVals, // Perform graph-reachability constant prop.
- AnalysisGRSimpleValsView, // Visualize results of path-sens. analysis.
TestSerialization, // Run experimental serialization code.
ParsePrintCallbacks, // Parse and print each callback.
ParseSyntaxOnly, // Parse and perform semantic analysis.
"Run parser, then build and view CFGs with Graphviz"),
clEnumValN(AnalysisLiveVariables, "dump-live-variables",
"Print results of live variable analysis"),
- clEnumValN(AnalysisGRSimpleVals, "checker-simple",
- "Perform path-sensitive constant propagation"),
clEnumValN(TestSerialization, "test-pickling",
"Run prototype serialization code"),
clEnumValN(EmitLLVM, "emit-llvm",
"Flag warnings of stores to dead variables"),
clEnumValN(WarnUninitVals, "warn-uninit-values",
"Flag warnings of uses of unitialized variables"),
+clEnumValN(CheckerSimple, "checker-simple",
+ "Perform simple path-sensitive checks."),
clEnumValN(CheckerCFRef, "checker-cfref",
- "Run the [Core] Foundation reference count checker"),
+ "Run the [Core] Foundation reference count checker"),
clEnumValEnd));
//===----------------------------------------------------------------------===//
case AnalysisLiveVariables:
return CreateLiveVarAnalyzer(AnalyzeSpecificFunction);
-
- case AnalysisGRSimpleVals:
- return CreateGRSimpleVals(Diag, PP, PPF, AnalyzeSpecificFunction,
- OutputFile, VisualizeEG, TrimGraph, AnalyzeAll);
-
+
case TestSerialization:
return CreateSerializationTest(Diag, FileMgr);