[lld] r254032 - ELF2: Factor out isUnderSysroot from readLinkerScript. NFC.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 24 14:26:33 PST 2015


Author: ruiu
Date: Tue Nov 24 16:26:33 2015
New Revision: 254032

URL: http://llvm.org/viewvc/llvm-project?rev=254032&view=rev
Log:
ELF2: Factor out isUnderSysroot from readLinkerScript. NFC.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=254032&r1=254031&r2=254032&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Nov 24 16:26:33 2015
@@ -297,14 +297,17 @@ void LinkerScript::readOutputSectionDesc
   }
 }
 
+static bool isUnderSysroot(StringRef Path) {
+  if (Config->Sysroot == "")
+    return false;
+  for (; !Path.empty(); Path = sys::path::parent_path(Path))
+    if (sys::fs::equivalent(Config->Sysroot, Path))
+      return true;
+  return false;
+}
+
 // Entry point. The other functions or classes are private to this file.
 void lld::elf2::readLinkerScript(BumpPtrAllocator *A, MemoryBufferRef MB) {
   StringRef Path = MB.getBufferIdentifier();
-  if (!Config->Sysroot.empty())
-    for (; !Path.empty(); Path = sys::path::parent_path(Path))
-      if (sys::fs::equivalent(Config->Sysroot, Path)) {
-        LinkerScript(A, MB.getBuffer(), true).run();
-        return;
-      }
-  LinkerScript(A, MB.getBuffer(), false).run();
+  LinkerScript(A, MB.getBuffer(), isUnderSysroot(Path)).run();
 }




More information about the llvm-commits mailing list