diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 688f21dd0908b..4613ed8d7f61f 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -97,6 +97,10 @@ void CompilerInstance::setVerboseOutputStream(std::unique_ptr<raw_ostream> Value void CompilerInstance::setTarget(TargetInfo *Value) { Target = Value; } void CompilerInstance::setAuxTarget(TargetInfo *Value) { AuxTarget = Value; } +llvm::vfs::FileSystem &CompilerInstance::getVirtualFileSystem() const { + return getFileManager().getVirtualFileSystem(); +} + void CompilerInstance::setFileManager(FileManager *Value) { FileMgr = Value; } @@ -138,7 +142,7 @@ std::unique_ptr<Sema> CompilerInstance::takeSema() { IntrusiveRefCntPtr<ASTReader> CompilerInstance::getASTReader() const { return TheASTReader; } -void CompilerInstance::setModuleManager(IntrusiveRefCntPtr<ASTReader> Reader) { +void CompilerInstance::setASTReader(IntrusiveRefCntPtr<ASTReader> Reader) { assert(ModuleCache.get() == &Reader->getModuleManager().getModuleCache() && "Expected ASTReader to use the same PCM cache"); TheASTReader = std::move(Reader); @@ -379,7 +383,7 @@ static void InitializeFileRemapping(DiagnosticsEngine &Diags, void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) { const PreprocessorOptions &PPOpts = getPreprocessorOpts(); - // The module manager holds a reference to the old preprocessor (if any). + // The AST reader holds a reference to the old preprocessor (if any). TheASTReader.reset(); // Create the Preprocessor. @@ -474,7 +478,7 @@ std::string CompilerInstance::getSpecificModuleCachePath() { if (!SpecificModuleCache.empty() && !getHeaderSearchOpts().DisableModuleHash) llvm::sys::path::append(SpecificModuleCache, getInvocation().getModuleHash()); - return SpecificModuleCache.str(); + return std::string(SpecificModuleCache.str()); } // ASTContext @@ -713,13 +717,13 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile( std::string OutFile, TempFile; if (!OutputPath.empty()) { - OutFile = OutputPath; + OutFile = std::string(OutputPath); } else if (InFile == "-") { OutFile = "-"; } else if (!Extension.empty()) { SmallString<128> Path(InFile); llvm::sys::path::replace_extension(Path, Extension); - OutFile = Path.str(); + OutFile = std::string(Path.str()); } else { OutFile = "-"; } @@ -774,7 +778,7 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile( if (!EC) { OS.reset(new llvm::raw_fd_ostream(fd, /*shouldClose=*/true)); - OSFile = TempFile = TempPath.str(); + OSFile = TempFile = std::string(TempPath.str()); } // If we failed to create the temporary, fallback to writing to the file // directly. This handles the corner case where we cannot write to the @@ -811,17 +815,15 @@ std::unique_ptr<llvm::raw_pwrite_stream> CompilerInstance::createOutputFile( // Initialization Utilities bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input){ - return InitializeSourceManager( - Input, getDiagnostics(), getFileManager(), getSourceManager(), - hasPreprocessor() ? &getPreprocessor().getHeaderSearchInfo() : nullptr, - getDependencyOutputOpts(), getFrontendOpts()); + return InitializeSourceManager(Input, getDiagnostics(), getFileManager(), + getSourceManager()); } // static -bool CompilerInstance::InitializeSourceManager( - const FrontendInputFile &Input, DiagnosticsEngine &Diags, - FileManager &FileMgr, SourceManager &SourceMgr, HeaderSearch *HS, - DependencyOutputOptions &DepOpts, const FrontendOptions &Opts) { +bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, + DiagnosticsEngine &Diags, + FileManager &FileMgr, + SourceManager &SourceMgr) { SrcMgr::CharacteristicKind Kind = Input.getKind().getFormat() == InputKind::ModuleMap ? Input.isSystem() ? SrcMgr::C_System_ModuleMap @@ -923,10 +925,27 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { !getFrontendOpts().AuxTriple.empty()) { auto TO = std::make_shared<TargetOptions>(); TO->Triple = llvm::Triple::normalize(getFrontendOpts().AuxTriple); + if (getFrontendOpts().AuxTargetCPU) + TO->CPU = getFrontendOpts().AuxTargetCPU.getValue(); + if (getFrontendOpts().AuxTargetFeatures) + TO->FeaturesAsWritten = getFrontendOpts().AuxTargetFeatures.getValue(); TO->HostTriple = getTarget().getTriple().str(); setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO)); } + if (!getTarget().hasStrictFP() && !getLangOpts().ExpStrictFP) { + if (getLangOpts().getFPRoundingMode() != + llvm::RoundingMode::NearestTiesToEven) { + getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_rounding); + getLangOpts().setFPRoundingMode(llvm::RoundingMode::NearestTiesToEven); + } + if (getLangOpts().getFPExceptionMode() != LangOptions::FPE_Ignore) { + getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_exceptions); + getLangOpts().setFPExceptionMode(LangOptions::FPE_Ignore); + } + // FIXME: can we disable FEnvAccess? + } + // Inform the target of the language options. // // FIXME: We shouldn't need to do this, the target should be immutable once @@ -1073,7 +1092,7 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc, ImportingInstance.getInvocation().getLangOpts()->ModuleName; // Note the name of the module we're building. - Invocation->getLangOpts()->CurrentModule = ModuleName; + Invocation->getLangOpts()->CurrentModule = std::string(ModuleName); // Make sure that the failed-module structure has been allocated in // the importing instance, and propagate the pointer to the newly-created @@ -1093,7 +1112,7 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc, FrontendOpts.DisableFree = false; FrontendOpts.GenerateGlobalModuleIndex = false; FrontendOpts.BuildingImplicitModule = true; - FrontendOpts.OriginalModuleMap = OriginalModuleMapFile; + FrontendOpts.OriginalModuleMap = std::string(OriginalModuleMapFile); // Force implicitly-built modules to hash the content of the module file. HSOpts.ModulesHashContent = true; FrontendOpts.Inputs = {Input}; @@ -1568,7 +1587,7 @@ bool CompilerInstance::loadModuleFile(StringRef FileName) { Stack.push_back(M); while (!Stack.empty()) { Module *Current = Stack.pop_back_val(); - if (Current->IsMissingRequirement) continue; + if (Current->IsUnimportable) continue; Current->IsAvailable = true; Stack.insert(Stack.end(), Current->submodule_begin(), Current->submodule_end()); @@ -1630,10 +1649,10 @@ enum ModuleSource { /// Select a source for loading the named module and compute the filename to /// load it from. -static ModuleSource -selectModuleSource(Module *M, StringRef ModuleName, std::string &ModuleFilename, - const std::map<std::string, std::string> &BuiltModules, - HeaderSearch &HS) { +static ModuleSource selectModuleSource( + Module *M, StringRef ModuleName, std::string &ModuleFilename, + const std::map<std::string, std::string, std::less<>> &BuiltModules, + HeaderSearch &HS) { assert(ModuleFilename.empty() && "Already has a module source?"); // Check to see if the module has been built as part of this compilation @@ -2077,7 +2096,7 @@ void CompilerInstance::createModuleFromSource(SourceLocation ImportLoc, // Build the module, inheriting any modules that we've built locally. if (compileModuleImpl(*this, ImportLoc, ModuleName, Input, StringRef(), ModuleFileName, PreBuildStep, PostBuildStep)) { - BuiltModules[ModuleName] = ModuleFileName.str(); + BuiltModules[std::string(ModuleName)] = std::string(ModuleFileName.str()); llvm::sys::RemoveFileOnSignal(ModuleFileName); } } |