Index: include/clang/StaticAnalyzer/Core/AnalyzerOptions.h =================================================================== --- include/clang/StaticAnalyzer/Core/AnalyzerOptions.h +++ include/clang/StaticAnalyzer/Core/AnalyzerOptions.h @@ -20,6 +20,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Timer.h" #include #include #include @@ -188,6 +189,10 @@ /// The mode of function selection used during inlining. AnalysisInliningMode InliningMode = NoRedundancy; + /// Returns the timer group used accross the analyzer + std::shared_ptr AnalyzerTimers = + std::make_shared("analyzer", "Analyzer timers"); + enum class ExplorationStrategyKind { DFS, BFS, Index: lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- lib/StaticAnalyzer/Core/BugReporter.cpp +++ lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2594,6 +2594,14 @@ AnalyzerOptions &Opts, GRBugReporter &Reporter) { + bool enableStatistics = Opts.PrintStats || Opts.shouldSerializeStats(); + + llvm::Timer CrosscheckTimer; + if (Opts.shouldCrosscheckWithZ3() && enableStatistics) { + CrosscheckTimer.init("crosscheck", "Crosscheck total time", + *Opts.AnalyzerTimers); + } + while (TrimG.popNextReportGraph(ErrorGraph)) { // Find the BugReport with the original location. assert(ErrorGraph.Index < bugReports.size()); @@ -2624,9 +2632,13 @@ R->clearVisitors(); R->addVisitor(llvm::make_unique()); + if (enableStatistics) CrosscheckTimer.startTimer(); + // We don't overrite the notes inserted by other visitors because the // refutation manager does not add any new note to the path generateVisitorsDiagnostics(R, ErrorGraph.ErrorNode, BRC); + + if(enableStatistics) CrosscheckTimer.stopTimer(); } // Check if the bug is still valid Index: lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -192,7 +192,6 @@ std::unique_ptr Mgr; /// Time the analyzes time of each translation unit. - std::unique_ptr AnalyzerTimers; std::unique_ptr TUTotalTimer; /// The information about analyzed functions shared throughout the @@ -207,10 +206,8 @@ Plugins(plugins), Injector(injector), CTU(CI) { DigestAnalyzerOptions(); if (Opts->PrintStats || Opts->shouldSerializeStats()) { - AnalyzerTimers = llvm::make_unique( - "analyzer", "Analyzer timers"); TUTotalTimer = llvm::make_unique( - "time", "Analyzer total time", *AnalyzerTimers); + "time", "Analyzer total time", *Opts->AnalyzerTimers); llvm::EnableStatistics(/* PrintOnExit= */ false); } }