================
@@ -44,14 +45,25 @@ void 
ClangTidyProfiling::printUserFriendlyTable(llvm::raw_ostream &OS,
 
 void ClangTidyProfiling::printAsJSON(llvm::raw_ostream &OS,
                                      llvm::TimerGroup &TG) {
-  assert(Storage && "We should have a filename.");
-  OS << "{\n";
-  OS << R"("file": ")" << Storage->SourceFilename << "\",\n";
-  OS << R"("timestamp": ")" << Storage->Timestamp << "\",\n";
-  OS << "\"profile\": {\n";
-  TG.printJSONValues(OS, "");
-  OS << "\n}\n";
-  OS << "}\n";
+  if (!Storage)
+    return;
----------------
zeyi2 wrote:

Good question:

With assert:
```
View the output from clang-tidy here.
clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp:50:12: warning: unchecked 
access to optional value [bugprone-unchecked-optional-access]
   50 |   TmpOS << Storage->Timestamp;
      |            ^~~~~~~
```

So I guess we will have to switch to this to make clang-tidy happy.

https://github.com/llvm/llvm-project/pull/187454
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to