[lld] r291222 - Merge elf::toString and coff::toString.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 02:04:09 PST 2017
Author: ruiu
Date: Fri Jan 6 04:04:08 2017
New Revision: 291222
URL: http://llvm.org/viewvc/llvm-project?rev=291222&view=rev
Log:
Merge elf::toString and coff::toString.
The two overloaded functions hid each other. This patch merges them.
Modified:
lld/trunk/COFF/InputFiles.cpp
lld/trunk/COFF/InputFiles.h
lld/trunk/COFF/Symbols.cpp
lld/trunk/COFF/Symbols.h
lld/trunk/ELF/InputFiles.cpp
lld/trunk/ELF/InputFiles.h
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/Symbols.cpp
lld/trunk/ELF/Symbols.h
lld/trunk/ELF/Target.cpp
lld/trunk/ELF/Target.h
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Fri Jan 6 04:04:08 2017
@@ -372,6 +372,8 @@ MachineTypes BitcodeFile::getMachineType
return IMAGE_FILE_MACHINE_UNKNOWN;
}
}
+} // namespace coff
+} // namespace lld
// Returns the last element of a path, which is supposed to be a filename.
static StringRef getBasename(StringRef Path) {
@@ -382,7 +384,7 @@ static StringRef getBasename(StringRef P
}
// Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".
-std::string toString(InputFile *File) {
+std::string lld::toString(coff::InputFile *File) {
if (!File)
return "(internal)";
if (File->ParentName.empty())
@@ -393,6 +395,3 @@ std::string toString(InputFile *File) {
.str();
return StringRef(Res).lower();
}
-
-} // namespace coff
-} // namespace lld
Modified: lld/trunk/COFF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.h?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.h (original)
+++ lld/trunk/COFF/InputFiles.h Fri Jan 6 04:04:08 2017
@@ -202,10 +202,9 @@ private:
llvm::BumpPtrAllocator Alloc;
std::unique_ptr<LTOModule> M;
};
-
-std::string toString(InputFile *File);
-
} // namespace coff
+
+std::string toString(coff::InputFile *File);
} // namespace lld
#endif
Modified: lld/trunk/COFF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.cpp?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.cpp (original)
+++ lld/trunk/COFF/Symbols.cpp Fri Jan 6 04:04:08 2017
@@ -73,13 +73,12 @@ Defined *Undefined::getWeakAlias() {
return D;
return nullptr;
}
+} // namespace coff
// Returns a symbol name for an error message.
-std::string toString(SymbolBody &B) {
- if (Optional<std::string> S = demangle(B.getName()))
+std::string lld::toString(coff::SymbolBody &B) {
+ if (Optional<std::string> S = coff::demangle(B.getName()))
return ("\"" + *S + "\" (" + B.getName() + ")").str();
return B.getName();
}
-
-} // namespace coff
} // namespace lld
Modified: lld/trunk/COFF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Symbols.h?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/COFF/Symbols.h (original)
+++ lld/trunk/COFF/Symbols.h Fri Jan 6 04:04:08 2017
@@ -428,10 +428,9 @@ inline Symbol *SymbolBody::symbol() {
return reinterpret_cast<Symbol *>(reinterpret_cast<char *>(this) -
offsetof(Symbol, Body));
}
-
-std::string toString(SymbolBody &B);
-
} // namespace coff
+
+std::string toString(coff::SymbolBody &B);
} // namespace lld
#endif
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Fri Jan 6 04:04:08 2017
@@ -96,7 +96,7 @@ std::string elf::ObjectFile<ELFT>::getLi
}
// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
-std::string elf::toString(const InputFile *F) {
+std::string lld::toString(const InputFile *F) {
if (!F)
return "(internal)";
if (!F->ArchiveName.empty())
Modified: lld/trunk/ELF/InputFiles.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.h?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.h (original)
+++ lld/trunk/ELF/InputFiles.h Fri Jan 6 04:04:08 2017
@@ -36,10 +36,16 @@ class InputFile;
namespace lld {
namespace elf {
+class InputFile;
+}
+
+// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
+std::string toString(const elf::InputFile *F);
+
+namespace elf {
using llvm::object::Archive;
-class InputFile;
class Lazy;
class SymbolBody;
@@ -84,9 +90,6 @@ private:
const Kind FileKind;
};
-// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
-std::string toString(const InputFile *F);
-
template <typename ELFT> class ELFFileBase : public InputFile {
public:
typedef typename ELFT::Shdr Elf_Shdr;
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Fri Jan 6 04:04:08 2017
@@ -34,7 +34,7 @@ using namespace lld::elf;
// Returns a string to construct an error message.
template <class ELFT>
-std::string elf::toString(const InputSectionBase<ELFT> *Sec) {
+std::string lld::toString(const InputSectionBase<ELFT> *Sec) {
return (Sec->getFile()->getName() + ":(" + Sec->Name + ")").str();
}
@@ -844,7 +844,7 @@ template class elf::MergeInputSection<EL
template class elf::MergeInputSection<ELF64LE>;
template class elf::MergeInputSection<ELF64BE>;
-template std::string elf::toString(const InputSectionBase<ELF32LE> *);
-template std::string elf::toString(const InputSectionBase<ELF32BE> *);
-template std::string elf::toString(const InputSectionBase<ELF64LE> *);
-template std::string elf::toString(const InputSectionBase<ELF64BE> *);
+template std::string lld::toString(const InputSectionBase<ELF32LE> *);
+template std::string lld::toString(const InputSectionBase<ELF32BE> *);
+template std::string lld::toString(const InputSectionBase<ELF64LE> *);
+template std::string lld::toString(const InputSectionBase<ELF64BE> *);
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Fri Jan 6 04:04:08 2017
@@ -318,10 +318,9 @@ private:
};
template <class ELFT> InputSection<ELFT> InputSection<ELFT>::Discarded;
-
-template <class ELFT> std::string toString(const InputSectionBase<ELFT> *);
-
} // namespace elf
+
+template <class ELFT> std::string toString(const elf::InputSectionBase<ELFT> *);
} // namespace lld
#endif
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Fri Jan 6 04:04:08 2017
@@ -305,7 +305,7 @@ void elf::printTraceSymbol(Symbol *Sym)
}
// Returns a symbol for an error message.
-std::string elf::toString(const SymbolBody &B) {
+std::string lld::toString(const SymbolBody &B) {
if (Config->Demangle)
if (Optional<std::string> S = demangle(B.getName()))
return *S;
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Fri Jan 6 04:04:08 2017
@@ -453,10 +453,9 @@ inline Symbol *SymbolBody::symbol() {
return reinterpret_cast<Symbol *>(reinterpret_cast<char *>(this) -
offsetof(Symbol, Body));
}
-
-std::string toString(const SymbolBody &B);
-
} // namespace elf
+
+std::string toString(const elf::SymbolBody &B);
} // namespace lld
#endif
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Fri Jan 6 04:04:08 2017
@@ -44,6 +44,10 @@ using namespace llvm::object;
using namespace llvm::support::endian;
using namespace llvm::ELF;
+std::string lld::toString(uint32_t Type) {
+ return getELFRelocationTypeName(elf::Config->EMachine, Type);
+}
+
namespace lld {
namespace elf {
@@ -52,10 +56,6 @@ TargetInfo *Target;
static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); }
static void or32be(uint8_t *P, int32_t V) { write32be(P, read32be(P) | V); }
-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);
Modified: lld/trunk/ELF/Target.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.h?rev=291222&r1=291221&r2=291222&view=diff
==============================================================================
--- lld/trunk/ELF/Target.h (original)
+++ lld/trunk/ELF/Target.h Fri Jan 6 04:04:08 2017
@@ -104,13 +104,14 @@ public:
virtual void relaxTlsLdToLe(uint8_t *Loc, uint32_t Type, uint64_t Val) const;
};
-std::string toString(uint32_t RelType);
uint64_t getPPC64TocBase();
uint64_t getAArch64Page(uint64_t Expr);
extern TargetInfo *Target;
TargetInfo *createTarget();
}
+
+std::string toString(uint32_t RelType);
}
#endif
More information about the llvm-commits
mailing list