diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2020-01-28 20:23:46 +0100 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2020-01-28 23:25:25 +0100 |
commit | adcd02683856c30ba6f349279509acecd90063df (patch) | |
tree | 7b5927ef2ecab1618842183fac5ebe848f5832dd /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 5eaf44f99f0a0a3bdfa892892b8aaca841c8dbe0 (diff) | |
download | llvm-adcd02683856c30ba6f349279509acecd90063df.zip llvm-adcd02683856c30ba6f349279509acecd90063df.tar.gz llvm-adcd02683856c30ba6f349279509acecd90063df.tar.bz2 |
Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.
This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.
This doesn't actually modify StringRef yet, I'll do that in a follow-up.
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 688f21d..0715232 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -474,7 +474,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 +713,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 +774,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 @@ -1073,7 +1073,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 +1093,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}; @@ -1638,7 +1638,7 @@ selectModuleSource(Module *M, StringRef ModuleName, std::string &ModuleFilename, // Check to see if the module has been built as part of this compilation // via a module build pragma. - auto BuiltModuleIt = BuiltModules.find(ModuleName); + auto BuiltModuleIt = BuiltModules.find(std::string(ModuleName)); if (BuiltModuleIt != BuiltModules.end()) { ModuleFilename = BuiltModuleIt->second; return MS_ModuleBuildPragma; @@ -2077,7 +2077,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); } } |