Skip to content
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
4 changes: 2 additions & 2 deletions clang/include/clang/Frontend/ASTUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ASTUnit {
std::shared_ptr<Preprocessor> PP;
IntrusiveRefCntPtr<ASTContext> Ctx;
std::shared_ptr<TargetOptions> TargetOpts;
std::shared_ptr<HeaderSearchOptions> HSOpts;
std::unique_ptr<HeaderSearchOptions> HSOpts;
std::shared_ptr<PreprocessorOptions> PPOpts;
IntrusiveRefCntPtr<ASTReader> Reader;
bool HadModuleLoaderFatalFailure = false;
Expand Down Expand Up @@ -699,7 +699,7 @@ class ASTUnit {
WhatToLoad ToLoad,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
std::shared_ptr<HeaderSearchOptions> HSOpts,
const HeaderSearchOptions &HSOpts,
std::shared_ptr<LangOptions> LangOpts = nullptr,
bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Frontend/CompilerInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,6 @@ class CompilerInstance : public ModuleLoader {
const HeaderSearchOptions &getHeaderSearchOpts() const {
return Invocation->getHeaderSearchOpts();
}
std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() const {
return Invocation->getHeaderSearchOptsPtr();
}

APINotesOptions &getAPINotesOpts() { return Invocation->getAPINotesOpts(); }
const APINotesOptions &getAPINotesOpts() const {
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,6 @@ class CompilerInvocation : public CompilerInvocationBase {
/// @{
using CompilerInvocationBase::LangOpts;
using CompilerInvocationBase::TargetOpts;
std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() {
return HSOpts;
}
Comment on lines -272 to -274
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the primary goal of this PR.

std::shared_ptr<LangOptions> getLangOptsPtr() { return LangOpts; }
/// @}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CrossTU/CrossTranslationUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ CrossTranslationUnitContext::ASTLoader::loadFromDump(StringRef ASTDumpPath) {
return ASTUnit::LoadFromASTFile(
ASTDumpPath, CI.getPCHContainerOperations()->getRawReader(),
ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
CI.getHeaderSearchOptsPtr());
CI.getHeaderSearchOpts());
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Xazax-hun I think this change would mean that LoadFromASTFile would no longer modify the header search options on CI here. I'm not familiar with the CrossTU code; do you know if that is okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ping, and CC @gamesh411 too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

CC @haoNoQ @steakhal as well

}

/// Load the AST from a source-file, which is supposed to be located inside the
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/ASTMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void ASTMergeAction::ExecuteAction() {
/*ShouldOwnClient=*/true));
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
ASTFiles[I], CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags,
CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr());
CI.getFileSystemOpts(), CI.getHeaderSearchOpts());
Copy link
Collaborator

Choose a reason for hiding this comment

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

@adrian-prantl I think this change would mean that LoadFromASTFile would no longer modify the header search options on CI here. I'm not familiar with the ASTMerge code; do you know if that is okay?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ping, and CC @zygoloid too.


if (!Unit)
continue;
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Frontend/ASTUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,7 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
StringRef Filename, const PCHContainerReader &PCHContainerRdr,
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
std::shared_ptr<HeaderSearchOptions> HSOpts,
const FileSystemOptions &FileSystemOpts, const HeaderSearchOptions &HSOpts,
std::shared_ptr<LangOptions> LangOpts, bool OnlyLocalDecls,
CaptureDiagsKind CaptureDiagnostics, bool AllowASTWithCompilerErrors,
bool UserFilesAreVolatile, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
Expand All @@ -830,7 +829,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
AST->getFileManager(),
UserFilesAreVolatile);
AST->ModCache = createCrossProcessModuleCache();
AST->HSOpts = HSOpts ? HSOpts : std::make_shared<HeaderSearchOptions>();
AST->HSOpts = std::make_unique<HeaderSearchOptions>(HSOpts);
AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormats().front());
AST->HeaderInfo.reset(new HeaderSearch(AST->getHeaderSearchOpts(),
AST->getSourceManager(),
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,8 +780,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,

std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
InputFile, CI.getPCHContainerReader(), ASTUnit::LoadPreprocessorOnly,
ASTDiags, CI.getFileSystemOpts(),
/*HeaderSearchOptions=*/nullptr);
ASTDiags, CI.getFileSystemOpts(), CI.getHeaderSearchOpts());
if (!AST)
return false;

Expand Down Expand Up @@ -848,8 +847,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,

std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
InputFile, CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags,
CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr(),
CI.getLangOptsPtr());
CI.getFileSystemOpts(), CI.getHeaderSearchOpts(), CI.getLangOptsPtr());

if (!AST)
return false;
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/c-index-test/core_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static bool printSourceSymbolsFromModule(StringRef modulePath,
return true;
}

auto HSOpts = std::make_shared<HeaderSearchOptions>();
HeaderSearchOptions HSOpts;

IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(*llvm::vfs::getRealFileSystem(),
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static bool HandleAST(StringRef AstPath) {
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
AstPath, CI->getPCHContainerOperations()->getRawReader(),
ASTUnit::LoadASTOnly, DiagEngine, CI->getFileSystemOpts(),
CI->getHeaderSearchOptsPtr());
CI->getHeaderSearchOpts());

if (!Unit)
return false;
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/libclang/CIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4225,7 +4225,7 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,

CIndexer *CXXIdx = static_cast<CIndexer *>(CIdx);
FileSystemOptions FileSystemOpts;
auto HSOpts = std::make_shared<HeaderSearchOptions>();
HeaderSearchOptions HSOpts;

IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(*llvm::vfs::getRealFileSystem(),
Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/Frontend/ASTUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_F(ASTUnitTest, SaveLoadPreservesLangOptionsInPrintingPolicy) {
AST->Save(ASTFileName.str());

EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
auto HSOpts = std::make_shared<HeaderSearchOptions>();
HeaderSearchOptions HSOpts;

std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
ASTFileName, PCHContainerOps->getRawReader(), ASTUnit::LoadEverything,
Expand Down
Loading