diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp b/contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp index ac9f8f8ed51c..92e0b74e38f0 100644 --- a/contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp +++ b/contrib/llvm-project/clang/lib/Frontend/CompilerInstance.cpp @@ -46,7 +46,6 @@ #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/Host.h" #include "llvm/Support/LockFileManager.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -55,6 +54,7 @@ #include "llvm/Support/TimeProfiler.h" #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/TargetParser/Host.h" #include <optional> #include <time.h> #include <utility> @@ -113,7 +113,7 @@ bool CompilerInstance::createTarget() { // Check whether AuxTarget exists, if not, then create TargetInfo for the // other side of CUDA/OpenMP/SYCL compilation. if (!getAuxTarget() && - (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice || + (getLangOpts().CUDA || getLangOpts().OpenMPIsTargetDevice || getLangOpts().SYCLIsDevice) && !getFrontendOpts().AuxTriple.empty()) { auto TO = std::make_shared<TargetOptions>(); @@ -605,8 +605,9 @@ struct ReadModuleNames : ASTReaderListener { Module *Current = Stack.pop_back_val(); if (Current->IsUnimportable) continue; Current->IsAvailable = true; - Stack.insert(Stack.end(), - Current->submodule_begin(), Current->submodule_end()); + auto SubmodulesRange = Current->submodules(); + Stack.insert(Stack.end(), SubmodulesRange.begin(), + SubmodulesRange.end()); } } } @@ -851,6 +852,9 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary, // relative to that. std::optional<SmallString<128>> AbsPath; if (OutputPath != "-" && !llvm::sys::path::is_absolute(OutputPath)) { + assert(hasFileManager() && + "File Manager is required to fix up relative path.\n"); + AbsPath.emplace(OutputPath); FileMgr->FixupRelativePath(*AbsPath); OutputPath = *AbsPath; @@ -891,10 +895,12 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary, TempPath += "-%%%%%%%%"; TempPath += OutputExtension; TempPath += ".tmp"; + llvm::sys::fs::OpenFlags BinaryFlags = + Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text; Expected<llvm::sys::fs::TempFile> ExpectedFile = llvm::sys::fs::TempFile::create( TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write, - Binary ? llvm::sys::fs::OF_None : llvm::sys::fs::OF_Text); + BinaryFlags); llvm::Error E = handleErrors( ExpectedFile.takeError(), [&](const llvm::ECError &E) -> llvm::Error { @@ -904,7 +910,9 @@ CompilerInstance::createOutputFileImpl(StringRef OutputPath, bool Binary, StringRef Parent = llvm::sys::path::parent_path(OutputPath); EC = llvm::sys::fs::create_directories(Parent); if (!EC) { - ExpectedFile = llvm::sys::fs::TempFile::create(TempPath); + ExpectedFile = llvm::sys::fs::TempFile::create( + TempPath, llvm::sys::fs::all_read | llvm::sys::fs::all_write, + BinaryFlags); if (!ExpectedFile) return llvm::errorCodeToError( llvm::errc::no_such_file_or_directory); @@ -978,10 +986,9 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, ? FileMgr.getSTDIN() : FileMgr.getFileRef(InputFile, /*OpenFile=*/true); if (!FileOrErr) { - // FIXME: include the error in the diagnostic even when it's not stdin. auto EC = llvm::errorToErrorCode(FileOrErr.takeError()); if (InputFile != "-") - Diags.Report(diag::err_fe_error_reading) << InputFile; + Diags.Report(diag::err_fe_error_reading) << InputFile << EC.message(); else Diags.Report(diag::err_fe_error_reading_stdin) << EC.message(); return false; @@ -1084,9 +1091,12 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { } StringRef StatsFile = getFrontendOpts().StatsFile; if (!StatsFile.empty()) { + llvm::sys::fs::OpenFlags FileFlags = llvm::sys::fs::OF_TextWithCRLF; + if (getFrontendOpts().AppendStats) + FileFlags |= llvm::sys::fs::OF_Append; std::error_code EC; - auto StatS = std::make_unique<llvm::raw_fd_ostream>( - StatsFile, EC, llvm::sys::fs::OF_TextWithCRLF); + auto StatS = + std::make_unique<llvm::raw_fd_ostream>(StatsFile, EC, FileFlags); if (EC) { getDiagnostics().Report(diag::warn_fe_unable_to_open_stats_file) << StatsFile << EC.message(); @@ -2021,8 +2031,12 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID()); PrivPath.push_back(std::make_pair(&II, Path[0].second)); + std::string FileName; + // If there is a modulemap module or prebuilt module, load it. if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, true, - !IsInclusionDirective)) + !IsInclusionDirective) || + selectModuleSource(nullptr, PrivateModule, FileName, BuiltModules, + PP->getHeaderSearchInfo()) != MS_ModuleNotFound) Sub = loadModule(ImportLoc, PrivPath, Visibility, IsInclusionDirective); if (Sub) { MapPrivateSubModToTopLevel = true; |