[lld] r296224 - Factor out code to parse -L and -rpath.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 24 17:51:44 PST 2017


Author: ruiu
Date: Fri Feb 24 19:51:44 2017
New Revision: 296224

URL: http://llvm.org/viewvc/llvm-project?rev=296224&view=rev
Log:
Factor out code to parse -L and -rpath.

Modified:
    lld/trunk/ELF/Driver.cpp

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=296224&r1=296223&r2=296224&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Feb 24 19:51:44 2017
@@ -354,6 +354,20 @@ static bool getArg(opt::InputArgList &Ar
   return Default;
 }
 
+static std::vector<StringRef> getSearchPaths(opt::InputArgList &Args) {
+  std::vector<StringRef> V;
+  for (auto *Arg : Args.filtered(OPT_L))
+    V.push_back(Arg->getValue());
+  return V;
+}
+
+static std::string getRPath(opt::InputArgList &Args) {
+  std::vector<StringRef> V;
+  for (auto *Arg : Args.filtered(OPT_rpath))
+    V.push_back(Arg->getValue());
+  return llvm::join(V.begin(), V.end(), ":");
+}
+
 // Determines what we should do if there are remaining unresolved
 // symbols after the name resolution.
 static UnresolvedPolicy getUnresolvedSymbolPolicy(opt::InputArgList &Args) {
@@ -541,8 +555,10 @@ void LinkerDriver::readConfigs(opt::Inpu
   Config->OutputFile = getString(Args, OPT_o);
   Config->Pie = getArg(Args, OPT_pie, OPT_nopie, false);
   Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
+  Config->RPath = getRPath(Args);
   Config->Relocatable = Args.hasArg(OPT_relocatable);
   Config->SaveTemps = Args.hasArg(OPT_save_temps);
+  Config->SearchPaths = getSearchPaths(Args);
   Config->SectionStartMap = getSectionStartMap(Args);
   Config->Shared = Args.hasArg(OPT_shared);
   Config->SingleRoRx = Args.hasArg(OPT_no_rosegment);
@@ -574,15 +590,6 @@ void LinkerDriver::readConfigs(opt::Inpu
   if (Config->ThinLTOJobs == 0)
     error("--thinlto-jobs: number of threads must be > 0");
 
-  for (auto *Arg : Args.filtered(OPT_L))
-    Config->SearchPaths.push_back(Arg->getValue());
-
-  std::vector<StringRef> RPaths;
-  for (auto *Arg : Args.filtered(OPT_rpath))
-    RPaths.push_back(Arg->getValue());
-  if (!RPaths.empty())
-    Config->RPath = llvm::join(RPaths.begin(), RPaths.end(), ":");
-
   if (auto *Arg = Args.getLastArg(OPT_m)) {
     // Parse ELF{32,64}{LE,BE} and CPU type.
     StringRef S = Arg->getValue();




More information about the llvm-commits mailing list