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 /llvm/lib/LTO/LTO.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 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index e8f0fd6..5d03be1 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -513,7 +513,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms, assert(!GlobalRes.Prevailing && "Multiple prevailing defs are not allowed"); GlobalRes.Prevailing = true; - GlobalRes.IRName = Sym.getIRName(); + GlobalRes.IRName = std::string(Sym.getIRName()); } else if (!GlobalRes.Prevailing && GlobalRes.IRName.empty()) { // Sometimes it can be two copies of symbol in a module and prevailing // symbol can have no IR name. That might happen if symbol is defined in @@ -521,7 +521,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms, // the same symbol we want to use IR name of the prevailing symbol. // Otherwise, if we haven't seen a prevailing symbol, set the name so that // we can later use it to check if there is any prevailing copy in IR. - GlobalRes.IRName = Sym.getIRName(); + GlobalRes.IRName = std::string(Sym.getIRName()); } // Set the partition to external if we know it is re-defined by the linker @@ -762,7 +762,7 @@ LTO::addRegularLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms, if (Sym.isCommon()) { // FIXME: We should figure out what to do about commons defined by asm. // For now they aren't reported correctly by ModuleSymbolTable. - auto &CommonRes = RegularLTO.Commons[Sym.getIRName()]; + auto &CommonRes = RegularLTO.Commons[std::string(Sym.getIRName())]; CommonRes.Size = std::max(CommonRes.Size, Sym.getCommonSize()); CommonRes.Align = std::max(CommonRes.Align, MaybeAlign(Sym.getCommonAlignment())); @@ -1191,7 +1191,7 @@ std::string lto::getThinLTOOutputFile(const std::string &Path, llvm::errs() << "warning: could not create directory '" << ParentPath << "': " << EC.message() << '\n'; } - return NewPath.str(); + return std::string(NewPath.str()); } namespace { @@ -1220,7 +1220,7 @@ public: MapVector<StringRef, BitcodeModule> &ModuleMap) override { StringRef ModulePath = BM.getModuleIdentifier(); std::string NewModulePath = - getThinLTOOutputFile(ModulePath, OldPrefix, NewPrefix); + getThinLTOOutputFile(std::string(ModulePath), OldPrefix, NewPrefix); if (LinkedObjectsFile) *LinkedObjectsFile << NewModulePath << '\n'; @@ -1244,7 +1244,7 @@ public: } if (OnWrite) - OnWrite(ModulePath); + OnWrite(std::string(ModulePath)); return Error::success(); } @@ -1391,7 +1391,7 @@ Expected<std::unique_ptr<ToolOutputFile>> lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename, StringRef RemarksPasses, StringRef RemarksFormat, bool RemarksWithHotness, int Count) { - std::string Filename = RemarksFilename; + std::string Filename = std::string(RemarksFilename); // For ThinLTO, file.opt.<format> becomes // file.opt.<format>.thin.<num>.<format>. if (!Filename.empty() && Count != -1) |