[lld] r329060 - [ELF] - Simplify createFiles. NFCI.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 3 05:06:29 PDT 2018


Author: grimar
Date: Tue Apr  3 05:06:29 2018
New Revision: 329060

URL: http://llvm.org/viewvc/llvm-project?rev=329060&view=rev
Log:
[ELF] - Simplify createFiles. NFCI.

Groups paired options together.

Differential revision: https://reviews.llvm.org/D45090

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=329060&r1=329059&r2=329060&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Apr  3 05:06:29 2018
@@ -879,7 +879,8 @@ static bool getBinaryOption(StringRef S)
 
 void LinkerDriver::createFiles(opt::InputArgList &Args) {
   for (auto *Arg : Args) {
-    switch (Arg->getOption().getUnaliasedOption().getID()) {
+    unsigned ID = Arg->getOption().getUnaliasedOption().getID();
+    switch (ID) {
     case OPT_library:
       addLibrary(Arg->getValue());
       break;
@@ -902,25 +903,19 @@ void LinkerDriver::createFiles(opt::Inpu
       error(Twine("cannot find linker script ") + Arg->getValue());
       break;
     case OPT_as_needed:
-      Config->AsNeeded = true;
+    case OPT_no_as_needed:
+      Config->AsNeeded = (ID == OPT_as_needed);
       break;
     case OPT_format:
       InBinary = getBinaryOption(Arg->getValue());
       break;
-    case OPT_no_as_needed:
-      Config->AsNeeded = false;
-      break;
     case OPT_Bstatic:
-      Config->Static = true;
-      break;
     case OPT_Bdynamic:
-      Config->Static = false;
+      Config->Static = (ID == OPT_Bstatic);
       break;
     case OPT_whole_archive:
-      InWholeArchive = true;
-      break;
     case OPT_no_whole_archive:
-      InWholeArchive = false;
+      InWholeArchive = (ID == OPT_whole_archive);
       break;
     case OPT_just_symbols:
       if (Optional<MemoryBufferRef> MB = readFile(Arg->getValue())) {
@@ -929,10 +924,8 @@ void LinkerDriver::createFiles(opt::Inpu
       }
       break;
     case OPT_start_lib:
-      InLib = true;
-      break;
     case OPT_end_lib:
-      InLib = false;
+      InLib = (ID == OPT_start_lib);
       break;
     }
   }




More information about the llvm-commits mailing list