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
26 changes: 12 additions & 14 deletions clang/include/clang/Frontend/ASTUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ASTUnit {
};

private:
std::shared_ptr<LangOptions> LangOpts;
std::unique_ptr<LangOptions> LangOpts;
IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
IntrusiveRefCntPtr<FileManager> FileMgr;
IntrusiveRefCntPtr<SourceManager> SourceMgr;
Expand Down Expand Up @@ -698,19 +698,17 @@ class ASTUnit {
/// lifetime is expected to extend past that of the returned ASTUnit.
///
/// \returns - The initialized ASTUnit or null if the AST failed to load.
static std::unique_ptr<ASTUnit>
LoadFromASTFile(StringRef Filename, const PCHContainerReader &PCHContainerRdr,
WhatToLoad ToLoad,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
const HeaderSearchOptions &HSOpts,
std::shared_ptr<LangOptions> LangOpts = nullptr,
bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
bool AllowASTWithCompilerErrors = false,
bool UserFilesAreVolatile = false,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
llvm::vfs::getRealFileSystem());
static std::unique_ptr<ASTUnit> LoadFromASTFile(
StringRef Filename, const PCHContainerReader &PCHContainerRdr,
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts,
const HeaderSearchOptions &HSOpts, const LangOptions *LangOpts = nullptr,
bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
bool AllowASTWithCompilerErrors = false,
bool UserFilesAreVolatile = false,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
llvm::vfs::getRealFileSystem());

private:
/// Helper function for \c LoadFromCompilerInvocation() and
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 @@ -327,9 +327,6 @@ class CompilerInstance : public ModuleLoader {

LangOptions &getLangOpts() { return Invocation->getLangOpts(); }
const LangOptions &getLangOpts() const { return Invocation->getLangOpts(); }
std::shared_ptr<LangOptions> getLangOptsPtr() const {
return Invocation->getLangOptsPtr();
}

PreprocessorOptions &getPreprocessorOpts() {
return Invocation->getPreprocessorOpts();
Expand Down
6 changes: 0 additions & 6 deletions clang/include/clang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ class CompilerInvocation : public CompilerInvocationBase {
}
/// @}

/// Base class internals.
/// @{
using CompilerInvocationBase::LangOpts;
std::shared_ptr<LangOptions> getLangOptsPtr() { return LangOpts; }
/// @}

/// Create a compiler invocation from a list of input options.
/// \returns true on success.
///
Expand Down
10 changes: 6 additions & 4 deletions clang/lib/Frontend/ASTUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
StringRef Filename, const PCHContainerReader &PCHContainerRdr,
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
const FileSystemOptions &FileSystemOpts, const HeaderSearchOptions &HSOpts,
std::shared_ptr<LangOptions> LangOpts, bool OnlyLocalDecls,
const LangOptions *LangOpts, bool OnlyLocalDecls,
CaptureDiagsKind CaptureDiagnostics, bool AllowASTWithCompilerErrors,
bool UserFilesAreVolatile, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
std::unique_ptr<ASTUnit> AST(new ASTUnit(true));
Expand All @@ -819,7 +819,8 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(

ConfigureDiags(Diags, *AST, CaptureDiagnostics);

AST->LangOpts = LangOpts ? LangOpts : std::make_shared<LangOptions>();
AST->LangOpts = LangOpts ? std::make_unique<LangOptions>(*LangOpts)
: std::make_unique<LangOptions>();
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
AST->Diagnostics = Diags;
Expand Down Expand Up @@ -1211,7 +1212,8 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
"IR inputs not support here!");

// Configure the various subsystems.
LangOpts = Clang->getInvocation().LangOpts;
LangOpts =
std::make_unique<LangOptions>(Clang->getInvocation().getLangOpts());
FileSystemOpts = Clang->getFileSystemOpts();

ResetForParse();
Expand Down Expand Up @@ -1486,7 +1488,7 @@ void ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance &CI) {
// Steal the created target, context, and preprocessor if they have been
// created.
assert(CI.hasInvocation() && "missing invocation");
LangOpts = CI.getInvocation().LangOpts;
LangOpts = std::make_unique<LangOptions>(CI.getInvocation().getLangOpts());
TheSema = CI.takeSema();
Consumer = CI.takeASTConsumer();
if (CI.hasASTContext())
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/FrontendAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,

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

if (!AST)
return false;
Expand Down