[lld] r284694 - Split LinkerDriver::createFiles. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 21:47:47 PDT 2016


Author: ruiu
Date: Wed Oct 19 23:47:47 2016
New Revision: 284694

URL: http://llvm.org/viewvc/llvm-project?rev=284694&view=rev
Log:
Split LinkerDriver::createFiles. NFC.

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Driver.h

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=284694&r1=284693&r2=284694&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Wed Oct 19 23:47:47 2016
@@ -306,6 +306,7 @@ void LinkerDriver::main(ArrayRef<const c
   readConfigs(Args);
   initLLVM(Args);
   createFiles(Args);
+  inferMachineType();
   checkOptions(Args);
   if (HasError)
     return;
@@ -324,7 +325,7 @@ void LinkerDriver::main(ArrayRef<const c
     link<ELF64BE>(Args);
     return;
   default:
-    error("target emulation unknown: -m or at least one .o file required");
+    llvm_unreachable("unknown Config->EKind");
   }
 }
 
@@ -636,17 +637,21 @@ void LinkerDriver::createFiles(opt::Inpu
 
   if (Files.empty() && !HasError)
     error("no input files");
+}
 
-  // If -m <machine_type> was not given, infer it from object files.
-  if (Config->EKind == ELFNoneKind) {
-    for (InputFile *F : Files) {
-      if (F->EKind == ELFNoneKind)
-        continue;
-      Config->EKind = F->EKind;
-      Config->EMachine = F->EMachine;
-      break;
-    }
+// If -m <machine_type> was not given, infer it from object files.
+void LinkerDriver::inferMachineType() {
+  if (Config->EKind != ELFNoneKind)
+    return;
+
+  for (InputFile *F : Files) {
+    if (F->EKind == ELFNoneKind)
+      continue;
+    Config->EKind = F->EKind;
+    Config->EMachine = F->EMachine;
+    return;
   }
+  error("target emulation unknown: -m or at least one .o file required");
 }
 
 // Do actual linking. Note that when this function is called,

Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=284694&r1=284693&r2=284694&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Wed Oct 19 23:47:47 2016
@@ -38,6 +38,7 @@ private:
   llvm::Optional<MemoryBufferRef> readFile(StringRef Path);
   void readConfigs(llvm::opt::InputArgList &Args);
   void createFiles(llvm::opt::InputArgList &Args);
+  void inferMachineType();
   template <class ELFT> void link(llvm::opt::InputArgList &Args);
 
   // True if we are in --whole-archive and --no-whole-archive.




More information about the llvm-commits mailing list