diff --git a/clang/Driver/ASTConsumers.cpp b/clang/Driver/ASTConsumers.cpp index 9ff0387702ed..a25468794de6 100644 --- a/clang/Driver/ASTConsumers.cpp +++ b/clang/Driver/ASTConsumers.cpp @@ -732,39 +732,6 @@ void CheckerConsumer::VisitCFG(CFG& C, Decl& CD) { } } -//===----------------------------------------------------------------------===// -// 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& 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 diff --git a/clang/Driver/ASTConsumers.h b/clang/Driver/ASTConsumers.h index c19a1afa5cf5..6bba0bbab901 100644 --- a/clang/Driver/ASTConsumers.h +++ b/clang/Driver/ASTConsumers.h @@ -40,12 +40,6 @@ ASTConsumer *CreateCFGDumper(bool ViewGraphs, const std::string& FName); 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, diff --git a/clang/Driver/AnalysisConsumer.cpp b/clang/Driver/AnalysisConsumer.cpp index 57be0ff55d6a..ea2418610ec5 100644 --- a/clang/Driver/AnalysisConsumer.cpp +++ b/clang/Driver/AnalysisConsumer.cpp @@ -227,24 +227,30 @@ static void ActionUninitVals(AnalysisManager& mgr) { } -static void ActionRefLeakCheckerAux(AnalysisManager& mgr, bool GCEnabled, - bool StandardWarnings) { - - // Construct the analysis engine. - GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext()); +static void ActionGRExprEngine(AnalysisManager& mgr, GRTransferFuncs* tf) { + + llvm::OwningPtr TF(tf); + + // Construct the analysis engine. + GRExprEngine Eng(*mgr.getCFG(), *mgr.getCodeDecl(), mgr.getContext()); + Eng.setTransferFunctions(tf); - // Construct the transfer function object. - llvm::OwningPtr - 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) { @@ -267,6 +273,10 @@ static void ActionRefLeakChecker(AnalysisManager& mgr) { } } +static void ActionSimpleChecks(AnalysisManager& mgr) { + ActionGRExprEngine(mgr, MakeGRSimpleValsTF()); +} + //===----------------------------------------------------------------------===// // AnalysisConsumer creation. //===----------------------------------------------------------------------===// @@ -298,6 +308,10 @@ ASTConsumer* clang::CreateAnalysisConsumer(Analyses* Beg, Analyses* End, C->addCodeAction(&ActionRefLeakChecker); break; + case CheckerSimple: + C->addCodeAction(&ActionSimpleChecks); + break; + default: break; } diff --git a/clang/Driver/AnalysisConsumer.h b/clang/Driver/AnalysisConsumer.h index 8514a9b531ab..487706b67591 100644 --- a/clang/Driver/AnalysisConsumer.h +++ b/clang/Driver/AnalysisConsumer.h @@ -19,7 +19,8 @@ namespace clang { enum Analyses { WarnDeadStores, WarnUninitVals, - CheckerCFRef + CheckerCFRef, + CheckerSimple }; ASTConsumer* CreateAnalysisConsumer(Analyses* Beg, Analyses* End, diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index 344fe08bffd6..9de09243305a 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -75,8 +75,6 @@ enum ProgActions { 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. @@ -117,8 +115,6 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore, "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", @@ -179,8 +175,10 @@ clEnumValN(WarnDeadStores, "warn-dead-stores", "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)); //===----------------------------------------------------------------------===// @@ -1200,11 +1198,7 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile, case AnalysisLiveVariables: return CreateLiveVarAnalyzer(AnalyzeSpecificFunction); - - case AnalysisGRSimpleVals: - return CreateGRSimpleVals(Diag, PP, PPF, AnalyzeSpecificFunction, - OutputFile, VisualizeEG, TrimGraph, AnalyzeAll); - + case TestSerialization: return CreateSerializationTest(Diag, FileMgr);