@@ -36,23 +36,25 @@ ClangTidyProfiling::StorageParams::StorageParams(llvm::StringRef ProfilePrefix,
36
36
.str ();
37
37
}
38
38
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);
41
42
OS.flush ();
42
43
}
43
44
44
- void ClangTidyProfiling::printAsJSON (llvm::raw_ostream &OS) {
45
+ void ClangTidyProfiling::printAsJSON (llvm::raw_ostream &OS,
46
+ llvm::TimerGroup &TG) {
45
47
OS << " {\n " ;
46
48
OS << R"( "file": ")" << Storage->SourceFilename << " \" ,\n " ;
47
49
OS << R"( "timestamp": ")" << Storage->Timestamp << " \" ,\n " ;
48
50
OS << " \" profile\" : {\n " ;
49
- TG-> printJSONValues (OS, " " );
51
+ TG. printJSONValues (OS, " " );
50
52
OS << " \n }\n " ;
51
53
OS << " }\n " ;
52
54
OS.flush ();
53
55
}
54
56
55
- void ClangTidyProfiling::storeProfileData () {
57
+ void ClangTidyProfiling::storeProfileData (llvm::TimerGroup &TG ) {
56
58
assert (Storage && " We should have a filename." );
57
59
58
60
llvm::SmallString<256 > OutputDirectory (Storage->StoreFilename );
@@ -71,19 +73,18 @@ void ClangTidyProfiling::storeProfileData() {
71
73
return ;
72
74
}
73
75
74
- printAsJSON (OS);
76
+ printAsJSON (OS, TG );
75
77
}
76
78
77
79
ClangTidyProfiling::ClangTidyProfiling (std::optional<StorageParams> Storage)
78
80
: Storage(std::move(Storage)) {}
79
81
80
82
ClangTidyProfiling::~ClangTidyProfiling () {
81
- TG.emplace (" clang-tidy" , " clang-tidy checks profiling" , Records);
82
-
83
+ llvm::TimerGroup TG{" clang-tidy" , " clang-tidy checks profiling" , Records};
83
84
if (!Storage)
84
- printUserFriendlyTable (llvm::errs ());
85
+ printUserFriendlyTable (llvm::errs (), TG );
85
86
else
86
- storeProfileData ();
87
+ storeProfileData (TG );
87
88
}
88
89
89
90
} // namespace clang::tidy
0 commit comments