From e5d9cb587c3d2bd38ea431b481589667bad67d79 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 10 Aug 2017 19:28:00 +0000 Subject: [PATCH] [gold-plugin] Use more StringRef. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310652 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/gold/gold-plugin.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 3123cde7950..4d4ff195364 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -587,22 +587,20 @@ static void getThinLTOOldAndNewSuffix(std::string &OldSuffix, assert(options::thinlto_object_suffix_replace.empty() || options::thinlto_object_suffix_replace.find(";") != StringRef::npos); StringRef SuffixReplace = options::thinlto_object_suffix_replace; - std::pair Split = SuffixReplace.split(";"); - OldSuffix = Split.first.str(); - NewSuffix = Split.second.str(); + std::tie(OldSuffix, NewSuffix) = SuffixReplace.split(';'); } /// Given the original \p Path to an output file, replace any filename /// suffix matching \p OldSuffix with \p NewSuffix. -static std::string getThinLTOObjectFileName(const std::string Path, - const std::string &OldSuffix, - const std::string &NewSuffix) { +static std::string getThinLTOObjectFileName(StringRef Path, StringRef OldSuffix, + StringRef NewSuffix) { if (OldSuffix.empty() && NewSuffix.empty()) return Path; StringRef NewPath = Path; NewPath.consume_back(OldSuffix); - std::string NewNewPath = NewPath.str() + NewSuffix; - return NewPath.str() + NewSuffix; + std::string NewNewPath = NewPath; + NewNewPath += NewSuffix; + return NewNewPath; } static bool isAlpha(char C) { @@ -687,19 +685,19 @@ static void addModule(LTO &Lto, claimed_file &F, const void *View, std::string("Failed to link module ") + F.name); } -static void recordFile(std::string Filename, bool TempOutFile) { +static void recordFile(const std::string &Filename, bool TempOutFile) { if (add_input_file(Filename.c_str()) != LDPS_OK) message(LDPL_FATAL, "Unable to add .o file to the link. File left behind in: %s", Filename.c_str()); if (TempOutFile) - Cleanup.push_back(Filename.c_str()); + Cleanup.push_back(Filename); } /// Return the desired output filename given a base input name, a flag /// indicating whether a temp file should be generated, and an optional task id. /// The new filename generated is returned in \p NewFilename. -static int getOutputFileName(SmallString<128> InFilename, bool TempOutFile, +static int getOutputFileName(StringRef InFilename, bool TempOutFile, SmallString<128> &NewFilename, int TaskID) { int FD = -1; if (TempOutFile) { @@ -741,9 +739,7 @@ static void getThinLTOOldAndNewPrefix(std::string &OldPrefix, std::string &NewPrefix) { StringRef PrefixReplace = options::thinlto_prefix_replace; assert(PrefixReplace.empty() || PrefixReplace.find(";") != StringRef::npos); - std::pair Split = PrefixReplace.split(";"); - OldPrefix = Split.first.str(); - NewPrefix = Split.second.str(); + std::tie(OldPrefix, NewPrefix) = PrefixReplace.split(';'); } static std::unique_ptr createLTO() { -- 2.40.0