Move logic for "-checker-simple" to the new AnalysisConsumer interface.

llvm-svn: 53028
This commit is contained in:
Ted Kremenek 2008-07-02 16:35:50 +00:00
parent 5cc931d409
commit becec2cbbc
5 changed files with 34 additions and 64 deletions

View File

@ -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<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

View File

@ -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,

View File

@ -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<GRTransferFuncs> TF(tf);
// Construct the analysis engine.
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) {
@ -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;
}

View File

@ -19,7 +19,8 @@ namespace clang {
enum Analyses {
WarnDeadStores,
WarnUninitVals,
CheckerCFRef
CheckerCFRef,
CheckerSimple
};
ASTConsumer* CreateAnalysisConsumer(Analyses* Beg, Analyses* End,

View File

@ -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);