Skip to content

[analyzer] Clean up slightly the messed up ownership model of the analyzer #128368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

steakhal
Copy link
Contributor

Well, yes. It's not pretty.
At least after this we would have a bit more unique pointers than before.

This is for fixing the memory leak diagnosed by:
https://lab.llvm.org/buildbot/#/builders/24/builds/5580

And that caused the revert of #127409.

After these uptrs that patch can re-land finally.

…lyzer

Well, yes. It's not pretty.
At least after this we would have a bit more unique pointers than before.

This is for fixing the memory leak diagnosed by:
https://lab.llvm.org/buildbot/#/builders/24/builds/5580

And that caused the revert of llvm#127409.

After these uptrs that patch can re-land finally.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:analysis labels Feb 22, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 22, 2025

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balazs Benics (steakhal)

Changes

Well, yes. It's not pretty.
At least after this we would have a bit more unique pointers than before.

This is for fixing the memory leak diagnosed by:
https://lab.llvm.org/buildbot/#/builders/24/builds/5580

And that caused the revert of #127409.

After these uptrs that patch can re-land finally.


Patch is 22.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/128368.diff

15 Files Affected:

  • (modified) clang/include/clang/Analysis/AnalysisDeclContext.h (+1-1)
  • (modified) clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (+14-10)
  • (modified) clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h (+2-1)
  • (modified) clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h (+4-3)
  • (modified) clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h (+2-1)
  • (modified) clang/lib/Analysis/AnalysisDeclContext.cpp (+2-2)
  • (modified) clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp (+8-15)
  • (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (+11-11)
  • (modified) clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (+4-2)
  • (modified) clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp (+6-6)
  • (modified) clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp (+3-2)
  • (modified) clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (+11-10)
  • (modified) clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp (+4-2)
  • (modified) clang/unittests/StaticAnalyzer/CheckerRegistration.h (+2-2)
  • (modified) clang/unittests/StaticAnalyzer/Reusables.h (+3-4)
diff --git a/clang/include/clang/Analysis/AnalysisDeclContext.h b/clang/include/clang/Analysis/AnalysisDeclContext.h
index a517a4e757c9f..ced4bb8595bea 100644
--- a/clang/include/clang/Analysis/AnalysisDeclContext.h
+++ b/clang/include/clang/Analysis/AnalysisDeclContext.h
@@ -451,7 +451,7 @@ class AnalysisDeclContextManager {
       bool synthesizeBodies = false, bool addStaticInitBranches = false,
       bool addCXXNewAllocator = true, bool addRichCXXConstructors = true,
       bool markElidedCXXConstructors = true, bool addVirtualBaseBranches = true,
-      CodeInjector *injector = nullptr);
+      std::unique_ptr<CodeInjector> injector = nullptr);
 
   AnalysisDeclContext *getContext(const Decl *D);
 
diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 7563d8bbd1d27..8e1d25b3eefa1 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -570,7 +570,8 @@ class BugReporterData {
 public:
   virtual ~BugReporterData() = default;
 
-  virtual ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() = 0;
+  virtual ArrayRef<std::unique_ptr<PathDiagnosticConsumer>>
+  getPathDiagnosticConsumers() = 0;
   virtual ASTContext &getASTContext() = 0;
   virtual SourceManager &getSourceManager() = 0;
   virtual AnalyzerOptions &getAnalyzerOptions() = 0;
@@ -608,7 +609,8 @@ class BugReporter {
   /// Generate and flush diagnostics for all bug reports.
   void FlushReports();
 
-  ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() {
+  ArrayRef<std::unique_ptr<PathDiagnosticConsumer>>
+  getPathDiagnosticConsumers() {
     return D.getPathDiagnosticConsumers();
   }
 
@@ -670,9 +672,10 @@ class BugReporter {
 protected:
   /// Generate the diagnostics for the given bug report.
   virtual std::unique_ptr<DiagnosticForConsumerMapTy>
-  generateDiagnosticForConsumerMap(BugReport *exampleReport,
-                                   ArrayRef<PathDiagnosticConsumer *> consumers,
-                                   ArrayRef<BugReport *> bugReports);
+  generateDiagnosticForConsumerMap(
+      BugReport *exampleReport,
+      ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
+      ArrayRef<BugReport *> bugReports);
 };
 
 /// GRBugReporter is used for generating path-sensitive reports.
@@ -684,10 +687,11 @@ class PathSensitiveBugReporter final : public BugReporter {
       SmallVectorImpl<BugReport *> &bugReports) override;
 
   /// Generate the diagnostics for the given bug report.
-  std::unique_ptr<DiagnosticForConsumerMapTy>
-  generateDiagnosticForConsumerMap(BugReport *exampleReport,
-                                   ArrayRef<PathDiagnosticConsumer *> consumers,
-                                   ArrayRef<BugReport *> bugReports) override;
+  std::unique_ptr<DiagnosticForConsumerMapTy> generateDiagnosticForConsumerMap(
+      BugReport *exampleReport,
+      ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
+      ArrayRef<BugReport *> bugReports) override;
+
 public:
   PathSensitiveBugReporter(BugReporterData& d, ExprEngine& eng)
       : BugReporter(d), Eng(eng) {}
@@ -706,7 +710,7 @@ class PathSensitiveBugReporter final : public BugReporter {
   /// Iterates through the bug reports within a single equivalence class,
   /// stops at a first non-invalidated report.
   std::unique_ptr<DiagnosticForConsumerMapTy> generatePathDiagnostics(
-      ArrayRef<PathDiagnosticConsumer *> consumers,
+      ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
       ArrayRef<PathSensitiveBugReport *> &bugReports);
 
   void emitReport(std::unique_ptr<BugReport> R) override;
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h b/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
index 88a9d76f24887..9fafd6acaa2ac 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
@@ -30,7 +30,8 @@ class CrossTranslationUnitContext;
 namespace ento {
 
 class PathDiagnosticConsumer;
-typedef std::vector<PathDiagnosticConsumer*> PathDiagnosticConsumers;
+using PathDiagnosticConsumers =
+    std::vector<std::unique_ptr<PathDiagnosticConsumer>>;
 
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)                    \
   void CREATEFN(PathDiagnosticConsumerOptions Diagopts,                        \
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
index c76e9c0326afe..e3cf1bac83ad0 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -47,11 +47,11 @@ class AnalysisManager : public BugReporterData {
   AnalyzerOptions &options;
 
   AnalysisManager(ASTContext &ctx, Preprocessor &PP,
-                  const PathDiagnosticConsumers &Consumers,
+                  PathDiagnosticConsumers Consumers,
                   StoreManagerCreator storemgr,
                   ConstraintManagerCreator constraintmgr,
                   CheckerManager *checkerMgr, AnalyzerOptions &Options,
-                  CodeInjector *injector = nullptr);
+                  std::unique_ptr<CodeInjector> injector = nullptr);
 
   ~AnalysisManager() override;
 
@@ -91,7 +91,8 @@ class AnalysisManager : public BugReporterData {
     return LangOpts;
   }
 
-  ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() override {
+  ArrayRef<std::unique_ptr<PathDiagnosticConsumer>>
+  getPathDiagnosticConsumers() override {
     return PathConsumers;
   }
 
diff --git a/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h b/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
index f3b1c1f206459..2163d66466c1c 100644
--- a/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
+++ b/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
@@ -29,7 +29,8 @@ class CheckerRegistry;
 
 class AnalysisASTConsumer : public ASTConsumer {
 public:
-  virtual void AddDiagnosticConsumer(PathDiagnosticConsumer *Consumer) = 0;
+  virtual void
+  AddDiagnosticConsumer(std::unique_ptr<PathDiagnosticConsumer> Consumer) = 0;
 
   /// This method allows registering statically linked custom checkers that are
   /// not a part of the Clang tree. It employs the same mechanism that is used
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp
index d3a1a993711fb..d0b663bd94580 100644
--- a/clang/lib/Analysis/AnalysisDeclContext.cpp
+++ b/clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -71,8 +71,8 @@ AnalysisDeclContextManager::AnalysisDeclContextManager(
     bool addLoopExit, bool addScopes, bool synthesizeBodies,
     bool addStaticInitBranch, bool addCXXNewAllocator,
     bool addRichCXXConstructors, bool markElidedCXXConstructors,
-    bool addVirtualBaseBranches, CodeInjector *injector)
-    : Injector(injector), FunctionBodyFarm(ASTCtx, injector),
+    bool addVirtualBaseBranches, std::unique_ptr<CodeInjector> injector)
+    : Injector(std::move(injector)), FunctionBodyFarm(ASTCtx, Injector.get()),
       SynthesizeBodies(synthesizeBodies) {
   cfgBuildOptions.PruneTriviallyFalseEdges = !useUnoptimizedCFG;
   cfgBuildOptions.AddImplicitDtors = addImplicitDtors;
diff --git a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
index f9750db7b5017..8a16716f951b8 100644
--- a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -14,32 +14,28 @@ using namespace ento;
 void AnalysisManager::anchor() { }
 
 AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP,
-                                 const PathDiagnosticConsumers &PDC,
+                                 PathDiagnosticConsumers PDC,
                                  StoreManagerCreator storemgr,
                                  ConstraintManagerCreator constraintmgr,
                                  CheckerManager *checkerMgr,
                                  AnalyzerOptions &Options,
-                                 CodeInjector *injector)
+                                 std::unique_ptr<CodeInjector> injector)
     : AnaCtxMgr(
           ASTCtx, Options.UnoptimizedCFG,
           Options.ShouldIncludeImplicitDtorsInCFG,
-          /*addInitializers=*/true,
-          Options.ShouldIncludeTemporaryDtorsInCFG,
+          /*addInitializers=*/true, Options.ShouldIncludeTemporaryDtorsInCFG,
           Options.ShouldIncludeLifetimeInCFG,
           // Adding LoopExit elements to the CFG is a requirement for loop
           // unrolling.
-          Options.ShouldIncludeLoopExitInCFG ||
-            Options.ShouldUnrollLoops,
-          Options.ShouldIncludeScopesInCFG,
-          Options.ShouldSynthesizeBodies,
+          Options.ShouldIncludeLoopExitInCFG || Options.ShouldUnrollLoops,
+          Options.ShouldIncludeScopesInCFG, Options.ShouldSynthesizeBodies,
           Options.ShouldConditionalizeStaticInitializers,
           /*addCXXNewAllocator=*/true,
           Options.ShouldIncludeRichConstructorsInCFG,
           Options.ShouldElideConstructors,
-          /*addVirtualBaseBranches=*/true,
-          injector),
+          /*addVirtualBaseBranches=*/true, std::move(injector)),
       Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()),
-      PathConsumers(PDC), CreateStoreMgr(storemgr),
+      PathConsumers(std::move(PDC)), CreateStoreMgr(storemgr),
       CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
       options(Options) {
   AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
@@ -50,14 +46,11 @@ AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP,
 
 AnalysisManager::~AnalysisManager() {
   FlushDiagnostics();
-  for (PathDiagnosticConsumer *Consumer : PathConsumers) {
-    delete Consumer;
-  }
 }
 
 void AnalysisManager::FlushDiagnostics() {
   PathDiagnosticConsumer::FilesMade filesMade;
-  for (PathDiagnosticConsumer *Consumer : PathConsumers) {
+  for (const auto &Consumer : PathConsumers) {
     Consumer->FlushDiagnostics(&filesMade);
   }
 }
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 13677ed341d0c..7101b1eb2c7f5 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2958,7 +2958,7 @@ std::optional<PathDiagnosticBuilder> PathDiagnosticBuilder::findValidReport(
 
 std::unique_ptr<DiagnosticForConsumerMapTy>
 PathSensitiveBugReporter::generatePathDiagnostics(
-    ArrayRef<PathDiagnosticConsumer *> consumers,
+    ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
     ArrayRef<PathSensitiveBugReport *> &bugReports) {
   assert(!bugReports.empty());
 
@@ -2968,9 +2968,9 @@ PathSensitiveBugReporter::generatePathDiagnostics(
       PathDiagnosticBuilder::findValidReport(bugReports, *this);
 
   if (PDB) {
-    for (PathDiagnosticConsumer *PC : consumers) {
-      if (std::unique_ptr<PathDiagnostic> PD = PDB->generate(PC)) {
-        (*Out)[PC] = std::move(PD);
+    for (const auto &PC : consumers) {
+      if (std::unique_ptr<PathDiagnostic> PD = PDB->generate(PC.get())) {
+        (*Out)[PC.get()] = std::move(PD);
       }
     }
   }
@@ -3164,7 +3164,7 @@ void BugReporter::FlushReport(BugReportEquivClass &EQ) {
       return;
   }
 
-  ArrayRef<PathDiagnosticConsumer*> Consumers = getPathDiagnosticConsumers();
+  ArrayRef Consumers = getPathDiagnosticConsumers();
   std::unique_ptr<DiagnosticForConsumerMapTy> Diagnostics =
       generateDiagnosticForConsumerMap(report, Consumers, bugReports);
 
@@ -3298,12 +3298,13 @@ findExecutedLines(const SourceManager &SM, const ExplodedNode *N) {
 
 std::unique_ptr<DiagnosticForConsumerMapTy>
 BugReporter::generateDiagnosticForConsumerMap(
-    BugReport *exampleReport, ArrayRef<PathDiagnosticConsumer *> consumers,
+    BugReport *exampleReport,
+    ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
     ArrayRef<BugReport *> bugReports) {
   auto *basicReport = cast<BasicBugReport>(exampleReport);
   auto Out = std::make_unique<DiagnosticForConsumerMapTy>();
-  for (auto *Consumer : consumers)
-    (*Out)[Consumer] =
+  for (const auto &Consumer : consumers)
+    (*Out)[Consumer.get()] =
         generateDiagnosticForBasicReport(basicReport, AnalysisEntryPoint);
   return Out;
 }
@@ -3371,11 +3372,10 @@ static void resetDiagnosticLocationToMainFile(PathDiagnostic &PD) {
   }
 }
 
-
-
 std::unique_ptr<DiagnosticForConsumerMapTy>
 PathSensitiveBugReporter::generateDiagnosticForConsumerMap(
-    BugReport *exampleReport, ArrayRef<PathDiagnosticConsumer *> consumers,
+    BugReport *exampleReport,
+    ArrayRef<std::unique_ptr<PathDiagnosticConsumer>> consumers,
     ArrayRef<BugReport *> bugReports) {
   std::vector<BasicBugReport *> BasicBugReports;
   std::vector<PathSensitiveBugReport *> PathSensitiveBugReports;
diff --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index 5c0df8808c272..21d99a359ca80 100644
--- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -193,7 +193,8 @@ void ento::createHTMLDiagnosticConsumer(
   if (OutputDir.empty())
     return;
 
-  C.push_back(new HTMLDiagnostics(std::move(DiagOpts), OutputDir, PP, true));
+  C.emplace_back(std::make_unique<HTMLDiagnostics>(std::move(DiagOpts),
+                                                   OutputDir, PP, true));
 }
 
 void ento::createHTMLSingleFileDiagnosticConsumer(
@@ -208,7 +209,8 @@ void ento::createHTMLSingleFileDiagnosticConsumer(
   if (OutputDir.empty())
     return;
 
-  C.push_back(new HTMLDiagnostics(std::move(DiagOpts), OutputDir, PP, false));
+  C.emplace_back(std::make_unique<HTMLDiagnostics>(std::move(DiagOpts),
+                                                   OutputDir, PP, false));
 }
 
 void ento::createPlistHTMLDiagnosticConsumer(
diff --git a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
index d806d970acf8d..2ab248f9aa6d9 100644
--- a/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -541,9 +541,9 @@ void ento::createPlistDiagnosticConsumer(
   if (OutputFile.empty())
     return;
 
-  C.push_back(new PlistDiagnostics(DiagOpts, OutputFile, PP, CTU,
-                                   MacroExpansions,
-                                   /*supportsMultipleFiles=*/false));
+  C.push_back(std::make_unique<PlistDiagnostics>(
+      DiagOpts, OutputFile, PP, CTU, MacroExpansions,
+      /*supportsMultipleFiles=*/false));
   createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, OutputFile,
                                           PP, CTU, MacroExpansions);
 }
@@ -558,9 +558,9 @@ void ento::createPlistMultiFileDiagnosticConsumer(
   if (OutputFile.empty())
     return;
 
-  C.push_back(new PlistDiagnostics(DiagOpts, OutputFile, PP, CTU,
-                                   MacroExpansions,
-                                   /*supportsMultipleFiles=*/true));
+  C.push_back(std::make_unique<PlistDiagnostics>(
+      DiagOpts, OutputFile, PP, CTU, MacroExpansions,
+      /*supportsMultipleFiles=*/true));
   createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, OutputFile,
                                           PP, CTU, MacroExpansions);
 }
diff --git a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
index fab520098f13e..cae6e872a7df5 100644
--- a/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -23,6 +23,7 @@
 #include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Path.h"
+#include <memory>
 
 using namespace llvm;
 using namespace clang;
@@ -60,8 +61,8 @@ void ento::createSarifDiagnosticConsumer(
   if (Output.empty())
     return;
 
-  C.push_back(
-      new SarifDiagnostics(Output, PP.getLangOpts(), PP.getSourceManager()));
+  C.push_back(std::make_unique<SarifDiagnostics>(Output, PP.getLangOpts(),
+                                                 PP.getSourceManager()));
   createTextMinimalPathDiagnosticConsumer(std::move(DiagOpts), C, Output, PP,
                                           CTU, MacroExpansions);
 }
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index 189d7d6bede8e..8a4bb35925e2c 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -90,7 +90,7 @@ class AnalysisConsumer : public AnalysisASTConsumer,
   const std::string OutDir;
   AnalyzerOptions &Opts;
   ArrayRef<std::string> Plugins;
-  CodeInjector *Injector;
+  std::unique_ptr<CodeInjector> Injector;
   cross_tu::CrossTranslationUnitContext CTU;
 
   /// Stores the declarations from the local translation unit.
@@ -123,10 +123,10 @@ class AnalysisConsumer : public AnalysisASTConsumer,
 
   AnalysisConsumer(CompilerInstance &CI, const std::string &outdir,
                    AnalyzerOptions &opts, ArrayRef<std::string> plugins,
-                   CodeInjector *injector)
+                   std::unique_ptr<CodeInjector> injector)
       : RecVisitorMode(0), RecVisitorBR(nullptr), Ctx(nullptr),
-        PP(CI.getPreprocessor()), OutDir(outdir), Opts(opts),
-        Plugins(plugins), Injector(injector), CTU(CI),
+        PP(CI.getPreprocessor()), OutDir(outdir), Opts(opts), Plugins(plugins),
+        Injector(std::move(injector)), CTU(CI),
         MacroExpansions(CI.getLangOpts()) {
     DigestAnalyzerOptions();
     if (Opts.AnalyzerDisplayProgress || Opts.PrintStats ||
@@ -229,9 +229,9 @@ class AnalysisConsumer : public AnalysisASTConsumer,
     checkerMgr = std::make_unique<CheckerManager>(*Ctx, Opts, PP, Plugins,
                                                   CheckerRegistrationFns);
 
-    Mgr = std::make_unique<AnalysisManager>(*Ctx, PP, PathConsumers,
-                                            CreateStoreMgr, CreateConstraintMgr,
-                                            checkerMgr.get(), Opts, Injector);
+    Mgr = std::make_unique<AnalysisManager>(
+        *Ctx, PP, std::move(PathConsumers), CreateStoreMgr, CreateConstraintMgr,
+        checkerMgr.get(), Opts, std::move(Injector));
   }
 
   /// Store the top level decls in the set to be processed later on.
@@ -342,8 +342,9 @@ class AnalysisConsumer : public AnalysisASTConsumer,
     return true;
   }
 
-  void AddDiagnosticConsumer(PathDiagnosticConsumer *Consumer) override {
-    PathConsumers.push_back(Consumer);
+  void AddDiagnosticConsumer(
+      std::unique_ptr<PathDiagnosticConsumer> Consumer) override {
+    PathConsumers.push_back(std::move(Consumer));
   }
 
   void AddCheckerRegistrationFn(std::function<void(CheckerRegistry&)> Fn) override {
@@ -794,5 +795,5 @@ ento::CreateAnalysisConsumer(CompilerInstance &CI) {
   return std::make_unique<AnalysisConsumer>(
       CI, CI.getFrontendOpts().OutputFile, analyzerOpts,
       CI.getFrontendOpts().Plugins,
-      hasModelPath ? new ModelInjector(CI) : nullptr);
+      hasModelPath ? std::make_unique<ModelInjector>(CI) : nullptr);
 }
diff --git a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
index 70a58026da95f..0ef63b049621e 100644
--- a/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
+++ b/clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
+#include <memory>
 
 using namespace clang;
 using namespace ento;
@@ -114,8 +115,9 @@ class TestAction : public ASTFrontendAction {
                                                  StringRef File) override {
     std::unique_ptr<AnalysisASTConsumer> AnalysisConsumer =
         CreateAnalysisConsumer(Compiler);
-    AnalysisConsumer->AddDiagnosticConsumer(new VerifyPathDiagnosticConsumer(
-        std::move(ExpectedDiags), Compiler.getSourceManager...
[truncated]

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff db836edf47f36ed04cab919a7a2c4414f4d0d7e6 6fd30233a570ace5ccf3f04f649ddd37bd4149b2 --extensions h,cpp -- clang/include/clang/Analysis/AnalysisDeclContext.h clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h clang/lib/Analysis/AnalysisDeclContext.cpp clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp clang/lib/StaticAnalyzer/Core/BugReporter.cpp clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp clang/unittests/StaticAnalyzer/BugReportInterestingnessTest.cpp clang/unittests/StaticAnalyzer/CheckerRegistration.h clang/unittests/StaticAnalyzer/Reusables.h
View the diff from clang-format here.
diff --git a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
index 8a16716f95..283b796ab2 100644
--- a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -44,9 +44,7 @@ AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP,
       Options.ShouldIncludeDefaultInitForAggregates;
 }
 
-AnalysisManager::~AnalysisManager() {
-  FlushDiagnostics();
-}
+AnalysisManager::~AnalysisManager() { FlushDiagnostics(); }
 
 void AnalysisManager::FlushDiagnostics() {
   PathDiagnosticConsumer::FilesMade filesMade;

@steakhal steakhal merged commit 3dc1594 into llvm:main Feb 24, 2025
11 of 15 checks passed
@steakhal steakhal deleted the bb/clean-up-analyzer-ownership-model branch February 24, 2025 10:34
steakhal added a commit to steakhal/llvm-project that referenced this pull request Feb 24, 2025
There was one place I forgot to update, clang-tidy.
I only ran the CSA tests in llvm#128368.

Fixes:
https://lab.llvm.org/buildbot/#/builders/52/builds/6286/steps/9/logs/stdio
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 24, 2025

LLVM Buildbot has detected a new failure on builder llvm-clang-x86_64-sie-ubuntu-fast running on sie-linux-worker while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/18717

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
25.435 [413/40/53] Building CXX object tools/clang/tools/extra/clang-apply-replacements/tool/CMakeFiles/clang-apply-replacements.dir/ClangApplyReplacementsMain.cpp.o
25.483 [412/40/54] Building CXX object lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
25.634 [411/40/55] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/ExpandResponseFilesCompilationDatabase.cpp.o
25.681 [410/40/56] Linking CXX static library lib/libLLVMAsmPrinter.a
25.885 [409/40/57] Building CXX object tools/clang/lib/FrontendTool/CMakeFiles/obj.clangFrontendTool.dir/ExecuteCompilerInvocation.cpp.o
25.963 [408/40/58] Building CXX object tools/clang/tools/extra/modularize/CMakeFiles/modularize.dir/ModularizeUtilities.cpp.o
26.221 [407/40/59] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/AnalysisBasedWarnings.cpp.o
26.738 [406/40/60] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Execution.cpp.o
26.861 [405/40/61] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CommonOptionsParser.cpp.o
27.787 [404/40/62] Building CXX object tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o
FAILED: tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/g++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/tools/extra/clang-tidy -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/tools/clang/include -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/include -I/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o -MF tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o.d -o tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o -c /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp: In member function ‘std::unique_ptr<clang::ASTConsumer> clang::tidy::ClangTidyASTConsumerFactory::createASTConsumer(clang::CompilerInstance&, llvm::StringRef)’:
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:465:9: error: cannot convert ‘clang::tidy::{anonymous}::AnalyzerDiagnosticConsumer*’ to ‘std::unique_ptr<clang::ento::PathDiagnosticConsumer>’
  465 |         new AnalyzerDiagnosticConsumer(Context));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         |
      |         clang::tidy::{anonymous}::AnalyzerDiagnosticConsumer*
In file included from /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:48:
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h:33:65: note:   initializing argument 1 of ‘virtual void clang::ento::AnalysisASTConsumer::AddDiagnosticConsumer(std::unique_ptr<clang::ento::PathDiagnosticConsumer>)’
   33 |   AddDiagnosticConsumer(std::unique_ptr<PathDiagnosticConsumer> Consumer) = 0;
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
28.340 [404/39/63] Linking CXX static library lib/libclangSema.a
28.372 [404/38/64] Linking CXX shared library lib/libLTO.so.21.0git
28.373 [404/37/65] Linking CXX executable bin/llvm-exegesis
28.611 [404/36/66] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CompilerInstance.cpp.o
28.974 [404/35/67] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/GuessTargetAndModeCompilationDatabase.cpp.o
29.099 [404/34/68] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CompilationDatabase.cpp.o
29.176 [404/33/69] Linking CXX executable bin/llvm-lto
29.227 [404/32/70] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/AllTUsExecution.cpp.o
29.230 [404/31/71] Linking CXX executable bin/lld
30.008 [404/30/72] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/JSONCompilationDatabase.cpp.o
30.053 [404/29/73] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/Interpreter.cpp.o
30.221 [404/28/74] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/LocateToolCompilationDatabase.cpp.o
31.014 [404/27/75] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Refactoring.cpp.o
31.904 [404/26/76] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/StandaloneExecution.cpp.o
31.944 [404/25/77] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/InterfaceStubFunctionsConsumer.cpp.o
32.253 [404/24/78] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenAction.cpp.o
32.588 [404/23/79] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/BasicValueFactory.cpp.o
32.659 [404/22/80] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/AnalyzerOptions.cpp.o
32.779 [404/21/81] Building CXX object tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/AtomicChange.cpp.o
33.673 [404/20/82] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/Checker.cpp.o
33.770 [404/19/83] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Tooling.cpp.o
33.972 [404/18/84] Building CXX object tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/RefactoringActions.cpp.o
34.105 [404/17/85] Building CXX object tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/Rename/RenamingAction.cpp.o
34.450 [404/16/86] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/AnalysisManager.cpp.o
35.103 [404/15/87] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/BackendUtil.cpp.o
35.175 [404/14/88] Building CXX object tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/ObjectFilePCHContainerWriter.cpp.o
35.992 [404/13/89] Building CXX object tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CallDescription.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 24, 2025

LLVM Buildbot has detected a new failure on builder llvm-x86_64-debian-dylib running on gribozavr4 while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/60/builds/20287

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
83.831 [1077/96/5994] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ExpectedTypes.cpp.o
83.832 [1076/96/5995] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/DumpAST.cpp.o
83.837 [1075/96/5996] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Feature.cpp.o
83.848 [1074/96/5997] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FileDistance.cpp.o
83.861 [1073/96/5998] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Format.cpp.o
83.872 [1072/96/5999] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FS.cpp.o
83.882 [1071/96/6000] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FuzzyMatch.cpp.o
83.959 [1070/96/6001] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
84.474 [1069/96/6002] Building CXX object tools/clang/tools/extra/include-cleaner/lib/CMakeFiles/obj.clangIncludeCleaner.dir/Record.cpp.o
84.540 [1068/96/6003] Building CXX object tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o
FAILED: tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/llvm-x86_64-debian-dylib/build/tools/clang/tools/extra/clang-tidy -I/b/1/llvm-x86_64-debian-dylib/llvm-project/clang-tools-extra/clang-tidy -I/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/include -I/b/1/llvm-x86_64-debian-dylib/build/tools/clang/include -I/b/1/llvm-x86_64-debian-dylib/build/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o -MF tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o.d -o tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o -c /b/1/llvm-x86_64-debian-dylib/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang-tools-extra/clang-tidy/ClangTidy.cpp:465:9: error: no viable conversion from 'clang::tidy::(anonymous namespace)::AnalyzerDiagnosticConsumer *' to 'std::unique_ptr<PathDiagnosticConsumer>'
        new AnalyzerDiagnosticConsumer(Context));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:320:12: note: candidate constructor template not viable: no known conversion from 'clang::tidy::(anonymous namespace)::AnalyzerDiagnosticConsumer *' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
        constexpr unique_ptr(nullptr_t) noexcept
                  ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:327:7: note: candidate constructor not viable: no known conversion from 'clang::tidy::(anonymous namespace)::AnalyzerDiagnosticConsumer *' to 'std::unique_ptr<clang::ento::PathDiagnosticConsumer, std::default_delete<clang::ento::PathDiagnosticConsumer>> &&' for 1st argument
      unique_ptr(unique_ptr&&) = default;
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:468:7: note: candidate constructor not viable: no known conversion from 'clang::tidy::(anonymous namespace)::AnalyzerDiagnosticConsumer *' to 'const std::unique_ptr<clang::ento::PathDiagnosticConsumer, std::default_delete<clang::ento::PathDiagnosticConsumer>> &' for 1st argument
      unique_ptr(const unique_ptr&) = delete;
      ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:340:2: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-0, type-parameter-0-1>' against 'clang::tidy::(anonymous namespace)::AnalyzerDiagnosticConsumer *'
        unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:350:2: note: candidate template ignored: could not match 'auto_ptr<type-parameter-0-0>' against 'clang::tidy::(anonymous namespace)::AnalyzerDiagnosticConsumer *'
        unique_ptr(auto_ptr<_Up>&& __u) noexcept;
        ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:281:2: note: explicit constructor is not a candidate
        unique_ptr(pointer __p) noexcept
        ^
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h:33:65: note: passing argument to parameter 'Consumer' here
  AddDiagnosticConsumer(std::unique_ptr<PathDiagnosticConsumer> Consumer) = 0;
                                                                ^
1 error generated.
84.941 [1068/95/6004] Building CXX object tools/clang/tools/extra/include-cleaner/tool/CMakeFiles/clang-include-cleaner.dir/IncludeCleaner.cpp.o
85.100 [1068/94/6005] Building CXX object tools/clang/tools/extra/clang-apply-replacements/CMakeFiles/obj.clangApplyReplacements.dir/lib/Tooling/ApplyReplacements.cpp.o
85.284 [1068/93/6006] Building CXX object tools/clang/tools/extra/clang-doc/CMakeFiles/obj.clangDoc.dir/ClangDoc.cpp.o
85.524 [1068/92/6007] Building CXX object tools/clang/tools/extra/clang-include-fixer/tool/CMakeFiles/clang-include-fixer.dir/ClangIncludeFixer.cpp.o
85.636 [1068/91/6008] Building CXX object tools/clang/tools/extra/clang-doc/CMakeFiles/obj.clangDoc.dir/Representation.cpp.o
85.677 [1068/90/6009] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
85.821 [1068/89/6010] Building CXX object tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/ProBoundsConstantArrayIndexCheck.cpp.o
86.058 [1068/88/6011] Linking CXX shared library lib/libclang-cpp.so.21.0git
86.200 [1068/87/6012] Building CXX object tools/clang/tools/extra/modularize/CMakeFiles/modularize.dir/CoverageChecker.cpp.o
86.234 [1068/86/6013] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
86.236 [1068/85/6014] Building CXX object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/core_main.cpp.o
86.349 [1068/84/6015] Building CXX object tools/clang/tools/extra/clang-doc/CMakeFiles/obj.clangDoc.dir/HTMLGenerator.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 24, 2025

LLVM Buildbot has detected a new failure on builder clang-x86_64-debian-fast running on gribozavr4 while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/19276

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
             TemplateArgs
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Sema/Sema.h:13337:14: warning: parameter 'IsIncompleteSubstitution' not found in the function declaration [-Wdocumentation]
  /// \param IsIncompleteSubstitution If provided, the pointee will be set
             ^~~~~~~~~~~~~~~~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Sema/Sema.h:13337:14: note: did you mean 'TemplateArgs'?
  /// \param IsIncompleteSubstitution If provided, the pointee will be set
             ^~~~~~~~~~~~~~~~~~~~~~~~
             TemplateArgs
38 warnings generated.
74.984 [837/96/5221] Building CXX object tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o
FAILED: tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/clang-tidy -I/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy -I/b/1/clang-x86_64-debian-fast/llvm.src/clang/include -I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/include -I/b/1/clang-x86_64-debian-fast/llvm.obj/include -I/b/1/clang-x86_64-debian-fast/llvm.src/llvm/include -std=c++11 -Wdocumentation -Wno-documentation-deprecated-sync -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o -MF tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o.d -o tools/clang/tools/extra/clang-tidy/CMakeFiles/obj.clangTidy.dir/ClangTidy.cpp.o -c /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy/ClangTidy.cpp
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy/ClangTidy.cpp:18:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy/ClangTidyCheck.h:14:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/ASTMatchers/ASTMatchFinder.h:43:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/ASTMatchers/ASTMatchers.h:47:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ASTContext.h:21:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/Decl.h:17:
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/APValue.h:391:14: warning: parameter 'UninitArray' not found in the function declaration [-Wdocumentation]
  /// \param UninitArray Marker. Pass an empty UninitArray.
             ^~~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/APValue.h:400:14: warning: parameter 'UninitStruct' not found in the function declaration [-Wdocumentation]
  /// \param UninitStruct Marker. Pass an empty UninitStruct.
             ^~~~~~~~~~~~
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy/ClangTidy.cpp:18:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy/ClangTidyCheck.h:14:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/ASTMatchers/ASTMatchFinder.h:43:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/ASTMatchers/ASTMatchers.h:47:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ASTContext.h:21:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/Decl.h:22:
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:165:39: warning: empty paragraph passed to '\param' command [-Wdocumentation]
  /// specializations for the \param D.
                              ~~~~~~~~^
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:165:38: warning: parameter 'D.' not found in the function declaration [-Wdocumentation]
  /// specializations for the \param D.
                                     ^~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:171:44: warning: empty paragraph passed to '\param' command [-Wdocumentation]
  /// args specified by \param TemplateArgs.
                        ~~~~~~~~~~~~~~~~~~~^
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:171:32: warning: parameter 'TemplateArgs.' not found in the function declaration [-Wdocumentation]
  /// args specified by \param TemplateArgs.
                               ^~~~~~~~~~~~~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/ExternalASTSource.h:171:32: note: did you mean 'TemplateArgs'?
  /// args specified by \param TemplateArgs.
                               ^~~~~~~~~~~~~
                               TemplateArgs
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy/ClangTidy.cpp:18:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-tidy/ClangTidyCheck.h:14:
In file included from /b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/ASTMatchers/ASTMatchFinder.h:43:

steakhal added a commit that referenced this pull request Mar 18, 2025
…128369)

Reapply "[analyzer] Delay the checker constructions after parsing"
(#128350)
    
This reverts commit db836ed, as-is.

Depends on #128368
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:analysis clang:static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants