Skip to content

Conversation

@jansvoboda11
Copy link
Contributor

This makes it so that CompilerInvocation can be the only entity that manages ownership of HeaderSearchOptions, making it possible to implement copy-on-write semantics.

@jansvoboda11 jansvoboda11 requested a review from Bigcheese March 24, 2025 17:03
@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra clangd clang-tidy clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Mar 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/pr-subscribers-clangd
@llvm/pr-subscribers-clang-tools-extra

@llvm/pr-subscribers-clang-tidy

Author: Jan Svoboda (jansvoboda11)

Changes

This makes it so that CompilerInvocation can be the only entity that manages ownership of HeaderSearchOptions, making it possible to implement copy-on-write semantics.


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

20 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp (+4-7)
  • (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h (+2)
  • (modified) clang-tools-extra/clangd/ModulesBuilder.cpp (+5-5)
  • (modified) clang-tools-extra/clangd/unittests/StdLibTests.cpp (+2-1)
  • (modified) clang-tools-extra/modularize/ModularizeUtilities.cpp (+2-3)
  • (modified) clang-tools-extra/modularize/ModularizeUtilities.h (+2)
  • (modified) clang/include/clang/Frontend/ASTUnit.h (+3)
  • (modified) clang/include/clang/Lex/HeaderSearch.h (+5-5)
  • (modified) clang/lib/Frontend/ASTUnit.cpp (+2-2)
  • (modified) clang/lib/Frontend/CompilerInstance.cpp (+1-1)
  • (modified) clang/lib/Lex/HeaderSearch.cpp (+20-21)
  • (modified) clang/unittests/Analysis/MacroExpansionContextTest.cpp (+2-2)
  • (modified) clang/unittests/Basic/SourceManagerTest.cpp (+10-10)
  • (modified) clang/unittests/Lex/HeaderSearchTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/LexerTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/ModuleDeclStateTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/PPCallbacksTest.cpp (+14-12)
  • (modified) clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/PPDependencyDirectivesTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/PPMemoryAllocationsTest.cpp (+2-2)
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 4c34f9ea122d9..a15850cb63542 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -73,7 +73,7 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
       // Forward the new diagnostics to the original DiagnosticConsumer.
       Diags(new DiagnosticIDs, new DiagnosticOptions,
             new ForwardingDiagnosticConsumer(Compiler.getDiagnosticClient())),
-      LangOpts(Compiler.getLangOpts()) {
+      LangOpts(Compiler.getLangOpts()), HSOpts(Compiler.getHeaderSearchOpts()) {
   // Add a FileSystem containing the extra files needed in place of modular
   // headers.
   OverlayFS->pushOverlay(InMemoryFs);
@@ -86,11 +86,8 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
 
   LangOpts.Modules = false;
 
-  auto HSO = std::make_shared<HeaderSearchOptions>();
-  *HSO = Compiler.getHeaderSearchOpts();
-
-  HeaderInfo = std::make_unique<HeaderSearch>(HSO, Sources, Diags, LangOpts,
-                                               &Compiler.getTarget());
+  HeaderInfo = std::make_unique<HeaderSearch>(HSOpts, Sources, Diags, LangOpts,
+                                              &Compiler.getTarget());
 
   auto PO = std::make_shared<PreprocessorOptions>();
   *PO = Compiler.getPreprocessorOpts();
@@ -102,7 +99,7 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
   PP->Initialize(Compiler.getTarget(), Compiler.getAuxTarget());
   InitializePreprocessor(*PP, *PO, Compiler.getPCHContainerReader(),
                          Compiler.getFrontendOpts(), Compiler.getCodeGenOpts());
-  ApplyHeaderSearchOptions(*HeaderInfo, *HSO, LangOpts,
+  ApplyHeaderSearchOptions(*HeaderInfo, HSOpts, LangOpts,
                            Compiler.getTarget().getTriple());
 }
 
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
index 0742c21bc4372..a263681b3c633 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLING_EXPANDMODULARHEADERSPPCALLBACKS_H_
 #define LLVM_CLANG_TOOLING_EXPANDMODULARHEADERSPPCALLBACKS_H_
 
+#include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/DenseSet.h"
@@ -129,6 +130,7 @@ class ExpandModularHeadersPPCallbacks : public PPCallbacks {
   SourceManager &Sources;
   DiagnosticsEngine Diags;
   LangOptions LangOpts;
+  HeaderSearchOptions HSOpts;
   TrivialModuleLoader ModuleLoader;
 
   std::unique_ptr<HeaderSearch> HeaderInfo;
diff --git a/clang-tools-extra/clangd/ModulesBuilder.cpp b/clang-tools-extra/clangd/ModulesBuilder.cpp
index 39cf57f5fe724..03c5f5e1b5993 100644
--- a/clang-tools-extra/clangd/ModulesBuilder.cpp
+++ b/clang-tools-extra/clangd/ModulesBuilder.cpp
@@ -181,10 +181,10 @@ class ReusablePrerequisiteModules : public PrerequisiteModules {
 bool IsModuleFileUpToDate(PathRef ModuleFilePath,
                           const PrerequisiteModules &RequisiteModules,
                           llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
-  auto HSOpts = std::make_shared<HeaderSearchOptions>();
-  RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
-  HSOpts->ForceCheckCXX20ModulesInputFiles = true;
-  HSOpts->ValidateASTInputFilesContent = true;
+  HeaderSearchOptions HSOpts;
+  RequisiteModules.adjustHeaderSearchOptions(HSOpts);
+  HSOpts.ForceCheckCXX20ModulesInputFiles = true;
+  HSOpts.ValidateASTInputFilesContent = true;
 
   clang::clangd::IgnoreDiagnostics IgnoreDiags;
   IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
@@ -199,7 +199,7 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,
 
   SourceManager SourceMgr(*Diags, FileMgr);
 
-  HeaderSearch HeaderInfo(std::move(HSOpts), SourceMgr, *Diags, LangOpts,
+  HeaderSearch HeaderInfo(HSOpts, SourceMgr, *Diags, LangOpts,
                           /*Target=*/nullptr);
 
   TrivialModuleLoader ModuleLoader;
diff --git a/clang-tools-extra/clangd/unittests/StdLibTests.cpp b/clang-tools-extra/clangd/unittests/StdLibTests.cpp
index a39d34ea33811..a7a33f78303d3 100644
--- a/clang-tools-extra/clangd/unittests/StdLibTests.cpp
+++ b/clang-tools-extra/clangd/unittests/StdLibTests.cpp
@@ -85,11 +85,12 @@ TEST(StdLibTests, StdLibSet) {
   FS.Files["std/_"] = "";
   FS.Files["libc/_"] = "";
 
+  HeaderSearchOptions HSOpts;
   auto Add = [&](const LangOptions &LO,
                  std::vector<llvm::StringRef> SearchPath) {
     SourceManagerForFile SM("scratch", "");
     SM.get().getFileManager().setVirtualFileSystem(FS.view(std::nullopt));
-    HeaderSearch HS(/*HSOpts=*/nullptr, SM.get(), SM.get().getDiagnostics(), LO,
+    HeaderSearch HS(HSOpts, SM.get(), SM.get().getDiagnostics(), LO,
                     /*Target=*/nullptr);
     for (auto P : SearchPath)
       HS.AddSearchPath(
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 476e13770a94f..78df40cb006e0 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -55,9 +55,8 @@ ModularizeUtilities::ModularizeUtilities(std::vector<std::string> &InputPaths,
       TargetOpts(new ModuleMapTargetOptions()),
       Target(TargetInfo::CreateTargetInfo(*Diagnostics, TargetOpts)),
       FileMgr(new FileManager(FileSystemOpts)),
-      SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)),
-      HeaderInfo(new HeaderSearch(std::make_shared<HeaderSearchOptions>(),
-                                  *SourceMgr, *Diagnostics, *LangOpts,
+      SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)), HSOpts(),
+      HeaderInfo(new HeaderSearch(HSOpts, *SourceMgr, *Diagnostics, *LangOpts,
                                   Target.get())) {}
 
 // Create instance of ModularizeUtilities, to simplify setting up
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.h b/clang-tools-extra/modularize/ModularizeUtilities.h
index 64675022dad76..7b4c16a492b89 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.h
+++ b/clang-tools-extra/modularize/ModularizeUtilities.h
@@ -213,6 +213,8 @@ class ModularizeUtilities {
   llvm::IntrusiveRefCntPtr<clang::FileManager> FileMgr;
   /// Source manager.
   llvm::IntrusiveRefCntPtr<clang::SourceManager> SourceMgr;
+  /// Header search options.
+  clang::HeaderSearchOptions HSOpts;
   /// Header search manager.
   std::unique_ptr<clang::HeaderSearch> HeaderInfo;
   // The loaded module map objects.
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 248bbe1657f8b..0506ac361721d 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -139,6 +139,9 @@ class ASTUnit {
   /// Optional owned invocation, just used to make the invocation used in
   /// LoadFromCommandLine available.
   std::shared_ptr<CompilerInvocation> Invocation;
+  /// Optional owned invocation, just used to make the invocation used in
+  /// Parse available.
+  std::shared_ptr<CompilerInvocation> CCInvocation;
 
   /// Fake module loader: the AST unit doesn't need to load any modules.
   TrivialModuleLoader ModuleLoader;
diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index f3dac905318c6..bccec4dd951d6 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -241,7 +241,7 @@ class HeaderSearch {
   friend SearchDirIterator;
 
   /// Header-search options used to initialize this header search.
-  std::shared_ptr<const HeaderSearchOptions> HSOpts;
+  const HeaderSearchOptions &HSOpts;
 
   /// Mapping from SearchDir to HeaderSearchOptions::UserEntries indices.
   llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
@@ -359,15 +359,15 @@ class HeaderSearch {
   void indexInitialHeaderMaps();
 
 public:
-  HeaderSearch(std::shared_ptr<const HeaderSearchOptions> HSOpts,
-               SourceManager &SourceMgr, DiagnosticsEngine &Diags,
-               const LangOptions &LangOpts, const TargetInfo *Target);
+  HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
+               DiagnosticsEngine &Diags, const LangOptions &LangOpts,
+               const TargetInfo *Target);
   HeaderSearch(const HeaderSearch &) = delete;
   HeaderSearch &operator=(const HeaderSearch &) = delete;
 
   /// Retrieve the header-search options with which this header search
   /// was initialized.
-  const HeaderSearchOptions &getHeaderSearchOpts() const { return *HSOpts; }
+  const HeaderSearchOptions &getHeaderSearchOpts() const { return HSOpts; }
 
   FileManager &getFileMgr() const { return FileMgr; }
 
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 1dda7f4bde027..0a5f1cfd1a264 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -832,7 +832,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
   AST->ModCache = createCrossProcessModuleCache();
   AST->HSOpts = HSOpts ? HSOpts : std::make_shared<HeaderSearchOptions>();
   AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormats().front());
-  AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts,
+  AST->HeaderInfo.reset(new HeaderSearch(AST->getHeaderSearchOpts(),
                                          AST->getSourceManager(),
                                          AST->getDiagnostics(),
                                          AST->getLangOpts(),
@@ -1153,7 +1153,7 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
     assert(VFS == &FileMgr->getVirtualFileSystem() &&
            "VFS passed to Parse and VFS in FileMgr are different");
 
-  auto CCInvocation = std::make_shared<CompilerInvocation>(*Invocation);
+  CCInvocation = std::make_shared<CompilerInvocation>(*Invocation);
   if (OverrideMainBuffer) {
     assert(Preamble &&
            "No preamble was built, but OverrideMainBuffer is not null");
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index bff5326e89973..4e13b6ced252f 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -451,7 +451,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
 
   // Create the Preprocessor.
   HeaderSearch *HeaderInfo =
-      new HeaderSearch(getHeaderSearchOptsPtr(), getSourceManager(),
+      new HeaderSearch(getHeaderSearchOpts(), getSourceManager(),
                        getDiagnostics(), getLangOpts(), &getTarget());
   PP = std::make_shared<Preprocessor>(Invocation->getPreprocessorOptsPtr(),
                                       getDiagnostics(), getLangOpts(),
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ad9263f2994f2..1b6de76d260ff 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -80,13 +80,12 @@ HeaderFileInfo::getControllingMacro(ExternalPreprocessorSource *External) {
 
 ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource() = default;
 
-HeaderSearch::HeaderSearch(std::shared_ptr<const HeaderSearchOptions> HSOpts,
+HeaderSearch::HeaderSearch(const HeaderSearchOptions &HSOpts,
                            SourceManager &SourceMgr, DiagnosticsEngine &Diags,
                            const LangOptions &LangOpts,
                            const TargetInfo *Target)
-    : HSOpts(std::move(HSOpts)), Diags(Diags),
-      FileMgr(SourceMgr.getFileManager()), FrameworkMap(64),
-      ModMap(SourceMgr, Diags, LangOpts, Target, *this) {}
+    : HSOpts(HSOpts), Diags(Diags), FileMgr(SourceMgr.getFileManager()),
+      FrameworkMap(64), ModMap(SourceMgr, Diags, LangOpts, Target, *this) {}
 
 void HeaderSearch::PrintStats() {
   llvm::errs() << "\n*** HeaderSearch Stats:\n"
@@ -129,7 +128,7 @@ void HeaderSearch::AddSearchPath(const DirectoryLookup &dir, bool isAngled) {
 }
 
 std::vector<bool> HeaderSearch::computeUserEntryUsage() const {
-  std::vector<bool> UserEntryUsage(HSOpts->UserEntries.size());
+  std::vector<bool> UserEntryUsage(HSOpts.UserEntries.size());
   for (unsigned I = 0, E = SearchDirsUsage.size(); I < E; ++I) {
     // Check whether this DirectoryLookup has been successfully used.
     if (SearchDirsUsage[I]) {
@@ -211,16 +210,16 @@ std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
 std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
                                                     bool FileMapOnly) {
   // First check the module name to pcm file map.
-  auto i(HSOpts->PrebuiltModuleFiles.find(ModuleName));
-  if (i != HSOpts->PrebuiltModuleFiles.end())
+  auto i(HSOpts.PrebuiltModuleFiles.find(ModuleName));
+  if (i != HSOpts.PrebuiltModuleFiles.end())
     return i->second;
 
-  if (FileMapOnly || HSOpts->PrebuiltModulePaths.empty())
+  if (FileMapOnly || HSOpts.PrebuiltModulePaths.empty())
     return {};
 
   // Then go through each prebuilt module directory and try to find the pcm
   // file.
-  for (const std::string &Dir : HSOpts->PrebuiltModulePaths) {
+  for (const std::string &Dir : HSOpts.PrebuiltModulePaths) {
     SmallString<256> Result(Dir);
     llvm::sys::fs::make_absolute(Result);
     if (ModuleName.contains(':'))
@@ -244,8 +243,8 @@ std::string HeaderSearch::getPrebuiltImplicitModuleFileName(Module *Module) {
       getModuleMap().getModuleMapFileForUniquing(Module);
   StringRef ModuleName = Module->Name;
   StringRef ModuleMapPath = ModuleMap->getName();
-  StringRef ModuleCacheHash = HSOpts->DisableModuleHash ? "" : getModuleHash();
-  for (const std::string &Dir : HSOpts->PrebuiltModulePaths) {
+  StringRef ModuleCacheHash = HSOpts.DisableModuleHash ? "" : getModuleHash();
+  for (const std::string &Dir : HSOpts.PrebuiltModulePaths) {
     SmallString<256> CachePath(Dir);
     llvm::sys::fs::make_absolute(CachePath);
     llvm::sys::path::append(CachePath, ModuleCacheHash);
@@ -273,7 +272,7 @@ std::string HeaderSearch::getCachedModuleFileNameImpl(StringRef ModuleName,
 
   SmallString<256> Result(CachePath);
 
-  if (HSOpts->DisableModuleHash) {
+  if (HSOpts.DisableModuleHash) {
     llvm::sys::path::append(Result, ModuleName + ".pcm");
   } else {
     // Construct the name <ModuleName>-<hash of ModuleMapPath>.pcm which should
@@ -301,7 +300,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName,
                                    bool AllowExtraModuleMapSearch) {
   // Look in the module map to determine if there is a module by this name.
   Module *Module = ModMap.findModule(ModuleName);
-  if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps)
+  if (Module || !AllowSearch || !HSOpts.ImplicitModuleMaps)
     return Module;
 
   StringRef SearchName = ModuleName;
@@ -382,7 +381,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
         break;
     }
 
-    if (HSOpts->AllowModuleMapSubdirectorySearch) {
+    if (HSOpts.AllowModuleMapSubdirectorySearch) {
       // If we've already performed the exhaustive search for module maps in
       // this search directory, don't do it again.
       if (Dir.haveSearchedAllModuleMaps())
@@ -770,7 +769,7 @@ void HeaderSearch::noteLookupUsage(unsigned HitIdx, SourceLocation Loc) {
   auto UserEntryIdxIt = SearchDirToHSEntry.find(HitIdx);
   if (UserEntryIdxIt != SearchDirToHSEntry.end())
     Diags.Report(Loc, diag::remark_pp_search_path_usage)
-        << HSOpts->UserEntries[UserEntryIdxIt->second].Path;
+        << HSOpts.UserEntries[UserEntryIdxIt->second].Path;
 }
 
 void HeaderSearch::setTarget(const TargetInfo &Target) {
@@ -1557,7 +1556,7 @@ StringRef HeaderSearch::getIncludeNameForHeader(const FileEntry *File) const {
 bool HeaderSearch::hasModuleMap(StringRef FileName,
                                 const DirectoryEntry *Root,
                                 bool IsSystem) {
-  if (!HSOpts->ImplicitModuleMaps)
+  if (!HSOpts.ImplicitModuleMaps)
     return false;
 
   SmallVector<const DirectoryEntry *, 2> FixUpDirectories;
@@ -1803,7 +1802,7 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
 
 OptionalFileEntryRef
 HeaderSearch::lookupModuleMapFile(DirectoryEntryRef Dir, bool IsFramework) {
-  if (!HSOpts->ImplicitModuleMaps)
+  if (!HSOpts.ImplicitModuleMaps)
     return std::nullopt;
   // For frameworks, the preferred spelling is Modules/module.modulemap, but
   // module.map at the framework root is also accepted.
@@ -1841,7 +1840,7 @@ Module *HeaderSearch::loadFrameworkModule(StringRef Name, DirectoryEntryRef Dir,
   switch (loadModuleMapFile(Dir, IsSystem, /*IsFramework*/true)) {
   case LMM_InvalidModuleMap:
     // Try to infer a module map from the framework directory.
-    if (HSOpts->ImplicitModuleMaps)
+    if (HSOpts.ImplicitModuleMaps)
       ModMap.inferFrameworkModule(Dir, IsSystem, /*Parent=*/nullptr);
     break;
 
@@ -1891,7 +1890,7 @@ HeaderSearch::loadModuleMapFile(DirectoryEntryRef Dir, bool IsSystem,
 void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
   Modules.clear();
 
-  if (HSOpts->ImplicitModuleMaps) {
+  if (HSOpts.ImplicitModuleMaps) {
     // Load module maps for each of the header search directories.
     for (DirectoryLookup &DL : search_dir_range()) {
       bool IsSystem = DL.isSystemHeaderDirectory();
@@ -1938,7 +1937,7 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
 }
 
 void HeaderSearch::loadTopLevelSystemModules() {
-  if (!HSOpts->ImplicitModuleMaps)
+  if (!HSOpts.ImplicitModuleMaps)
     return;
 
   // Load module maps for each of the header search directories.
@@ -1954,7 +1953,7 @@ void HeaderSearch::loadTopLevelSystemModules() {
 }
 
 void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
-  assert(HSOpts->ImplicitModuleMaps &&
+  assert(HSOpts.ImplicitModuleMaps &&
          "Should not be loading subdirectory module maps");
 
   if (SearchDir.haveSearchedAllModuleMaps())
diff --git a/clang/unittests/Analysis/MacroExpansionContextTest.cpp b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
index 54b209e7b28c1..48db9d46180ab 100644
--- a/clang/unittests/Analysis/MacroExpansionContextTest.cpp
+++ b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
@@ -58,9 +58,9 @@ class MacroExpansionContextTest : public ::testing::Test {
     std::unique_ptr<llvm::MemoryBuffer> Buf =
         llvm::MemoryBuffer::getMemBuffer(SourceText);
     SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
+    HeaderSearchOptions HSOpts;
     TrivialModuleLoader ModLoader;
-    HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
-                            Diags, LangOpts, Target.get());
+    HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, Target.get());
     Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
                     SourceMgr, HeaderInfo, ModLoader,
                     /*IILookup =*/nullptr,
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp
index 2b3fce9128ba9..1f2dba6fcc5d8 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -135,9 +135,9 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
   FileID mainFileID = SourceMgr.createFileID(std::move(Buf));
   SourceMgr.setMainFileID(mainFileID);
 
+  HeaderSearchOptions HSOpts;
   TrivialModuleLoader ModLoader;
-  HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
-                          Diags, LangOpts, &*Target);
+  HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, &*Target);
   Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
                   SourceMgr, HeaderInfo, ModLoader,
                   /*IILookup =*/nullptr,
@@ -185,9 +185,9 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithTokenSplit) {
   SourceMgr.setMainFileID(
       SourceMgr.createFileID(llvm::MemoryBuffer::getMemBuffer(main)));
 
+  HeaderSearchOptions HSOpts;
   TrivialModuleLoader ModLoader;
-  HeaderSearch HeaderInfo(std::make_shared<Heade...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Mar 24, 2025

@llvm/pr-subscribers-clang

Author: Jan Svoboda (jansvoboda11)

Changes

This makes it so that CompilerInvocation can be the only entity that manages ownership of HeaderSearchOptions, making it possible to implement copy-on-write semantics.


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

20 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp (+4-7)
  • (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h (+2)
  • (modified) clang-tools-extra/clangd/ModulesBuilder.cpp (+5-5)
  • (modified) clang-tools-extra/clangd/unittests/StdLibTests.cpp (+2-1)
  • (modified) clang-tools-extra/modularize/ModularizeUtilities.cpp (+2-3)
  • (modified) clang-tools-extra/modularize/ModularizeUtilities.h (+2)
  • (modified) clang/include/clang/Frontend/ASTUnit.h (+3)
  • (modified) clang/include/clang/Lex/HeaderSearch.h (+5-5)
  • (modified) clang/lib/Frontend/ASTUnit.cpp (+2-2)
  • (modified) clang/lib/Frontend/CompilerInstance.cpp (+1-1)
  • (modified) clang/lib/Lex/HeaderSearch.cpp (+20-21)
  • (modified) clang/unittests/Analysis/MacroExpansionContextTest.cpp (+2-2)
  • (modified) clang/unittests/Basic/SourceManagerTest.cpp (+10-10)
  • (modified) clang/unittests/Lex/HeaderSearchTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/LexerTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/ModuleDeclStateTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/PPCallbacksTest.cpp (+14-12)
  • (modified) clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/PPDependencyDirectivesTest.cpp (+2-2)
  • (modified) clang/unittests/Lex/PPMemoryAllocationsTest.cpp (+2-2)
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 4c34f9ea122d9..a15850cb63542 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -73,7 +73,7 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
       // Forward the new diagnostics to the original DiagnosticConsumer.
       Diags(new DiagnosticIDs, new DiagnosticOptions,
             new ForwardingDiagnosticConsumer(Compiler.getDiagnosticClient())),
-      LangOpts(Compiler.getLangOpts()) {
+      LangOpts(Compiler.getLangOpts()), HSOpts(Compiler.getHeaderSearchOpts()) {
   // Add a FileSystem containing the extra files needed in place of modular
   // headers.
   OverlayFS->pushOverlay(InMemoryFs);
@@ -86,11 +86,8 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
 
   LangOpts.Modules = false;
 
-  auto HSO = std::make_shared<HeaderSearchOptions>();
-  *HSO = Compiler.getHeaderSearchOpts();
-
-  HeaderInfo = std::make_unique<HeaderSearch>(HSO, Sources, Diags, LangOpts,
-                                               &Compiler.getTarget());
+  HeaderInfo = std::make_unique<HeaderSearch>(HSOpts, Sources, Diags, LangOpts,
+                                              &Compiler.getTarget());
 
   auto PO = std::make_shared<PreprocessorOptions>();
   *PO = Compiler.getPreprocessorOpts();
@@ -102,7 +99,7 @@ ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
   PP->Initialize(Compiler.getTarget(), Compiler.getAuxTarget());
   InitializePreprocessor(*PP, *PO, Compiler.getPCHContainerReader(),
                          Compiler.getFrontendOpts(), Compiler.getCodeGenOpts());
-  ApplyHeaderSearchOptions(*HeaderInfo, *HSO, LangOpts,
+  ApplyHeaderSearchOptions(*HeaderInfo, HSOpts, LangOpts,
                            Compiler.getTarget().getTriple());
 }
 
diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
index 0742c21bc4372..a263681b3c633 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_CLANG_TOOLING_EXPANDMODULARHEADERSPPCALLBACKS_H_
 #define LLVM_CLANG_TOOLING_EXPANDMODULARHEADERSPPCALLBACKS_H_
 
+#include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/DenseSet.h"
@@ -129,6 +130,7 @@ class ExpandModularHeadersPPCallbacks : public PPCallbacks {
   SourceManager &Sources;
   DiagnosticsEngine Diags;
   LangOptions LangOpts;
+  HeaderSearchOptions HSOpts;
   TrivialModuleLoader ModuleLoader;
 
   std::unique_ptr<HeaderSearch> HeaderInfo;
diff --git a/clang-tools-extra/clangd/ModulesBuilder.cpp b/clang-tools-extra/clangd/ModulesBuilder.cpp
index 39cf57f5fe724..03c5f5e1b5993 100644
--- a/clang-tools-extra/clangd/ModulesBuilder.cpp
+++ b/clang-tools-extra/clangd/ModulesBuilder.cpp
@@ -181,10 +181,10 @@ class ReusablePrerequisiteModules : public PrerequisiteModules {
 bool IsModuleFileUpToDate(PathRef ModuleFilePath,
                           const PrerequisiteModules &RequisiteModules,
                           llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
-  auto HSOpts = std::make_shared<HeaderSearchOptions>();
-  RequisiteModules.adjustHeaderSearchOptions(*HSOpts);
-  HSOpts->ForceCheckCXX20ModulesInputFiles = true;
-  HSOpts->ValidateASTInputFilesContent = true;
+  HeaderSearchOptions HSOpts;
+  RequisiteModules.adjustHeaderSearchOptions(HSOpts);
+  HSOpts.ForceCheckCXX20ModulesInputFiles = true;
+  HSOpts.ValidateASTInputFilesContent = true;
 
   clang::clangd::IgnoreDiagnostics IgnoreDiags;
   IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
@@ -199,7 +199,7 @@ bool IsModuleFileUpToDate(PathRef ModuleFilePath,
 
   SourceManager SourceMgr(*Diags, FileMgr);
 
-  HeaderSearch HeaderInfo(std::move(HSOpts), SourceMgr, *Diags, LangOpts,
+  HeaderSearch HeaderInfo(HSOpts, SourceMgr, *Diags, LangOpts,
                           /*Target=*/nullptr);
 
   TrivialModuleLoader ModuleLoader;
diff --git a/clang-tools-extra/clangd/unittests/StdLibTests.cpp b/clang-tools-extra/clangd/unittests/StdLibTests.cpp
index a39d34ea33811..a7a33f78303d3 100644
--- a/clang-tools-extra/clangd/unittests/StdLibTests.cpp
+++ b/clang-tools-extra/clangd/unittests/StdLibTests.cpp
@@ -85,11 +85,12 @@ TEST(StdLibTests, StdLibSet) {
   FS.Files["std/_"] = "";
   FS.Files["libc/_"] = "";
 
+  HeaderSearchOptions HSOpts;
   auto Add = [&](const LangOptions &LO,
                  std::vector<llvm::StringRef> SearchPath) {
     SourceManagerForFile SM("scratch", "");
     SM.get().getFileManager().setVirtualFileSystem(FS.view(std::nullopt));
-    HeaderSearch HS(/*HSOpts=*/nullptr, SM.get(), SM.get().getDiagnostics(), LO,
+    HeaderSearch HS(HSOpts, SM.get(), SM.get().getDiagnostics(), LO,
                     /*Target=*/nullptr);
     for (auto P : SearchPath)
       HS.AddSearchPath(
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.cpp b/clang-tools-extra/modularize/ModularizeUtilities.cpp
index 476e13770a94f..78df40cb006e0 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.cpp
+++ b/clang-tools-extra/modularize/ModularizeUtilities.cpp
@@ -55,9 +55,8 @@ ModularizeUtilities::ModularizeUtilities(std::vector<std::string> &InputPaths,
       TargetOpts(new ModuleMapTargetOptions()),
       Target(TargetInfo::CreateTargetInfo(*Diagnostics, TargetOpts)),
       FileMgr(new FileManager(FileSystemOpts)),
-      SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)),
-      HeaderInfo(new HeaderSearch(std::make_shared<HeaderSearchOptions>(),
-                                  *SourceMgr, *Diagnostics, *LangOpts,
+      SourceMgr(new SourceManager(*Diagnostics, *FileMgr, false)), HSOpts(),
+      HeaderInfo(new HeaderSearch(HSOpts, *SourceMgr, *Diagnostics, *LangOpts,
                                   Target.get())) {}
 
 // Create instance of ModularizeUtilities, to simplify setting up
diff --git a/clang-tools-extra/modularize/ModularizeUtilities.h b/clang-tools-extra/modularize/ModularizeUtilities.h
index 64675022dad76..7b4c16a492b89 100644
--- a/clang-tools-extra/modularize/ModularizeUtilities.h
+++ b/clang-tools-extra/modularize/ModularizeUtilities.h
@@ -213,6 +213,8 @@ class ModularizeUtilities {
   llvm::IntrusiveRefCntPtr<clang::FileManager> FileMgr;
   /// Source manager.
   llvm::IntrusiveRefCntPtr<clang::SourceManager> SourceMgr;
+  /// Header search options.
+  clang::HeaderSearchOptions HSOpts;
   /// Header search manager.
   std::unique_ptr<clang::HeaderSearch> HeaderInfo;
   // The loaded module map objects.
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 248bbe1657f8b..0506ac361721d 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -139,6 +139,9 @@ class ASTUnit {
   /// Optional owned invocation, just used to make the invocation used in
   /// LoadFromCommandLine available.
   std::shared_ptr<CompilerInvocation> Invocation;
+  /// Optional owned invocation, just used to make the invocation used in
+  /// Parse available.
+  std::shared_ptr<CompilerInvocation> CCInvocation;
 
   /// Fake module loader: the AST unit doesn't need to load any modules.
   TrivialModuleLoader ModuleLoader;
diff --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index f3dac905318c6..bccec4dd951d6 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -241,7 +241,7 @@ class HeaderSearch {
   friend SearchDirIterator;
 
   /// Header-search options used to initialize this header search.
-  std::shared_ptr<const HeaderSearchOptions> HSOpts;
+  const HeaderSearchOptions &HSOpts;
 
   /// Mapping from SearchDir to HeaderSearchOptions::UserEntries indices.
   llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
@@ -359,15 +359,15 @@ class HeaderSearch {
   void indexInitialHeaderMaps();
 
 public:
-  HeaderSearch(std::shared_ptr<const HeaderSearchOptions> HSOpts,
-               SourceManager &SourceMgr, DiagnosticsEngine &Diags,
-               const LangOptions &LangOpts, const TargetInfo *Target);
+  HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
+               DiagnosticsEngine &Diags, const LangOptions &LangOpts,
+               const TargetInfo *Target);
   HeaderSearch(const HeaderSearch &) = delete;
   HeaderSearch &operator=(const HeaderSearch &) = delete;
 
   /// Retrieve the header-search options with which this header search
   /// was initialized.
-  const HeaderSearchOptions &getHeaderSearchOpts() const { return *HSOpts; }
+  const HeaderSearchOptions &getHeaderSearchOpts() const { return HSOpts; }
 
   FileManager &getFileMgr() const { return FileMgr; }
 
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 1dda7f4bde027..0a5f1cfd1a264 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -832,7 +832,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
   AST->ModCache = createCrossProcessModuleCache();
   AST->HSOpts = HSOpts ? HSOpts : std::make_shared<HeaderSearchOptions>();
   AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormats().front());
-  AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts,
+  AST->HeaderInfo.reset(new HeaderSearch(AST->getHeaderSearchOpts(),
                                          AST->getSourceManager(),
                                          AST->getDiagnostics(),
                                          AST->getLangOpts(),
@@ -1153,7 +1153,7 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
     assert(VFS == &FileMgr->getVirtualFileSystem() &&
            "VFS passed to Parse and VFS in FileMgr are different");
 
-  auto CCInvocation = std::make_shared<CompilerInvocation>(*Invocation);
+  CCInvocation = std::make_shared<CompilerInvocation>(*Invocation);
   if (OverrideMainBuffer) {
     assert(Preamble &&
            "No preamble was built, but OverrideMainBuffer is not null");
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index bff5326e89973..4e13b6ced252f 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -451,7 +451,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
 
   // Create the Preprocessor.
   HeaderSearch *HeaderInfo =
-      new HeaderSearch(getHeaderSearchOptsPtr(), getSourceManager(),
+      new HeaderSearch(getHeaderSearchOpts(), getSourceManager(),
                        getDiagnostics(), getLangOpts(), &getTarget());
   PP = std::make_shared<Preprocessor>(Invocation->getPreprocessorOptsPtr(),
                                       getDiagnostics(), getLangOpts(),
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index ad9263f2994f2..1b6de76d260ff 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -80,13 +80,12 @@ HeaderFileInfo::getControllingMacro(ExternalPreprocessorSource *External) {
 
 ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource() = default;
 
-HeaderSearch::HeaderSearch(std::shared_ptr<const HeaderSearchOptions> HSOpts,
+HeaderSearch::HeaderSearch(const HeaderSearchOptions &HSOpts,
                            SourceManager &SourceMgr, DiagnosticsEngine &Diags,
                            const LangOptions &LangOpts,
                            const TargetInfo *Target)
-    : HSOpts(std::move(HSOpts)), Diags(Diags),
-      FileMgr(SourceMgr.getFileManager()), FrameworkMap(64),
-      ModMap(SourceMgr, Diags, LangOpts, Target, *this) {}
+    : HSOpts(HSOpts), Diags(Diags), FileMgr(SourceMgr.getFileManager()),
+      FrameworkMap(64), ModMap(SourceMgr, Diags, LangOpts, Target, *this) {}
 
 void HeaderSearch::PrintStats() {
   llvm::errs() << "\n*** HeaderSearch Stats:\n"
@@ -129,7 +128,7 @@ void HeaderSearch::AddSearchPath(const DirectoryLookup &dir, bool isAngled) {
 }
 
 std::vector<bool> HeaderSearch::computeUserEntryUsage() const {
-  std::vector<bool> UserEntryUsage(HSOpts->UserEntries.size());
+  std::vector<bool> UserEntryUsage(HSOpts.UserEntries.size());
   for (unsigned I = 0, E = SearchDirsUsage.size(); I < E; ++I) {
     // Check whether this DirectoryLookup has been successfully used.
     if (SearchDirsUsage[I]) {
@@ -211,16 +210,16 @@ std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
 std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
                                                     bool FileMapOnly) {
   // First check the module name to pcm file map.
-  auto i(HSOpts->PrebuiltModuleFiles.find(ModuleName));
-  if (i != HSOpts->PrebuiltModuleFiles.end())
+  auto i(HSOpts.PrebuiltModuleFiles.find(ModuleName));
+  if (i != HSOpts.PrebuiltModuleFiles.end())
     return i->second;
 
-  if (FileMapOnly || HSOpts->PrebuiltModulePaths.empty())
+  if (FileMapOnly || HSOpts.PrebuiltModulePaths.empty())
     return {};
 
   // Then go through each prebuilt module directory and try to find the pcm
   // file.
-  for (const std::string &Dir : HSOpts->PrebuiltModulePaths) {
+  for (const std::string &Dir : HSOpts.PrebuiltModulePaths) {
     SmallString<256> Result(Dir);
     llvm::sys::fs::make_absolute(Result);
     if (ModuleName.contains(':'))
@@ -244,8 +243,8 @@ std::string HeaderSearch::getPrebuiltImplicitModuleFileName(Module *Module) {
       getModuleMap().getModuleMapFileForUniquing(Module);
   StringRef ModuleName = Module->Name;
   StringRef ModuleMapPath = ModuleMap->getName();
-  StringRef ModuleCacheHash = HSOpts->DisableModuleHash ? "" : getModuleHash();
-  for (const std::string &Dir : HSOpts->PrebuiltModulePaths) {
+  StringRef ModuleCacheHash = HSOpts.DisableModuleHash ? "" : getModuleHash();
+  for (const std::string &Dir : HSOpts.PrebuiltModulePaths) {
     SmallString<256> CachePath(Dir);
     llvm::sys::fs::make_absolute(CachePath);
     llvm::sys::path::append(CachePath, ModuleCacheHash);
@@ -273,7 +272,7 @@ std::string HeaderSearch::getCachedModuleFileNameImpl(StringRef ModuleName,
 
   SmallString<256> Result(CachePath);
 
-  if (HSOpts->DisableModuleHash) {
+  if (HSOpts.DisableModuleHash) {
     llvm::sys::path::append(Result, ModuleName + ".pcm");
   } else {
     // Construct the name <ModuleName>-<hash of ModuleMapPath>.pcm which should
@@ -301,7 +300,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName,
                                    bool AllowExtraModuleMapSearch) {
   // Look in the module map to determine if there is a module by this name.
   Module *Module = ModMap.findModule(ModuleName);
-  if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps)
+  if (Module || !AllowSearch || !HSOpts.ImplicitModuleMaps)
     return Module;
 
   StringRef SearchName = ModuleName;
@@ -382,7 +381,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
         break;
     }
 
-    if (HSOpts->AllowModuleMapSubdirectorySearch) {
+    if (HSOpts.AllowModuleMapSubdirectorySearch) {
       // If we've already performed the exhaustive search for module maps in
       // this search directory, don't do it again.
       if (Dir.haveSearchedAllModuleMaps())
@@ -770,7 +769,7 @@ void HeaderSearch::noteLookupUsage(unsigned HitIdx, SourceLocation Loc) {
   auto UserEntryIdxIt = SearchDirToHSEntry.find(HitIdx);
   if (UserEntryIdxIt != SearchDirToHSEntry.end())
     Diags.Report(Loc, diag::remark_pp_search_path_usage)
-        << HSOpts->UserEntries[UserEntryIdxIt->second].Path;
+        << HSOpts.UserEntries[UserEntryIdxIt->second].Path;
 }
 
 void HeaderSearch::setTarget(const TargetInfo &Target) {
@@ -1557,7 +1556,7 @@ StringRef HeaderSearch::getIncludeNameForHeader(const FileEntry *File) const {
 bool HeaderSearch::hasModuleMap(StringRef FileName,
                                 const DirectoryEntry *Root,
                                 bool IsSystem) {
-  if (!HSOpts->ImplicitModuleMaps)
+  if (!HSOpts.ImplicitModuleMaps)
     return false;
 
   SmallVector<const DirectoryEntry *, 2> FixUpDirectories;
@@ -1803,7 +1802,7 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
 
 OptionalFileEntryRef
 HeaderSearch::lookupModuleMapFile(DirectoryEntryRef Dir, bool IsFramework) {
-  if (!HSOpts->ImplicitModuleMaps)
+  if (!HSOpts.ImplicitModuleMaps)
     return std::nullopt;
   // For frameworks, the preferred spelling is Modules/module.modulemap, but
   // module.map at the framework root is also accepted.
@@ -1841,7 +1840,7 @@ Module *HeaderSearch::loadFrameworkModule(StringRef Name, DirectoryEntryRef Dir,
   switch (loadModuleMapFile(Dir, IsSystem, /*IsFramework*/true)) {
   case LMM_InvalidModuleMap:
     // Try to infer a module map from the framework directory.
-    if (HSOpts->ImplicitModuleMaps)
+    if (HSOpts.ImplicitModuleMaps)
       ModMap.inferFrameworkModule(Dir, IsSystem, /*Parent=*/nullptr);
     break;
 
@@ -1891,7 +1890,7 @@ HeaderSearch::loadModuleMapFile(DirectoryEntryRef Dir, bool IsSystem,
 void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
   Modules.clear();
 
-  if (HSOpts->ImplicitModuleMaps) {
+  if (HSOpts.ImplicitModuleMaps) {
     // Load module maps for each of the header search directories.
     for (DirectoryLookup &DL : search_dir_range()) {
       bool IsSystem = DL.isSystemHeaderDirectory();
@@ -1938,7 +1937,7 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
 }
 
 void HeaderSearch::loadTopLevelSystemModules() {
-  if (!HSOpts->ImplicitModuleMaps)
+  if (!HSOpts.ImplicitModuleMaps)
     return;
 
   // Load module maps for each of the header search directories.
@@ -1954,7 +1953,7 @@ void HeaderSearch::loadTopLevelSystemModules() {
 }
 
 void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
-  assert(HSOpts->ImplicitModuleMaps &&
+  assert(HSOpts.ImplicitModuleMaps &&
          "Should not be loading subdirectory module maps");
 
   if (SearchDir.haveSearchedAllModuleMaps())
diff --git a/clang/unittests/Analysis/MacroExpansionContextTest.cpp b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
index 54b209e7b28c1..48db9d46180ab 100644
--- a/clang/unittests/Analysis/MacroExpansionContextTest.cpp
+++ b/clang/unittests/Analysis/MacroExpansionContextTest.cpp
@@ -58,9 +58,9 @@ class MacroExpansionContextTest : public ::testing::Test {
     std::unique_ptr<llvm::MemoryBuffer> Buf =
         llvm::MemoryBuffer::getMemBuffer(SourceText);
     SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(Buf)));
+    HeaderSearchOptions HSOpts;
     TrivialModuleLoader ModLoader;
-    HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
-                            Diags, LangOpts, Target.get());
+    HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, Target.get());
     Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
                     SourceMgr, HeaderInfo, ModLoader,
                     /*IILookup =*/nullptr,
diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp
index 2b3fce9128ba9..1f2dba6fcc5d8 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -135,9 +135,9 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
   FileID mainFileID = SourceMgr.createFileID(std::move(Buf));
   SourceMgr.setMainFileID(mainFileID);
 
+  HeaderSearchOptions HSOpts;
   TrivialModuleLoader ModLoader;
-  HeaderSearch HeaderInfo(std::make_shared<HeaderSearchOptions>(), SourceMgr,
-                          Diags, LangOpts, &*Target);
+  HeaderSearch HeaderInfo(HSOpts, SourceMgr, Diags, LangOpts, &*Target);
   Preprocessor PP(std::make_shared<PreprocessorOptions>(), Diags, LangOpts,
                   SourceMgr, HeaderInfo, ModLoader,
                   /*IILookup =*/nullptr,
@@ -185,9 +185,9 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithTokenSplit) {
   SourceMgr.setMainFileID(
       SourceMgr.createFileID(llvm::MemoryBuffer::getMemBuffer(main)));
 
+  HeaderSearchOptions HSOpts;
   TrivialModuleLoader ModLoader;
-  HeaderSearch HeaderInfo(std::make_shared<Heade...
[truncated]

@github-actions
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 72e596f35951e849de9fc739238e84ec1217b939 187c26f90800edf0b5335322025606e3779e344a --extensions cpp,h -- clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h clang-tools-extra/clangd/ModulesBuilder.cpp clang-tools-extra/clangd/unittests/StdLibTests.cpp clang-tools-extra/modularize/ModularizeUtilities.cpp clang-tools-extra/modularize/ModularizeUtilities.h clang/include/clang/Frontend/ASTUnit.h clang/include/clang/Lex/HeaderSearch.h clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/CompilerInstance.cpp clang/lib/Lex/HeaderSearch.cpp clang/unittests/Analysis/MacroExpansionContextTest.cpp clang/unittests/Basic/SourceManagerTest.cpp clang/unittests/Lex/HeaderSearchTest.cpp clang/unittests/Lex/LexerTest.cpp clang/unittests/Lex/ModuleDeclStateTest.cpp clang/unittests/Lex/PPCallbacksTest.cpp clang/unittests/Lex/PPConditionalDirectiveRecordTest.cpp clang/unittests/Lex/PPDependencyDirectivesTest.cpp clang/unittests/Lex/PPMemoryAllocationsTest.cpp
View the diff from clang-format here.
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 0a5f1cfd1a..4bc0496253 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -832,11 +832,10 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
   AST->ModCache = createCrossProcessModuleCache();
   AST->HSOpts = HSOpts ? HSOpts : std::make_shared<HeaderSearchOptions>();
   AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormats().front());
-  AST->HeaderInfo.reset(new HeaderSearch(AST->getHeaderSearchOpts(),
-                                         AST->getSourceManager(),
-                                         AST->getDiagnostics(),
-                                         AST->getLangOpts(),
-                                         /*Target=*/nullptr));
+  AST->HeaderInfo.reset(
+      new HeaderSearch(AST->getHeaderSearchOpts(), AST->getSourceManager(),
+                       AST->getDiagnostics(), AST->getLangOpts(),
+                       /*Target=*/nullptr));
   AST->PPOpts = std::make_shared<PreprocessorOptions>();
 
   // Gather Info for preprocessor construction later on.

Copy link
Contributor

@Bigcheese Bigcheese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no point in having vague ownership here, so this lgtm.

@jansvoboda11 jansvoboda11 merged commit 7a37074 into llvm:main Mar 25, 2025
16 of 17 checks passed
@jansvoboda11 jansvoboda11 deleted the raw-hsopts-ref branch March 25, 2025 19:14
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 25, 2025

LLVM Buildbot has detected a new failure on builder lldb-x86_64-debian running on lldb-x86_64-debian while building clang-tools-extra,clang at step 4 "build".

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

Here is the relevant piece of the build log for the reference
Step 4 (build) failure: build (failure)
...
74.416 [51/21/443] Building CXX object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/core_main.cpp.o
74.777 [51/20/444] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/ClangInstallAPI.cpp.o
75.033 [51/19/445] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/Indexing.cpp.o
76.210 [51/18/446] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ASTStructExtractor.cpp.o
76.411 [51/17/447] Building CXX object tools/clang/tools/clang-repl/CMakeFiles/clang-repl.dir/ClangRepl.cpp.o
76.595 [51/16/448] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ASTResultSynthesizer.cpp.o
77.293 [51/15/449] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/Interpreter.cpp.o
77.544 [51/14/450] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangFunctionCaller.cpp.o
78.014 [51/13/451] Building CXX object tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/ClangScanDeps.cpp.o
78.377 [51/12/452] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
FAILED: tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o 
/usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/source/Plugins/TypeSystem/Clang -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/TypeSystem/Clang -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/include -I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/include -I/home/worker/2.0.1/lldb-x86_64-debian/build/include -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/include -I/usr/include/python3.11 -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/../clang/include -I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/../clang/include -I/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source -I/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb/source -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -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 -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -MF tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d -o tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -c /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
In file included from /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:9:
In file included from /home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:16:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/memory:76:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:1065:34: error: no matching constructor for initialization of 'clang::HeaderSearch'
    { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                                 ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1221:31: note: in instantiation of function template specialization 'std::make_unique<clang::HeaderSearch, std::shared_ptr<clang::HeaderSearchOptions> &, clang::SourceManager &, clang::DiagnosticsEngine &, clang::LangOptions &, clang::TargetInfo *>' requested here
    m_header_search_up = std::make_unique<clang::HeaderSearch>(
                              ^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:3: note: candidate constructor not viable: no known conversion from 'std::shared_ptr<clang::HeaderSearchOptions>' to 'const clang::HeaderSearchOptions' for 1st argument
  HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
  ^
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:365:3: note: candidate constructor not viable: requires 1 argument, but 5 were provided
  HeaderSearch(const HeaderSearch &) = delete;
  ^
1 error generated.
79.573 [51/11/453] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/StdLibraryFunctionsChecker.cpp.o
79.824 [51/10/454] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/ForwardDeclChecker.cpp.o
79.992 [51/9/455] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndex.cpp.o
80.088 [51/8/456] Building CXX object tools/lldb/source/Commands/CMakeFiles/lldbCommands.dir/CommandObjectTarget.cpp.o
80.550 [51/7/457] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
80.704 [51/6/458] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaOpenMP.cpp.o
80.951 [51/5/459] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
81.769 [51/4/460] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
83.886 [51/3/461] Building CXX object tools/lldb/tools/lldb-instr/CMakeFiles/lldb-instr.dir/Instrument.cpp.o
84.903 [51/2/462] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaExpr.cpp.o
87.423 [51/1/463] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXExtractAPI.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 25, 2025

LLVM Buildbot has detected a new failure on builder lldb-arm-ubuntu running on linaro-lldb-arm-ubuntu while building clang-tools-extra,clang at step 4 "build".

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

Here is the relevant piece of the build log for the reference
Step 4 (build) failure: build (failure)
...
179.954 [129/8/6431] Linking CXX executable bin/clang-21
179.997 [128/8/6432] Creating executable symlink bin/clang
180.231 [128/7/6433] Linking CXX executable bin/clang-repl
180.950 [128/6/6434] Linking CXX shared library lib/libclang.so.21.0.0git
180.960 [127/6/6435] Creating library symlink lib/libclang.so.21.0git lib/libclang.so
181.114 [126/6/6436] Building CXX object tools/lldb/source/Commands/CMakeFiles/lldbCommands.dir/CommandObjectTarget.cpp.o
181.511 [126/5/6437] Building CXX object tools/lldb/tools/lldb-instr/CMakeFiles/lldb-instr.dir/Instrument.cpp.o
181.610 [125/5/6438] Linking CXX executable bin/c-index-test
181.714 [125/4/6439] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
182.127 [125/3/6440] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
FAILED: tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_FILE_OFFSET_BITS=64 -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/source/Plugins/TypeSystem/Clang -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/llvm/include -I/usr/include/python3.10 -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/llvm/../clang/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/../clang/include -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/source -I/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb/source -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -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 -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -MF tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d -o tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -c /home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
In file included from ../llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:9:
In file included from ../llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:16:
In file included from /usr/lib/gcc/arm-linux-gnueabihf/11/../../../../include/c++/11/memory:76:
/usr/lib/gcc/arm-linux-gnueabihf/11/../../../../include/c++/11/bits/unique_ptr.h:962:34: error: no matching constructor for initialization of 'clang::HeaderSearch'
  962 |     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
      |                                  ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1221:31: note: in instantiation of function template specialization 'std::make_unique<clang::HeaderSearch, std::shared_ptr<clang::HeaderSearchOptions> &, clang::SourceManager &, clang::DiagnosticsEngine &, clang::LangOptions &, clang::TargetInfo *>' requested here
 1221 |     m_header_search_up = std::make_unique<clang::HeaderSearch>(
      |                               ^
../llvm-project/clang/include/clang/Lex/HeaderSearch.h:362:3: note: candidate constructor not viable: no known conversion from 'std::shared_ptr<clang::HeaderSearchOptions>' to 'const HeaderSearchOptions' for 1st argument
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |   ^            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm-project/clang/include/clang/Lex/HeaderSearch.h:365:3: note: candidate constructor not viable: requires 1 argument, but 5 were provided
  365 |   HeaderSearch(const HeaderSearch &) = delete;
      |   ^            ~~~~~~~~~~~~~~~~~~~~
1 error generated.
182.690 [125/2/6441] Linking CXX executable bin/lldb-instr
185.357 [125/1/6442] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 25, 2025

LLVM Buildbot has detected a new failure on builder cross-project-tests-sie-ubuntu running on doug-worker-1a while building clang-tools-extra,clang at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
759.984 [43/8/456] Linking CXX executable bin/llc
760.196 [42/8/457] Linking CXX executable bin/llvm-gpu-loader
760.664 [41/8/458] Linking CXX executable bin/c-index-test
761.019 [40/8/459] Linking CXX executable bin/llvm-extract
761.343 [39/8/460] Linking CXX executable bin/llvm-dwp
761.414 [38/8/461] Linking CXX executable bin/llvm-dwarfutil
761.456 [37/8/462] Linking CXX executable bin/llvm-libtool-darwin
761.518 [36/8/463] Linking CXX executable bin/llvm-exegesis
761.526 [35/8/464] Linking CXX executable bin/llvm-gsymutil
761.534 [34/8/465] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
FAILED: tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o 
/opt/ccache/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -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/cross-project-tests-sie-ubuntu/build/tools/lldb/source/Plugins/TypeSystem/Clang -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/include -I/usr/include/python3.8 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../clang/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/../clang/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/tools/lldb/source -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -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 -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -MF tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d -o tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -c /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
In file included from /usr/include/c++/9/memory:80,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:16,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:9:
/usr/include/c++/9/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = clang::HeaderSearch; _Args = {std::shared_ptr<clang::HeaderSearchOptions>&, clang::SourceManager&, clang::DiagnosticsEngine&, clang::LangOptions&, clang::TargetInfo*}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<clang::HeaderSearch>]’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1223:55:   required from here
/usr/include/c++/9/bits/unique_ptr.h:857:30: error: no matching function for call to ‘clang::HeaderSearch::HeaderSearch(std::shared_ptr<clang::HeaderSearchOptions>&, clang::SourceManager&, clang::DiagnosticsEngine&, clang::LangOptions&, clang::TargetInfo*)’
  857 |     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:41:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:3: note: candidate: ‘clang::HeaderSearch::HeaderSearch(const clang::HeaderSearchOptions&, clang::SourceManager&, clang::DiagnosticsEngine&, const clang::LangOptions&, const clang::TargetInfo*)’
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |   ^~~~~~~~~~~~
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:43: note:   no known conversion for argument 1 from ‘std::shared_ptr<clang::HeaderSearchOptions>’ to ‘const clang::HeaderSearchOptions&’
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
761.790 [34/7/466] Linking CXX executable bin/llvm-isel-fuzzer
761.823 [34/6/467] Linking CXX executable bin/llvm-link
761.839 [34/5/468] Linking CXX executable bin/llvm-lipo
761.843 [34/4/469] Linking CXX executable bin/llvm-jitlink
761.908 [34/3/470] Linking CXX executable bin/llvm-nm
762.002 [34/2/471] Linking CXX executable bin/llvm-objdump
763.559 [34/1/472] Linking CXX executable bin/llvm-lto2
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 25, 2025

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-ubuntu running on as-builder-9 while building clang-tools-extra,clang at step 7 "build-default".

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

Here is the relevant piece of the build log for the reference
Step 7 (build-default) failure: cmake (failure)
...
134.196 [177/16/5089] Linking CXX executable bin/llvm-reduce
134.521 [177/15/5090] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/ForwardDeclChecker.cpp.o
135.254 [177/14/5091] Building CXX object tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/ClangScanDeps.cpp.o
135.285 [177/13/5092] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
135.685 [177/12/5093] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ASTStructExtractor.cpp.o
135.696 [177/11/5094] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ASTResultSynthesizer.cpp.o
136.034 [177/10/5095] Linking CXX executable bin/opt
136.132 [177/9/5096] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangFunctionCaller.cpp.o
137.803 [177/8/5097] Building CXX object tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaOpenMP.cpp.o
138.361 [175/9/5098] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
FAILED: tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o 
ccache /usr/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/source/Plugins/TypeSystem/Clang -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/include -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/llvm/include -I/usr/include/python3.12 -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/llvm/../clang/include -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/../clang/include -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source -I/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb/source -D__OPTIMIZE__ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-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 -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -MF tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d -o tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -c /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
In file included from /usr/include/c++/13/memory:78,
                 from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:16,
                 from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:9:
/usr/include/c++/13/bits/unique_ptr.h: In instantiation of ‘std::__detail::__unique_ptr_t<_Tp> std::make_unique(_Args&& ...) [with _Tp = clang::HeaderSearch; _Args = {shared_ptr<clang::HeaderSearchOptions>&, clang::SourceManager&, clang::DiagnosticsEngine&, clang::LangOptions&, clang::TargetInfo*}; __detail::__unique_ptr_t<_Tp> = __detail::__unique_ptr_t<clang::HeaderSearch>]’:
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1221:63:   required from here
/usr/include/c++/13/bits/unique_ptr.h:1070:30: error: no matching function for call to ‘clang::HeaderSearch::HeaderSearch(std::shared_ptr<clang::HeaderSearchOptions>&, clang::SourceManager&, clang::DiagnosticsEngine&, clang::LangOptions&, clang::TargetInfo*)’
 1070 |     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:41:
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:3: note: candidate: ‘clang::HeaderSearch::HeaderSearch(const clang::HeaderSearchOptions&, clang::SourceManager&, clang::DiagnosticsEngine&, const clang::LangOptions&, const clang::TargetInfo*)’
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |   ^~~~~~~~~~~~
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:43: note:   no known conversion for argument 1 from ‘std::shared_ptr<clang::HeaderSearchOptions>’ to ‘const clang::HeaderSearchOptions&’
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
138.563 [175/8/5099] Linking CXX static library lib/libclangSema.a
138.773 [175/7/5100] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndex.cpp.o
139.008 [175/6/5101] Building CXX object tools/lldb/source/Commands/CMakeFiles/lldbCommands.dir/CommandObjectTarget.cpp.o
139.425 [175/5/5102] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
142.556 [175/4/5103] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
143.116 [175/3/5104] Building CXX object tools/lldb/tools/lldb-instr/CMakeFiles/lldb-instr.dir/Instrument.cpp.o
143.334 [175/2/5105] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CXExtractAPI.cpp.o
145.648 [175/1/5106] Linking CXX shared library lib/libclang-cpp.so.21.0git
ninja: build stopped: subcommand failed.

jansvoboda11 added a commit that referenced this pull request Mar 25, 2025
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 25, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building clang-tools-extra,clang at step 4 "build".

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

Here is the relevant piece of the build log for the reference
Step 4 (build) failure: build (failure)
...
885.694 [777/10/5781] Building CXX object tools/lldb/source/ValueObject/CMakeFiles/lldbValueObject.dir/ValueObjectConstResult.cpp.o
885.701 [777/9/5782] Linking CXX static library lib/liblldbInterpreterInterfaces.a
885.701 [777/8/5783] Linking CXX static library lib/liblldbPluginPlatformQemuUser.a
885.702 [777/7/5784] Building CXX object tools/lldb/source/ValueObject/CMakeFiles/lldbValueObject.dir/ValueObjectChild.cpp.o
885.702 [777/6/5785] Building CXX object tools/lldb/source/ValueObject/CMakeFiles/lldbValueObject.dir/ValueObjectConstResultCast.cpp.o
885.702 [777/5/5786] Linking CXX static library lib/liblldbHost.a
885.724 [777/4/5787] Building CXX object tools/lldb/source/ValueObject/CMakeFiles/lldbValueObject.dir/ValueObjectConstResultChild.cpp.o
885.725 [777/3/5788] Building CXX object tools/lldb/source/ValueObject/CMakeFiles/lldbValueObject.dir/ValueObjectConstResultImpl.cpp.o
885.725 [777/2/5789] Building CXX object tools/lldb/source/ValueObject/CMakeFiles/lldbValueObject.dir/ValueObjectDynamicValue.cpp.o
897.005 [777/1/5790] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
FAILED: tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/source/Plugins/TypeSystem/Clang -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/include -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/include -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/llvm/include -I/usr/include/python3.10 -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/llvm/../clang/include -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/../clang/include -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/source -I/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb/source -isystem /usr/include/libxml2 -fPIC -fno-semantic-interposition -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 -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -MF tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d -o tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -c /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
In file included from ../llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:9:
In file included from ../llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:16:
In file included from /usr/lib/gcc/aarch64-linux-gnu/11/../../../../include/c++/11/memory:76:
/usr/lib/gcc/aarch64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:962:34: error: no matching constructor for initialization of 'clang::HeaderSearch'
  962 |     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
      |                                  ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1221:31: note: in instantiation of function template specialization 'std::make_unique<clang::HeaderSearch, std::shared_ptr<clang::HeaderSearchOptions> &, clang::SourceManager &, clang::DiagnosticsEngine &, clang::LangOptions &, clang::TargetInfo *>' requested here
 1221 |     m_header_search_up = std::make_unique<clang::HeaderSearch>(
      |                               ^
../llvm-project/clang/include/clang/Lex/HeaderSearch.h:362:3: note: candidate constructor not viable: no known conversion from 'std::shared_ptr<clang::HeaderSearchOptions>' to 'const HeaderSearchOptions' for 1st argument
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |   ^            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../llvm-project/clang/include/clang/Lex/HeaderSearch.h:365:3: note: candidate constructor not viable: requires 1 argument, but 5 were provided
  365 |   HeaderSearch(const HeaderSearch &) = delete;
      |   ^            ~~~~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 25, 2025

LLVM Buildbot has detected a new failure on builder cross-project-tests-sie-ubuntu-dwarf5 running on doug-worker-1b while building clang-tools-extra,clang at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
1199.490 [22/8/477] Linking CXX executable bin/llvm-rtdyld
1199.509 [21/8/478] Linking CXX executable bin/llvm-profgen
1199.592 [20/8/479] Linking CXX executable bin/llvm-strings
1199.993 [19/8/480] Linking CXX executable bin/llvm-tli-checker
1200.129 [18/8/481] Linking CXX executable bin/llvm-symbolizer
1200.147 [17/8/482] Generating ../../bin/llvm-addr2line
1200.209 [16/8/483] Linking CXX executable bin/llvm-xray
1200.816 [15/8/484] Linking CXX executable bin/sanstats
1200.844 [14/8/485] Linking CXX executable bin/sancov
1201.227 [13/8/486] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
FAILED: tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o 
/opt/ccache/bin/g++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -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/cross-project-tests-sie-ubuntu-dwarf5/build/tools/lldb/source/Plugins/TypeSystem/Clang -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/source/Plugins/TypeSystem/Clang -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/lldb/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/include -I/usr/include/python3.10 -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/../clang/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/lldb/../clang/include -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/source -I/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/tools/lldb/source -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -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 -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -MF tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d -o tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -c /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
In file included from /usr/include/c++/11/memory:76,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:16,
                 from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:9:
/usr/include/c++/11/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = clang::HeaderSearch; _Args = {std::shared_ptr<clang::HeaderSearchOptions>&, clang::SourceManager&, clang::DiagnosticsEngine&, clang::LangOptions&, clang::TargetInfo*}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<clang::HeaderSearch>]’:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1221:63:   required from here
/usr/include/c++/11/bits/unique_ptr.h:962:30: error: no matching function for call to ‘clang::HeaderSearch::HeaderSearch(std::shared_ptr<clang::HeaderSearchOptions>&, clang::SourceManager&, clang::DiagnosticsEngine&, clang::LangOptions&, clang::TargetInfo*)’
  962 |     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
      |                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:41:
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:3: note: candidate: ‘clang::HeaderSearch::HeaderSearch(const clang::HeaderSearchOptions&, clang::SourceManager&, clang::DiagnosticsEngine&, const clang::LangOptions&, const clang::TargetInfo*)’
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |   ^~~~~~~~~~~~
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:43: note:   no known conversion for argument 1 from ‘std::shared_ptr<clang::HeaderSearchOptions>’ to ‘const clang::HeaderSearchOptions&’
  362 |   HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
1201.227 [13/7/487] Linking CXX executable bin/llvm-split
1201.277 [13/6/488] Linking CXX executable bin/yaml2obj
1201.309 [13/5/489] Linking CXX executable bin/llvm-lto2
1201.417 [13/4/490] Linking CXX executable bin/verify-uselistorder
1201.538 [13/3/491] Linking CXX executable bin/llvm-opt-fuzzer
1202.012 [13/2/492] Linking CXX executable bin/llvm-reduce
1202.616 [13/1/493] Linking CXX executable bin/opt
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 25, 2025

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

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
124.876 [125/22/7092] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangFunctionCaller.cpp.o
124.881 [125/21/7093] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ASTResultSynthesizer.cpp.o
125.135 [125/20/7094] Building CXX object tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/ExtractFunction.cpp.o
125.836 [125/19/7095] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/index/FileIndex.cpp.o
125.907 [125/18/7096] Building CXX object tools/lldb/source/Commands/CMakeFiles/lldbCommands.dir/CommandObjectTarget.cpp.o
126.610 [125/17/7097] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Hover.cpp.o
126.778 [125/16/7098] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/TUScheduler.cpp.o
126.781 [125/15/7099] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdServer.cpp.o
126.939 [125/14/7100] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Preamble.cpp.o
127.214 [125/13/7101] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
FAILED: tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -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/lldb/source/Plugins/TypeSystem/Clang -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/TypeSystem/Clang -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/include -I/b/1/llvm-x86_64-debian-dylib/build/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/../clang/include -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/../clang/include -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source -I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/source -isystem /usr/include/libxml2 -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 -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -MF tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d -o tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o -c /b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
In file included from /b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:9:
In file included from /b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h:16:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/memory:83:
/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/unique_ptr.h:962:34: error: no matching constructor for initialization of 'clang::HeaderSearch'
    { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                                 ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:1221:31: note: in instantiation of function template specialization 'std::make_unique<clang::HeaderSearch, std::shared_ptr<clang::HeaderSearchOptions> &, clang::SourceManager &, clang::DiagnosticsEngine &, clang::LangOptions &, clang::TargetInfo *>' requested here
    m_header_search_up = std::make_unique<clang::HeaderSearch>(
                              ^
/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:362:3: note: candidate constructor not viable: no known conversion from 'std::shared_ptr<clang::HeaderSearchOptions>' to 'const clang::HeaderSearchOptions' for 1st argument
  HeaderSearch(const HeaderSearchOptions &HSOpts, SourceManager &SourceMgr,
  ^
/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/../clang/include/clang/Lex/HeaderSearch.h:365:3: note: candidate constructor not viable: requires 1 argument, but 5 were provided
  HeaderSearch(const HeaderSearch &) = delete;
  ^
1 error generated.
128.763 [125/12/7102] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangModulesDeclVendor.cpp.o
129.570 [125/11/7103] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ParsedAST.cpp.o
129.590 [125/10/7104] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/CodeComplete.cpp.o
132.506 [125/9/7105] Building CXX object tools/lldb/source/Plugins/ExpressionParser/Clang/CMakeFiles/lldbPluginExpressionParserClang.dir/ClangExpressionParser.cpp.o
132.774 [125/8/7106] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/FindTarget.cpp.o
132.778 [125/7/7107] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/DumpAST.cpp.o
134.682 [125/6/7108] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/InlayHints.cpp.o
134.893 [125/5/7109] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/SemanticHighlighting.cpp.o
135.610 [125/4/7110] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/AST.cpp.o
135.988 [125/3/7111] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/Selection.cpp.o
136.585 [125/2/7112] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/ClangdLSPServer.cpp.o
141.106 [125/1/7113] Building CXX object tools/clang/tools/extra/clangd/CMakeFiles/obj.clangDaemon.dir/XRefs.cpp.o
ninja: build stopped: subcommand failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category clang-tidy clang-tools-extra clangd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants