[lld] r290215 - Move a function defintion to make it static.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 16:05:40 PST 2016


Author: ruiu
Date: Tue Dec 20 18:05:39 2016
New Revision: 290215

URL: http://llvm.org/viewvc/llvm-project?rev=290215&view=rev
Log:
Move a function defintion to make it static.

Modified:
    lld/trunk/ELF/Target.cpp
    lld/trunk/ELF/Writer.cpp
    lld/trunk/ELF/Writer.h

Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=290215&r1=290214&r2=290215&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Tue Dec 20 18:05:39 2016
@@ -29,6 +29,7 @@
 #include "InputFiles.h"
 #include "Memory.h"
 #include "OutputSections.h"
+#include "SymbolTable.h"
 #include "Symbols.h"
 #include "SyntheticSections.h"
 #include "Thunks.h"
@@ -55,6 +56,34 @@ std::string toString(uint32_t Type) {
   return getELFRelocationTypeName(Config->EMachine, Type);
 }
 
+template <class ELFT> static std::string getErrorLoc(uint8_t *Loc) {
+  for (InputSectionData *D : Symtab<ELFT>::X->Sections) {
+    auto *IS = dyn_cast_or_null<InputSection<ELFT>>(D);
+    if (!IS || !IS->OutSec)
+      continue;
+
+    uint8_t *ISLoc = cast<OutputSection<ELFT>>(IS->OutSec)->Loc + IS->OutSecOff;
+    if (ISLoc <= Loc && Loc < ISLoc + IS->getSize())
+      return IS->getLocation(Loc - ISLoc) + ": ";
+  }
+  return "";
+}
+
+static std::string getErrorLocation(uint8_t *Loc) {
+  switch (Config->EKind) {
+  case ELF32LEKind:
+    return getErrorLoc<ELF32LE>(Loc);
+  case ELF32BEKind:
+    return getErrorLoc<ELF32BE>(Loc);
+  case ELF64LEKind:
+    return getErrorLoc<ELF64LE>(Loc);
+  case ELF64BEKind:
+    return getErrorLoc<ELF64BE>(Loc);
+  default:
+    llvm_unreachable("unknown ELF type");
+  }
+}
+
 template <unsigned N>
 static void checkInt(uint8_t *Loc, int64_t V, uint32_t Type) {
   if (!isInt<N>(V))

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=290215&r1=290214&r2=290215&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Dec 20 18:05:39 2016
@@ -1697,34 +1697,6 @@ template <class ELFT> void Writer<ELFT>:
   In<ELFT>::BuildId->writeBuildId({Start, End});
 }
 
-template <class ELFT> static std::string getErrorLoc(uint8_t *Loc) {
-  for (InputSectionData *D : Symtab<ELFT>::X->Sections) {
-    auto *IS = dyn_cast_or_null<InputSection<ELFT>>(D);
-    if (!IS || !IS->OutSec)
-      continue;
-
-    uint8_t *ISLoc = cast<OutputSection<ELFT>>(IS->OutSec)->Loc + IS->OutSecOff;
-    if (ISLoc <= Loc && ISLoc + IS->getSize() > Loc)
-      return IS->getLocation(Loc - ISLoc) + ": ";
-  }
-  return "";
-}
-
-std::string elf::getErrorLocation(uint8_t *Loc) {
-  switch (Config->EKind) {
-  case ELF32LEKind:
-    return getErrorLoc<ELF32LE>(Loc);
-  case ELF32BEKind:
-    return getErrorLoc<ELF32BE>(Loc);
-  case ELF64LEKind:
-    return getErrorLoc<ELF64LE>(Loc);
-  case ELF64BEKind:
-    return getErrorLoc<ELF64BE>(Loc);
-  default:
-    llvm_unreachable("unknown ELF type");
-  }
-}
-
 template void elf::writeResult<ELF32LE>();
 template void elf::writeResult<ELF32BE>();
 template void elf::writeResult<ELF64LE>();

Modified: lld/trunk/ELF/Writer.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.h?rev=290215&r1=290214&r2=290215&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.h (original)
+++ lld/trunk/ELF/Writer.h Tue Dec 20 18:05:39 2016
@@ -60,7 +60,6 @@ uint8_t getMipsFpAbiFlag(uint8_t OldFlag
                          llvm::StringRef FileName);
 
 bool isMipsN32Abi(const InputFile *F);
-std::string getErrorLocation(uint8_t *Loc);
 }
 }
 




More information about the llvm-commits mailing list