@@ -36,23 +36,25 @@ ClangTidyProfiling::StorageParams::StorageParams(llvm::StringRef ProfilePrefix,
3636 .str ();
3737}
3838
39- void ClangTidyProfiling::printUserFriendlyTable (llvm::raw_ostream &OS) {
40- TG->print (OS);
39+ void ClangTidyProfiling::printUserFriendlyTable (llvm::raw_ostream &OS,
40+ llvm::TimerGroup &TG) {
41+ TG.print (OS);
4142 OS.flush ();
4243}
4344
44- void ClangTidyProfiling::printAsJSON (llvm::raw_ostream &OS) {
45+ void ClangTidyProfiling::printAsJSON (llvm::raw_ostream &OS,
46+ llvm::TimerGroup &TG) {
4547 OS << " {\n " ;
4648 OS << R"( "file": ")" << Storage->SourceFilename << " \" ,\n " ;
4749 OS << R"( "timestamp": ")" << Storage->Timestamp << " \" ,\n " ;
4850 OS << " \" profile\" : {\n " ;
49- TG-> printJSONValues (OS, " " );
51+ TG. printJSONValues (OS, " " );
5052 OS << " \n }\n " ;
5153 OS << " }\n " ;
5254 OS.flush ();
5355}
5456
55- void ClangTidyProfiling::storeProfileData () {
57+ void ClangTidyProfiling::storeProfileData (llvm::TimerGroup &TG ) {
5658 assert (Storage && " We should have a filename." );
5759
5860 llvm::SmallString<256 > OutputDirectory (Storage->StoreFilename );
@@ -71,19 +73,18 @@ void ClangTidyProfiling::storeProfileData() {
7173 return ;
7274 }
7375
74- printAsJSON (OS);
76+ printAsJSON (OS, TG );
7577}
7678
7779ClangTidyProfiling::ClangTidyProfiling (std::optional<StorageParams> Storage)
7880 : Storage(std::move(Storage)) {}
7981
8082ClangTidyProfiling::~ClangTidyProfiling () {
81- TG.emplace (" clang-tidy" , " clang-tidy checks profiling" , Records);
82-
83+ llvm::TimerGroup TG{" clang-tidy" , " clang-tidy checks profiling" , Records};
8384 if (!Storage)
84- printUserFriendlyTable (llvm::errs ());
85+ printUserFriendlyTable (llvm::errs (), TG );
8586 else
86- storeProfileData ();
87+ storeProfileData (TG );
8788}
8889
8990} // namespace clang::tidy
0 commit comments