diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Frontend')
9 files changed, 48 insertions, 37 deletions
diff --git a/contrib/llvm/tools/clang/lib/Frontend/ASTMerge.cpp b/contrib/llvm/tools/clang/lib/Frontend/ASTMerge.cpp index f6f1551..762c7a5 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/ASTMerge.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/ASTMerge.cpp @@ -46,7 +46,7 @@ void ASTMergeAction::ExecuteAction() { *CI.getDiagnostics().getClient()), /*ShouldOwnClient=*/true)); std::unique_ptr<ASTUnit> Unit = - ASTUnit::LoadFromASTFile(ASTFiles[I], CI.getPCHContainerOperations(), + ASTUnit::LoadFromASTFile(ASTFiles[I], CI.getPCHContainerReader(), Diags, CI.getFileSystemOpts(), false); if (!Unit) diff --git a/contrib/llvm/tools/clang/lib/Frontend/ASTUnit.cpp b/contrib/llvm/tools/clang/lib/Frontend/ASTUnit.cpp index 57c97d0..1bb5c3f 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/ASTUnit.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/ASTUnit.cpp @@ -650,7 +650,7 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags, std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile( const std::string &Filename, - std::shared_ptr<PCHContainerOperations> PCHContainerOps, + const PCHContainerReader &PCHContainerRdr, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, const FileSystemOptions &FileSystemOpts, bool OnlyLocalDecls, ArrayRef<RemappedFile> RemappedFiles, bool CaptureDiagnostics, @@ -676,7 +676,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile( AST->getFileManager(), UserFilesAreVolatile); AST->HSOpts = new HeaderSearchOptions(); - + AST->HSOpts->ModuleFormat = PCHContainerRdr.getFormat(); AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts, AST->getSourceManager(), AST->getDiagnostics(), @@ -708,7 +708,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile( bool disableValid = false; if (::getenv("LIBCLANG_DISABLE_PCH_VALIDATION")) disableValid = true; - AST->Reader = new ASTReader(PP, Context, *PCHContainerOps, + AST->Reader = new ASTReader(PP, Context, PCHContainerRdr, /*isysroot=*/"", /*DisableValidation=*/disableValid, AllowPCHWithCompilerErrors); diff --git a/contrib/llvm/tools/clang/lib/Frontend/ChainedIncludesSource.cpp b/contrib/llvm/tools/clang/lib/Frontend/ChainedIncludesSource.cpp index be30d43..cc0504b 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/ChainedIncludesSource.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/ChainedIncludesSource.cpp @@ -81,7 +81,7 @@ createASTReader(CompilerInstance &CI, StringRef pchFile, Preprocessor &PP = CI.getPreprocessor(); std::unique_ptr<ASTReader> Reader; Reader.reset(new ASTReader(PP, CI.getASTContext(), - *CI.getPCHContainerOperations(), + CI.getPCHContainerReader(), /*isysroot=*/"", /*DisableValidation=*/true)); for (unsigned ti = 0; ti < bufNames.size(); ++ti) { StringRef sr(bufNames[ti]); diff --git a/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp b/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp index ff041a8..c33b150 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp @@ -322,7 +322,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { PP->getFileManager(), PPOpts); // Predefine macros and configure the preprocessor. - InitializePreprocessor(*PP, PPOpts, *getPCHContainerOperations(), + InitializePreprocessor(*PP, PPOpts, getPCHContainerReader(), getFrontendOpts()); // Initialize the header search object. @@ -399,7 +399,7 @@ void CompilerInstance::createPCHExternalASTSource( ModuleManager = createPCHExternalASTSource( Path, getHeaderSearchOpts().Sysroot, DisablePCHValidation, AllowPCHWithCompilerErrors, getPreprocessor(), getASTContext(), - *getPCHContainerOperations(), DeserializationListener, + getPCHContainerReader(), DeserializationListener, OwnDeserializationListener, Preamble, getFrontendOpts().UseGlobalModuleIndex); } @@ -407,13 +407,13 @@ void CompilerInstance::createPCHExternalASTSource( IntrusiveRefCntPtr<ASTReader> CompilerInstance::createPCHExternalASTSource( StringRef Path, StringRef Sysroot, bool DisablePCHValidation, bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, - const PCHContainerOperations &PCHContainerOps, + const PCHContainerReader &PCHContainerRdr, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex) { HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts(); IntrusiveRefCntPtr<ASTReader> Reader(new ASTReader( - PP, Context, PCHContainerOps, Sysroot.empty() ? "" : Sysroot.data(), + PP, Context, PCHContainerRdr, Sysroot.empty() ? "" : Sysroot.data(), DisablePCHValidation, AllowPCHWithCompilerErrors, /*AllowConfigurationMismatch*/ false, HSOpts.ModulesValidateSystemHeaders, UseGlobalModuleIndex)); @@ -1244,7 +1244,7 @@ void CompilerInstance::createModuleManager() { ReadTimer = llvm::make_unique<llvm::Timer>("Reading modules", *FrontendTimerGroup); ModuleManager = new ASTReader( - getPreprocessor(), *Context, *getPCHContainerOperations(), + getPreprocessor(), *Context, getPCHContainerReader(), Sysroot.empty() ? "" : Sysroot.c_str(), PPOpts.DisablePCHValidation, /*AllowASTWithCompilerErrors=*/false, /*AllowConfigurationMismatch=*/false, @@ -1296,7 +1296,7 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) { ModuleFileStack.push_back(FileName); ModuleNameStack.push_back(StringRef()); if (ASTReader::readASTFileControlBlock(FileName, CI.getFileManager(), - *CI.getPCHContainerOperations(), + CI.getPCHContainerReader(), *this)) { CI.getDiagnostics().Report( SourceLocation(), CI.getFileManager().getBufferForFile(FileName) @@ -1667,7 +1667,7 @@ GlobalModuleIndex *CompilerInstance::loadGlobalModuleIndex( llvm::sys::fs::create_directories( getPreprocessor().getHeaderSearchInfo().getModuleCachePath()); GlobalModuleIndex::writeIndex( - getFileManager(), *getPCHContainerOperations(), + getFileManager(), getPCHContainerReader(), getPreprocessor().getHeaderSearchInfo().getModuleCachePath()); ModuleManager->resetForReload(); ModuleManager->loadGlobalIndex(); @@ -1695,7 +1695,7 @@ GlobalModuleIndex *CompilerInstance::loadGlobalModuleIndex( } if (RecreateIndex) { GlobalModuleIndex::writeIndex( - getFileManager(), *getPCHContainerOperations(), + getFileManager(), getPCHContainerReader(), getPreprocessor().getHeaderSearchInfo().getModuleCachePath()); ModuleManager->resetForReload(); ModuleManager->loadGlobalIndex(); diff --git a/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp b/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp index 6f13faf..fbeba09 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/CompilerInvocation.cpp @@ -1112,6 +1112,8 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) { getLastArgUInt64Value(Args, OPT_fbuild_session_timestamp, 0); Opts.ModulesValidateSystemHeaders = Args.hasArg(OPT_fmodules_validate_system_headers); + if (const Arg *A = Args.getLastArg(OPT_fmodule_format_EQ)) + Opts.ModuleFormat = A->getValue(); for (const Arg *A : Args.filtered(OPT_fmodules_ignore_macro)) { StringRef MacroDef = A->getValue(); @@ -1258,6 +1260,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, // OpenCL has some additional defaults. if (Opts.OpenCL) { Opts.AltiVec = 0; + Opts.ZVector = 0; Opts.CXXOperatorNames = 1; Opts.LaxVectorConversions = 0; Opts.DefaultFPContract = 1; @@ -1446,6 +1449,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, if (Args.hasArg(OPT_faltivec)) Opts.AltiVec = 1; + if (Args.hasArg(OPT_fzvector)) + Opts.ZVector = 1; + if (Args.hasArg(OPT_pthread)) Opts.POSIXThreads = 1; diff --git a/contrib/llvm/tools/clang/lib/Frontend/FrontendAction.cpp b/contrib/llvm/tools/clang/lib/Frontend/FrontendAction.cpp index db9dd3b..3e0f7a1 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/FrontendAction.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/FrontendAction.cpp @@ -191,7 +191,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags(&CI.getDiagnostics()); std::unique_ptr<ASTUnit> AST = - ASTUnit::LoadFromASTFile(InputFile, CI.getPCHContainerOperations(), + ASTUnit::LoadFromASTFile(InputFile, CI.getPCHContainerReader(), Diags, CI.getFileSystemOpts()); if (!AST) @@ -273,7 +273,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, Dir != DirEnd && !EC; Dir.increment(EC)) { // Check whether this is an acceptable AST file. if (ASTReader::isAcceptableASTFile( - Dir->path(), FileMgr, *CI.getPCHContainerOperations(), + Dir->path(), FileMgr, CI.getPCHContainerReader(), CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(), SpecificModuleCachePath)) { PPOpts.ImplicitPCHInclude = Dir->path(); @@ -443,7 +443,7 @@ bool FrontendAction::Execute() { if (CI.shouldBuildGlobalModuleIndex() && CI.hasFileManager() && CI.hasPreprocessor()) { GlobalModuleIndex::writeIndex( - CI.getFileManager(), *CI.getPCHContainerOperations(), + CI.getFileManager(), CI.getPCHContainerReader(), CI.getPreprocessor().getHeaderSearchInfo().getModuleCachePath()); } diff --git a/contrib/llvm/tools/clang/lib/Frontend/FrontendActions.cpp b/contrib/llvm/tools/clang/lib/Frontend/FrontendActions.cpp index 4997764..40277bd 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/FrontendActions.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/FrontendActions.cpp @@ -93,7 +93,7 @@ GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { Consumers.push_back(llvm::make_unique<PCHGenerator>( CI.getPreprocessor(), OutputFile, nullptr, Sysroot, Buffer)); Consumers.push_back( - CI.getPCHContainerOperations()->CreatePCHContainerGenerator( + CI.getPCHContainerWriter().CreatePCHContainerGenerator( CI.getDiagnostics(), CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(), CI.getTargetOpts(), CI.getLangOpts(), InFile, OutputFile, OS, Buffer)); @@ -139,7 +139,7 @@ GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI, Consumers.push_back(llvm::make_unique<PCHGenerator>( CI.getPreprocessor(), OutputFile, Module, Sysroot, Buffer)); Consumers.push_back( - CI.getPCHContainerOperations()->CreatePCHContainerGenerator( + CI.getPCHContainerWriter().CreatePCHContainerGenerator( CI.getDiagnostics(), CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(), CI.getTargetOpts(), CI.getLangOpts(), InFile, OutputFile, OS, Buffer)); @@ -415,7 +415,7 @@ void VerifyPCHAction::ExecuteAction() { bool Preamble = CI.getPreprocessorOpts().PrecompiledPreambleBytes.first != 0; const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot; std::unique_ptr<ASTReader> Reader(new ASTReader( - CI.getPreprocessor(), CI.getASTContext(), *CI.getPCHContainerOperations(), + CI.getPreprocessor(), CI.getASTContext(), CI.getPCHContainerReader(), Sysroot.empty() ? "" : Sysroot.c_str(), /*DisableValidation*/ false, /*AllowPCHWithCompilerErrors*/ false, @@ -578,7 +578,7 @@ void DumpModuleInfoAction::ExecuteAction() { DumpModuleInfoListener Listener(Out); ASTReader::readASTFileControlBlock( getCurrentFile(), getCompilerInstance().getFileManager(), - *getCompilerInstance().getPCHContainerOperations(), Listener); + getCompilerInstance().getPCHContainerReader(), Listener); } //===----------------------------------------------------------------------===// diff --git a/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp b/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp index 025c8b9..0791494 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp @@ -97,11 +97,11 @@ static void AddImplicitIncludePTH(MacroBuilder &Builder, Preprocessor &PP, /// \brief Add an implicit \#include using the original file used to generate /// a PCH file. static void AddImplicitIncludePCH(MacroBuilder &Builder, Preprocessor &PP, - const PCHContainerOperations &PCHContainerOps, + const PCHContainerReader &PCHContainerRdr, StringRef ImplicitIncludePCH) { std::string OriginalFile = ASTReader::getOriginalSourceFile(ImplicitIncludePCH, PP.getFileManager(), - PCHContainerOps, PP.getDiagnostics()); + PCHContainerRdr, PP.getDiagnostics()); if (OriginalFile.empty()) return; @@ -902,7 +902,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI, /// void clang::InitializePreprocessor( Preprocessor &PP, const PreprocessorOptions &InitOpts, - const PCHContainerOperations &PCHContainerOps, + const PCHContainerReader &PCHContainerRdr, const FrontendOptions &FEOpts) { const LangOptions &LangOpts = PP.getLangOpts(); std::string PredefineBuffer; @@ -962,7 +962,7 @@ void clang::InitializePreprocessor( // Process -include-pch/-include-pth directives. if (!InitOpts.ImplicitPCHInclude.empty()) - AddImplicitIncludePCH(Builder, PP, PCHContainerOps, + AddImplicitIncludePCH(Builder, PP, PCHContainerRdr, InitOpts.ImplicitPCHInclude); if (!InitOpts.ImplicitPTHInclude.empty()) AddImplicitIncludePTH(Builder, PP, InitOpts.ImplicitPTHInclude); diff --git a/contrib/llvm/tools/clang/lib/Frontend/PCHContainerOperations.cpp b/contrib/llvm/tools/clang/lib/Frontend/PCHContainerOperations.cpp index c749bb5..cde3ba1 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/PCHContainerOperations.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/PCHContainerOperations.cpp @@ -21,21 +21,22 @@ using namespace clang; namespace { /// \brief A PCHContainerGenerator that writes out the PCH to a flat file. -class PCHContainerGenerator : public ASTConsumer { +class RawPCHContainerGenerator : public ASTConsumer { std::shared_ptr<PCHBuffer> Buffer; raw_pwrite_stream *OS; public: - PCHContainerGenerator(DiagnosticsEngine &Diags, - const HeaderSearchOptions &HSO, - const PreprocessorOptions &PPO, const TargetOptions &TO, - const LangOptions &LO, const std::string &MainFileName, - const std::string &OutputFileName, - llvm::raw_pwrite_stream *OS, - std::shared_ptr<PCHBuffer> Buffer) + RawPCHContainerGenerator(DiagnosticsEngine &Diags, + const HeaderSearchOptions &HSO, + const PreprocessorOptions &PPO, + const TargetOptions &TO, const LangOptions &LO, + const std::string &MainFileName, + const std::string &OutputFileName, + llvm::raw_pwrite_stream *OS, + std::shared_ptr<PCHBuffer> Buffer) : Buffer(Buffer), OS(OS) {} - virtual ~PCHContainerGenerator() {} + virtual ~RawPCHContainerGenerator() {} void HandleTranslationUnit(ASTContext &Ctx) override { if (Buffer->IsComplete) { @@ -50,19 +51,23 @@ public: }; } -std::unique_ptr<ASTConsumer> -RawPCHContainerOperations::CreatePCHContainerGenerator( +std::unique_ptr<ASTConsumer> RawPCHContainerWriter::CreatePCHContainerGenerator( DiagnosticsEngine &Diags, const HeaderSearchOptions &HSO, const PreprocessorOptions &PPO, const TargetOptions &TO, const LangOptions &LO, const std::string &MainFileName, const std::string &OutputFileName, llvm::raw_pwrite_stream *OS, std::shared_ptr<PCHBuffer> Buffer) const { - return llvm::make_unique<PCHContainerGenerator>( + return llvm::make_unique<RawPCHContainerGenerator>( Diags, HSO, PPO, TO, LO, MainFileName, OutputFileName, OS, Buffer); } -void RawPCHContainerOperations::ExtractPCH( +void RawPCHContainerReader::ExtractPCH( llvm::MemoryBufferRef Buffer, llvm::BitstreamReader &StreamFile) const { StreamFile.init((const unsigned char *)Buffer.getBufferStart(), (const unsigned char *)Buffer.getBufferEnd()); } + +PCHContainerOperations::PCHContainerOperations() { + registerWriter(llvm::make_unique<RawPCHContainerWriter>()); + registerReader(llvm::make_unique<RawPCHContainerReader>()); +} |