From bdabc2f19ffb9e20600dad6e8a300842a7bda50e Mon Sep 17 00:00:00 2001 From: patrick Date: Fri, 6 Apr 2018 14:26:03 +0000 Subject: Import LLVM 6.0.1 release including clang, lld and lldb. "where is the kaboom?" deraadt@ --- .../tools/clang/lib/Frontend/FrontendActions.cpp | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'gnu/llvm/tools/clang/lib/Frontend/FrontendActions.cpp') diff --git a/gnu/llvm/tools/clang/lib/Frontend/FrontendActions.cpp b/gnu/llvm/tools/clang/lib/Frontend/FrontendActions.cpp index d42400183a4..ffa5b410d2d 100644 --- a/gnu/llvm/tools/clang/lib/Frontend/FrontendActions.cpp +++ b/gnu/llvm/tools/clang/lib/Frontend/FrontendActions.cpp @@ -80,9 +80,12 @@ DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI, std::unique_ptr GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { std::string Sysroot; + if (!ComputeASTConsumerArguments(CI, /*ref*/ Sysroot)) + return nullptr; + std::string OutputFile; std::unique_ptr OS = - ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile); + CreateOutputFile(CI, InFile, /*ref*/ OutputFile); if (!OS) return nullptr; @@ -103,17 +106,20 @@ GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { return llvm::make_unique(std::move(Consumers)); } -std::unique_ptr -GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI, - StringRef InFile, - std::string &Sysroot, - std::string &OutputFile) { +bool GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance &CI, + std::string &Sysroot) { Sysroot = CI.getHeaderSearchOpts().Sysroot; if (CI.getFrontendOpts().RelocatablePCH && Sysroot.empty()) { CI.getDiagnostics().Report(diag::err_relocatable_without_isysroot); - return nullptr; + return false; } + return true; +} + +std::unique_ptr +GeneratePCHAction::CreateOutputFile(CompilerInstance &CI, StringRef InFile, + std::string &OutputFile) { // We use createOutputFile here because this is exposed via libclang, and we // must disable the RemoveFileOnSignal behavior. // We use a temporary to avoid race conditions. @@ -185,8 +191,8 @@ GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI, HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo(); CI.getFrontendOpts().OutputFile = - HS.getModuleFileName(CI.getLangOpts().CurrentModule, ModuleMapFile, - /*UsePrebuiltPath=*/false); + HS.getCachedModuleFileName(CI.getLangOpts().CurrentModule, + ModuleMapFile); } // We use createOutputFile here because this is exposed via libclang, and we @@ -591,7 +597,7 @@ void PrintPreambleAction::ExecuteAction() { auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile()); if (Buffer) { unsigned Preamble = - Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).first; + Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size; llvm::outs().write((*Buffer)->getBufferStart(), Preamble); } } -- cgit v1.2.3-59-g8ed1b