[lld] r234039 - ELF: Remove partial class definitions of <Arch>LinkingContexts.
Rui Ueyama
ruiu at google.com
Fri Apr 3 12:32:31 PDT 2015
Author: ruiu
Date: Fri Apr 3 14:32:31 2015
New Revision: 234039
URL: http://llvm.org/viewvc/llvm-project?rev=234039&view=rev
Log:
ELF: Remove partial class definitions of <Arch>LinkingContexts.
What we are doing in ELFTarget.h was dubious. In the file, we define
partial classes of <Arch>LinkingContexts to declare only static member
functions. We have different (complete) class definitions in other files.
They would conflict if they exist in the same compilation unit (because
the ones defined in ELFTarget.h has only static member functions).
I don't think this was valid C++.
http://reviews.llvm.org/D8797
Modified:
lld/trunk/include/lld/ReaderWriter/ELFTargets.h
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp
lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
Modified: lld/trunk/include/lld/ReaderWriter/ELFTargets.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFTargets.h?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/ELFTargets.h (original)
+++ lld/trunk/include/lld/ReaderWriter/ELFTargets.h Fri Apr 3 14:32:31 2015
@@ -15,22 +15,13 @@
namespace lld {
namespace elf {
-#define LLVM_TARGET(TargetName) \
- class TargetName##LinkingContext : public ELFLinkingContext { \
- public: \
- static std::unique_ptr<ELFLinkingContext> create(llvm::Triple); \
- };
-
-// FIXME: #include "llvm/Config/Targets.def"
-LLVM_TARGET(AArch64)
-LLVM_TARGET(ARM)
-LLVM_TARGET(Hexagon)
-LLVM_TARGET(Mips)
-LLVM_TARGET(X86)
-LLVM_TARGET(Example)
-LLVM_TARGET(X86_64)
-
-#undef LLVM_TARGET
+std::unique_ptr<ELFLinkingContext> createAArch64LinkingContext(llvm::Triple);
+std::unique_ptr<ELFLinkingContext> createARMLinkingContext(llvm::Triple);
+std::unique_ptr<ELFLinkingContext> createExampleLinkingContext(llvm::Triple);
+std::unique_ptr<ELFLinkingContext> createHexagonLinkingContext(llvm::Triple);
+std::unique_ptr<ELFLinkingContext> createMipsLinkingContext(llvm::Triple);
+std::unique_ptr<ELFLinkingContext> createX86LinkingContext(llvm::Triple);
+std::unique_ptr<ELFLinkingContext> createX86_64LinkingContext(llvm::Triple);
} // end namespace elf
} // end namespace lld
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Fri Apr 3 14:32:31 2015
@@ -350,17 +350,13 @@ void GnuLdDriver::addPlatformSearchDirs(
std::unique_ptr<ELFLinkingContext>
GnuLdDriver::createELFLinkingContext(llvm::Triple triple) {
std::unique_ptr<ELFLinkingContext> p;
- // FIXME: #include "llvm/Config/Targets.def"
-#define LLVM_TARGET(targetName) \
- if ((p = elf::targetName##LinkingContext::create(triple))) return p;
- LLVM_TARGET(AArch64)
- LLVM_TARGET(ARM)
- LLVM_TARGET(Hexagon)
- LLVM_TARGET(Mips)
- LLVM_TARGET(X86)
- LLVM_TARGET(Example)
- LLVM_TARGET(X86_64)
-#undef LLVM_TARGET
+ if ((p = elf::createAArch64LinkingContext(triple))) return p;
+ if ((p = elf::createARMLinkingContext(triple))) return p;
+ if ((p = elf::createExampleLinkingContext(triple))) return p;
+ if ((p = elf::createHexagonLinkingContext(triple))) return p;
+ if ((p = elf::createMipsLinkingContext(triple))) return p;
+ if ((p = elf::createX86LinkingContext(triple))) return p;
+ if ((p = elf::createX86_64LinkingContext(triple))) return p;
return nullptr;
}
Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp Fri Apr 3 14:32:31 2015
@@ -10,12 +10,13 @@
#include "AArch64LinkingContext.h"
#include "AArch64RelocationPass.h"
#include "AArch64TargetHandler.h"
+#include "lld/ReaderWriter/ELFTargets.h"
using namespace lld;
using namespace lld::elf;
std::unique_ptr<ELFLinkingContext>
-AArch64LinkingContext::create(llvm::Triple triple) {
+elf::createAArch64LinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::aarch64)
return llvm::make_unique<AArch64LinkingContext>(triple);
return nullptr;
Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp Fri Apr 3 14:32:31 2015
@@ -15,7 +15,7 @@ namespace lld {
namespace elf {
std::unique_ptr<ELFLinkingContext>
-ARMLinkingContext::create(llvm::Triple triple) {
+createARMLinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::arm)
return llvm::make_unique<ARMLinkingContext>(triple);
return nullptr;
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp Fri Apr 3 14:32:31 2015
@@ -9,12 +9,13 @@
#include "HexagonLinkingContext.h"
#include "HexagonTargetHandler.h"
+#include "lld/ReaderWriter/ELFTargets.h"
using namespace lld;
using namespace lld::elf;
std::unique_ptr<lld::ELFLinkingContext>
-HexagonLinkingContext::create(llvm::Triple triple) {
+elf::createHexagonLinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::hexagon)
return llvm::make_unique<HexagonLinkingContext>(triple);
return nullptr;
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp Fri Apr 3 14:32:31 2015
@@ -12,12 +12,13 @@
#include "MipsLinkingContext.h"
#include "MipsRelocationPass.h"
#include "MipsTargetHandler.h"
+#include "lld/ReaderWriter/ELFTargets.h"
using namespace lld;
using namespace lld::elf;
std::unique_ptr<ELFLinkingContext>
-MipsLinkingContext::create(llvm::Triple triple) {
+elf::createMipsLinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::mipsel ||
triple.getArch() == llvm::Triple::mips64el)
return llvm::make_unique<MipsLinkingContext>(triple);
Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp Fri Apr 3 14:32:31 2015
@@ -10,6 +10,7 @@
#include "X86LinkingContext.h"
#include "X86TargetHandler.h"
#include "lld/Core/LLVM.h"
+#include "lld/ReaderWriter/ELFTargets.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ErrorOr.h"
@@ -17,7 +18,7 @@ using namespace lld;
using namespace lld::elf;
std::unique_ptr<ELFLinkingContext>
-X86LinkingContext::create(llvm::Triple triple) {
+elf::createX86LinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::x86)
return llvm::make_unique<X86LinkingContext>(triple);
return nullptr;
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/ExampleLinkingContext.cpp Fri Apr 3 14:32:31 2015
@@ -9,12 +9,13 @@
#include "ExampleLinkingContext.h"
#include "ExampleTargetHandler.h"
+#include "lld/ReaderWriter/ELFTargets.h"
using namespace lld;
using namespace elf;
std::unique_ptr<ELFLinkingContext>
-ExampleLinkingContext::create(llvm::Triple triple) {
+elf::createExampleLinkingContext(llvm::Triple triple) {
if (triple.getVendorName() == "example")
return llvm::make_unique<ExampleLinkingContext>(triple);
return nullptr;
Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp?rev=234039&r1=234038&r2=234039&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp Fri Apr 3 14:32:31 2015
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include "lld/ReaderWriter/ELFTargets.h"
#include "X86_64LinkingContext.h"
#include "X86_64RelocationPass.h"
#include "X86_64TargetHandler.h"
@@ -30,7 +31,7 @@ void X86_64LinkingContext::addPasses(Pas
}
std::unique_ptr<ELFLinkingContext>
-X86_64LinkingContext::create(llvm::Triple triple) {
+elf::createX86_64LinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::x86_64)
return llvm::make_unique<X86_64LinkingContext>(triple);
return nullptr;
More information about the llvm-commits
mailing list