[PATCH] D115716: [Analyzer][BugReporter] Replace the example bug report with the one used to generate PathDiagnostic

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 4 01:54:50 PST 2022


Szelethus added inline comments.


================
Comment at: clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:76
+                     std::unique_ptr<PathDiagnostic>> {
+  const BugReport *Report = nullptr;
+};
----------------
Some comments about this field would be welcome!


================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:3076-3077
 
   ArrayRef<PathDiagnosticConsumer*> Consumers = getPathDiagnosticConsumers();
+  return generateDiagnosticForConsumerMap(EQ, Consumers);
+}
----------------
Considering that the consumers are already a part of the `BugReport`, the overload on `generateDiagnosticForConsumerMap` feels too arbitrary. Wouldn't a predicate function instead of an overload be more fitting?


================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:3210
+    BugReportEquivClass &EQ, ArrayRef<PathDiagnosticConsumer *> consumers) {
+  SmallVector<BugReport *> _;
+  auto *report = BugReporter::findReportInEquivalenceClass(EQ, _);
----------------
Ohh, a variable with its pants down!


================
Comment at: clang/lib/StaticAnalyzer/Core/BugReporter.cpp:3286-3290
 std::unique_ptr<DiagnosticForConsumerMapTy>
 PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
-    BugReport *exampleReport, ArrayRef<PathDiagnosticConsumer *> consumers,
-    ArrayRef<BugReport *> bugReports) {
+    BugReportEquivClass &EQ, ArrayRef<PathDiagnosticConsumer *> consumers) {
+  SmallVector<BugReport *, 10> bugReports;
+  const BugReport *report = findReportInEquivalenceClass(EQ, bugReports);
----------------
Really happy to see `exampleReport` gone as a parameter.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115716/new/

https://reviews.llvm.org/D115716



More information about the cfe-commits mailing list