[lld] 17a39ae - [ELF] Simplify code with invokeELFT. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 09:53:32 PST 2022
Author: Fangrui Song
Date: 2022-02-01T09:53:29-08:00
New Revision: 17a39aecd1703d94e2b1dff0dedd690cc1b0aaaf
URL: https://github.com/llvm/llvm-project/commit/17a39aecd1703d94e2b1dff0dedd690cc1b0aaaf
DIFF: https://github.com/llvm/llvm-project/commit/17a39aecd1703d94e2b1dff0dedd690cc1b0aaaf.diff
LOG: [ELF] Simplify code with invokeELFT. NFC
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/ELF/InputSection.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index f5cdb199d4c9..b5510b3b2736 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -13,6 +13,7 @@
#include "SymbolTable.h"
#include "Symbols.h"
#include "SyntheticSections.h"
+#include "Target.h"
#include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/DWARF.h"
#include "llvm/ADT/STLExtras.h"
@@ -217,24 +218,7 @@ template <class ELFT> static void doParseFile(InputFile *file) {
}
// Add symbols in File to the symbol table.
-void elf::parseFile(InputFile *file) {
- switch (config->ekind) {
- case ELF32LEKind:
- doParseFile<ELF32LE>(file);
- return;
- case ELF32BEKind:
- doParseFile<ELF32BE>(file);
- return;
- case ELF64LEKind:
- doParseFile<ELF64LE>(file);
- return;
- case ELF64BEKind:
- doParseFile<ELF64BE>(file);
- return;
- default:
- llvm_unreachable("unknown ELFT");
- }
-}
+void elf::parseFile(InputFile *file) { invokeELFT(doParseFile, file); }
// Concatenates arguments to construct a string representing an error location.
static std::string createFileLineMsg(StringRef path, unsigned line) {
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 66abe2001973..4e5b0f685922 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -83,22 +83,7 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
if (!zlib::isAvailable())
error(toString(file) + ": contains a compressed section, " +
"but zlib is not available");
- switch (config->ekind) {
- case ELF32LEKind:
- parseCompressedHeader<ELF32LE>();
- break;
- case ELF32BEKind:
- parseCompressedHeader<ELF32BE>();
- break;
- case ELF64LEKind:
- parseCompressedHeader<ELF64LE>();
- break;
- case ELF64BEKind:
- parseCompressedHeader<ELF64BE>();
- break;
- default:
- llvm_unreachable("unknown ELFT");
- }
+ invokeELFT(parseCompressedHeader);
}
}
More information about the llvm-commits
mailing list