Running -grsimple now emits diagnostics about the time spent analyzing each function. Will

probably make this a separate command line option later.

Added "--analyze-function" option to the driver to (gradually) allow different
analyses to only be run on specific functions. Currently only --grsimple uses
this option.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47285 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2008-02-18 21:21:23 +00:00
Родитель f0c8ef0237
Коммит cb33093b4d
3 изменённых файлов: 41 добавлений и 9 удалений

Просмотреть файл

@ -23,6 +23,7 @@
#include "clang/Analysis/Analyses/GRSimpleVals.h"
#include "clang/Analysis/LocalCheckers.h"
#include "llvm/Support/Streams.h"
#include "llvm/Support/Timer.h"
using namespace clang;
//===----------------------------------------------------------------------===//
@ -581,22 +582,43 @@ namespace {
Diagnostic &Diags;
ASTContext* Ctx;
bool Visualize;
std::string FName;
public:
GRSimpleValsVisitor(Diagnostic &diags, bool visualize)
: Diags(diags), Visualize(visualize) {}
GRSimpleValsVisitor(Diagnostic &diags, const std::string& fname, bool visualize)
: Diags(diags), Visualize(visualize), FName(fname) {}
virtual void Initialize(ASTContext &Context) { Ctx = &Context; }
virtual void VisitCFG(CFG& C, FunctionDecl&);
virtual bool printFuncDeclStart() { return Visualize; }
virtual bool printFuncDeclStart() { return false; }
};
} // end anonymous namespace
ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags, bool Visualize) {
return new GRSimpleValsVisitor(Diags, Visualize);
ASTConsumer* clang::CreateGRSimpleVals(Diagnostic &Diags,
const std::string& FunctionName,
bool Visualize) {
return new GRSimpleValsVisitor(Diags, FunctionName, Visualize);
}
void GRSimpleValsVisitor::VisitCFG(CFG& C, FunctionDecl& FD) {
RunGRSimpleVals(C, FD, *Ctx, Diags, Visualize);
if (FName.size() > 0 && FName != FD.getIdentifier()->getName())
return;
if (!Visualize) {
llvm::cerr << "ANALYZE: " << FD.getIdentifier()->getName() << ' '
<< Ctx->getSourceManager().getSourceName(FD.getLocation())
<< ' ';
llvm::Timer T("GRSimpleVals");
T.startTimer();
RunGRSimpleVals(C, FD, *Ctx, Diags, Visualize);
T.stopTimer();
llvm::cerr << T.getWallTime() << '\n';
}
else {
llvm::cerr << '\n';
RunGRSimpleVals(C, FD, *Ctx, Diags, Visualize);
}
}
//===----------------------------------------------------------------------===//

Просмотреть файл

@ -42,7 +42,9 @@ ASTConsumer *CreateDeadStoreChecker(Diagnostic &Diags);
ASTConsumer *CreateUnitValsChecker(Diagnostic &Diags);
ASTConsumer *CreateGRSimpleVals(Diagnostic &Diags, bool Visualize = false);
ASTConsumer *CreateGRSimpleVals(Diagnostic &Diags,
const std::string& Function,
bool Visualize = false);
ASTConsumer *CreateCodeRewriterTest(const std::string& InFile,
Diagnostic &Diags);

Просмотреть файл

@ -448,6 +448,14 @@ static void InitializeDiagnostics(Diagnostic &Diags) {
Diags.setDiagnosticMapping(diag::w_no_declarators, diag::MAP_IGNORE);
}
//===----------------------------------------------------------------------===//
// Analysis-specific options.
//===----------------------------------------------------------------------===//
static llvm::cl::opt<std::string>
AnalyzeSpecificFunction("analyze-function",
llvm::cl::desc("Run analysis on specific function."));
//===----------------------------------------------------------------------===//
// Target Triple Processing.
//===----------------------------------------------------------------------===//
@ -982,10 +990,10 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
return CreateUnitValsChecker(Diag);
case AnalysisGRSimpleVals:
return CreateGRSimpleVals(Diag);
return CreateGRSimpleVals(Diag, AnalyzeSpecificFunction);
case AnalysisGRSimpleValsView:
return CreateGRSimpleVals(Diag, true);
return CreateGRSimpleVals(Diag, AnalyzeSpecificFunction, true);
case TestSerialization:
return CreateSerializationTest(Diag, FileMgr, LangOpts);