Skip to content

[clang] Make HeaderSearchOptions references const #130825

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clang/include/clang/Lex/HeaderSearch.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class HeaderSearch {
friend SearchDirIterator;

/// Header-search options used to initialize this header search.
std::shared_ptr<HeaderSearchOptions> HSOpts;
std::shared_ptr<const HeaderSearchOptions> HSOpts;

/// Mapping from SearchDir to HeaderSearchOptions::UserEntries indices.
llvm::DenseMap<unsigned, unsigned> SearchDirToHSEntry;
Expand Down Expand Up @@ -359,15 +359,15 @@ class HeaderSearch {
void indexInitialHeaderMaps();

public:
HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts,
HeaderSearch(std::shared_ptr<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.
HeaderSearchOptions &getHeaderSearchOpts() const { return *HSOpts; }
const HeaderSearchOptions &getHeaderSearchOpts() const { return *HSOpts; }

FileManager &getFileMgr() const { return FileMgr; }

Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ IntrusiveRefCntPtr<ASTReader> CompilerInstance::createPCHExternalASTSource(
ArrayRef<std::shared_ptr<DependencyCollector>> DependencyCollectors,
void *DeserializationListener, bool OwnDeserializationListener,
bool Preamble, bool UseGlobalModuleIndex) {
HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
const HeaderSearchOptions &HSOpts =
PP.getHeaderSearchInfo().getHeaderSearchOpts();

IntrusiveRefCntPtr<ASTReader> Reader(new ASTReader(
PP, ModuleCache, &Context, PCHContainerRdr, Extensions,
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,8 @@ void DumpModuleInfoAction::ExecuteAction() {

Preprocessor &PP = CI.getPreprocessor();
DumpModuleInfoListener Listener(Out);
HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
const HeaderSearchOptions &HSOpts =
PP.getHeaderSearchInfo().getHeaderSearchOpts();

// The FrontendAction::BeginSourceFile () method loads the AST so that much
// of the information is already available and modules should have been
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ HeaderFileInfo::getControllingMacro(ExternalPreprocessorSource *External) {

ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource() = default;

HeaderSearch::HeaderSearch(std::shared_ptr<HeaderSearchOptions> HSOpts,
HeaderSearch::HeaderSearch(std::shared_ptr<const HeaderSearchOptions> HSOpts,
SourceManager &SourceMgr, DiagnosticsEngine &Diags,
const LangOptions &LangOpts,
const TargetInfo *Target)
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4897,7 +4897,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type,
}
}

HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts();
const HeaderSearchOptions &HSOpts =
PP.getHeaderSearchInfo().getHeaderSearchOpts();
if (HSOpts.ModulesValidateOncePerBuildSession) {
// Now we are certain that the module and all modules it depends on are
// up-to-date. For implicitly-built module files, ensure the corresponding
Expand Down
Loading