Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -116,6 +116,10 @@ std::unique_ptr ExprEngineTimer; std::unique_ptr BugReporterTimer; + /// Saves timer's last value + llvm::TimeRecord LastSyntaxTimerValue; + llvm::TimeRecord LastPathTimerValue; + /// The information about analyzed functions shared throughout the /// translation unit. FunctionSummariesTy FunctionSummaries; @@ -128,7 +132,7 @@ Plugins(plugins), Injector(injector), CTU(CI), MacroExpansions(CI.getLangOpts()) { DigestAnalyzerOptions(); - if (Opts->PrintStats || Opts->ShouldSerializeStats) { + if (Opts->AnalyzerDisplayProgress || Opts->PrintStats || Opts->ShouldSerializeStats) { AnalyzerTimers = std::make_unique( "analyzer", "Analyzer timers"); SyntaxCheckTimer = std::make_unique( @@ -138,6 +142,9 @@ BugReporterTimer = std::make_unique( "bugreporter", "Path-sensitive report post-processing time", *AnalyzerTimers); + } + + if (Opts->PrintStats || Opts->ShouldSerializeStats) { llvm::EnableStatistics(/* PrintOnExit= */ false); } @@ -209,8 +216,26 @@ } else assert(Mode == (AM_Syntax | AM_Path) && "Unexpected mode!"); - llvm::errs() << ": " << Loc.getFilename() << ' ' << getFunctionName(D) - << '\n'; + llvm::errs() << ": " << Loc.getFilename() << ' ' << getFunctionName(D); + + if (Mode == AM_Syntax) + llvm::errs() << " : " + << llvm::format( + "%1.1f", + (SyntaxCheckTimer->getTotalTime().getWallTime() - + LastSyntaxTimerValue.getWallTime()) * + 1000) + << " ms"; + else if (Mode == AM_Path) + llvm::errs() << " : " + << llvm::format( + "%1.1f", + (ExprEngineTimer->getTotalTime().getWallTime() - + LastPathTimerValue.getWallTime()) * + 1000) + << " ms"; + + llvm::errs() << " \n"; } } @@ -262,8 +287,10 @@ bool VisitDecl(Decl *D) { AnalysisMode Mode = getModeForDecl(D, RecVisitorMode); if (Mode & AM_Syntax) { - if (SyntaxCheckTimer) + if (SyntaxCheckTimer) { + LastSyntaxTimerValue = SyntaxCheckTimer->getTotalTime(); SyntaxCheckTimer->startTimer(); + } checkerMgr->runCheckersOnASTDecl(D, *Mgr, *RecVisitorBR); if (SyntaxCheckTimer) SyntaxCheckTimer->stopTimer(); @@ -493,8 +520,10 @@ void AnalysisConsumer::runAnalysisOnTranslationUnit(ASTContext &C) { BugReporter BR(*Mgr); TranslationUnitDecl *TU = C.getTranslationUnitDecl(); - if (SyntaxCheckTimer) + if (SyntaxCheckTimer){ + LastSyntaxTimerValue = SyntaxCheckTimer->getTotalTime(); SyntaxCheckTimer->startTimer(); + } checkerMgr->runCheckersOnASTDecl(TU, *Mgr, BR); if (SyntaxCheckTimer) SyntaxCheckTimer->stopTimer(); @@ -661,7 +690,6 @@ if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized()) return; - DisplayFunction(D, Mode, IMode); CFG *DeclCFG = Mgr->getCFG(D); if (DeclCFG) MaxCFGSize.updateMax(DeclCFG->size()); @@ -669,8 +697,10 @@ BugReporter BR(*Mgr); if (Mode & AM_Syntax) { - if (SyntaxCheckTimer) + if (SyntaxCheckTimer){ + LastSyntaxTimerValue = SyntaxCheckTimer->getTotalTime(); SyntaxCheckTimer->startTimer(); + } checkerMgr->runCheckersOnASTBody(D, *Mgr, BR); if (SyntaxCheckTimer) SyntaxCheckTimer->stopTimer(); @@ -683,6 +713,7 @@ if (IMode != ExprEngine::Inline_Minimal) NumFunctionsAnalyzed++; } + DisplayFunction(D, Mode, IMode); } //===----------------------------------------------------------------------===// @@ -704,8 +735,10 @@ ExprEngine Eng(CTU, *Mgr, VisitedCallees, &FunctionSummaries, IMode); // Execute the worklist algorithm. - if (ExprEngineTimer) + if (ExprEngineTimer){ + LastPathTimerValue = ExprEngineTimer->getTotalTime(); ExprEngineTimer->startTimer(); + } Eng.ExecuteWorkList(Mgr->getAnalysisDeclContextManager().getStackFrame(D), Mgr->options.MaxNodesPerTopLevelFunction); if (ExprEngineTimer)