[clang] [clang-tools-extra] [clang][lex] Store non-owning options ref in `HeaderSearch` (PR #132780)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 24 10:04:02 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
@llvm/pr-subscribers-clang-tidy
Author: Jan Svoboda (jansvoboda11)
<details>
<summary>Changes</summary>
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
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]
``````````
</details>
https://github.com/llvm/llvm-project/pull/132780
More information about the cfe-commits
mailing list