[llvm] r310652 - [gold-plugin] Use more StringRef. No functionality change intended.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 10 12:28:01 PDT 2017


Author: d0k
Date: Thu Aug 10 12:28:00 2017
New Revision: 310652

URL: http://llvm.org/viewvc/llvm-project?rev=310652&view=rev
Log:
[gold-plugin] Use more StringRef. No functionality change intended.

Modified:
    llvm/trunk/tools/gold/gold-plugin.cpp

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=310652&r1=310651&r2=310652&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Thu Aug 10 12:28:00 2017
@@ -587,22 +587,20 @@ static void getThinLTOOldAndNewSuffix(st
   assert(options::thinlto_object_suffix_replace.empty() ||
          options::thinlto_object_suffix_replace.find(";") != StringRef::npos);
   StringRef SuffixReplace = options::thinlto_object_suffix_replace;
-  std::pair<StringRef, StringRef> 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_
         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(st
                                       std::string &NewPrefix) {
   StringRef PrefixReplace = options::thinlto_prefix_replace;
   assert(PrefixReplace.empty() || PrefixReplace.find(";") != StringRef::npos);
-  std::pair<StringRef, StringRef> Split = PrefixReplace.split(";");
-  OldPrefix = Split.first.str();
-  NewPrefix = Split.second.str();
+  std::tie(OldPrefix, NewPrefix) = PrefixReplace.split(';');
 }
 
 static std::unique_ptr<LTO> createLTO() {




More information about the llvm-commits mailing list