<p dir="ltr">Thanks!</p>
<div class="gmail_quote">On Jun 7, 2016 2:16 PM, "Rui Ueyama via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Tue Jun  7 13:10:12 2016<br>
New Revision: 272034<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=272034&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=272034&view=rev</a><br>
Log:<br>
Define a helper function to get a relocation name. NFC.<br>
<br>
Modified:<br>
    lld/trunk/ELF/Target.cpp<br>
<br>
Modified: lld/trunk/ELF/Target.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=272034&r1=272033&r2=272034&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=272034&r1=272033&r2=272034&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/Target.cpp (original)<br>
+++ lld/trunk/ELF/Target.cpp Tue Jun  7 13:10:12 2016<br>
@@ -47,36 +47,36 @@ TargetInfo *Target;<br>
<br>
 static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); }<br>
<br>
+static StringRef getRelName(uint32_t Type) {<br>
+  return getELFRelocationTypeName(Config->EMachine, Type);<br>
+}<br>
+<br>
 template <unsigned N> static void checkInt(int64_t V, uint32_t Type) {<br>
   if (isInt<N>(V))<br>
     return;<br>
-  StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
-  error("relocation " + S + " out of range");<br>
+  error("relocation " + getRelName(Type) + " out of range");<br>
 }<br>
<br>
 template <unsigned N> static void checkUInt(uint64_t V, uint32_t Type) {<br>
   if (isUInt<N>(V))<br>
     return;<br>
-  StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
-  error("relocation " + S + " out of range");<br>
+  error("relocation " + getRelName(Type) + " out of range");<br>
 }<br>
<br>
 template <unsigned N> static void checkIntUInt(uint64_t V, uint32_t Type) {<br>
   if (isInt<N>(V) || isUInt<N>(V))<br>
     return;<br>
-  StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
-  error("relocation " + S + " out of range");<br>
+  error("relocation " + getRelName(Type) + " out of range");<br>
 }<br>
<br>
 template <unsigned N> static void checkAlignment(uint64_t V, uint32_t Type) {<br>
   if ((V & (N - 1)) == 0)<br>
     return;<br>
-  StringRef S = getELFRelocationTypeName(Config->EMachine, Type);<br>
-  error("improper alignment for relocation " + S);<br>
+  error("improper alignment for relocation " + getRelName(Type));<br>
 }<br>
<br>
 static void warnDynRel(uint32_t Type) {<br>
-  error("relocation " + getELFRelocationTypeName(Config->EMachine, Type) +<br>
+  error("relocation " + getRelName(Type) +<br>
         " cannot be used when making a shared object; recompile with -fPIC.");<br>
 }<br>
<br>
@@ -617,10 +617,8 @@ void X86_64TargetInfo::writePlt(uint8_t<br>
 }<br>
<br>
 uint32_t X86_64TargetInfo::getDynRel(uint32_t Type) const {<br>
-  if (Type == R_X86_64_PC32 || Type == R_X86_64_32)<br>
-    if (Config->Shared)<br>
-      error(getELFRelocationTypeName(EM_X86_64, Type) +<br>
-            " cannot be a dynamic relocation");<br>
+  if (Config->Shared && (Type == R_X86_64_PC32 || Type == R_X86_64_32))<br>
+    error(getRelName(Type) + " cannot be a dynamic relocation");<br>
   return Type;<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>