Skip to content

Commit 17a39ae

Browse files
committed
[ELF] Simplify code with invokeELFT. NFC
1 parent c935f6e commit 17a39ae

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "SymbolTable.h"
1414
#include "Symbols.h"
1515
#include "SyntheticSections.h"
16+
#include "Target.h"
1617
#include "lld/Common/CommonLinkerContext.h"
1718
#include "lld/Common/DWARF.h"
1819
#include "llvm/ADT/STLExtras.h"
@@ -217,24 +218,7 @@ template <class ELFT> static void doParseFile(InputFile *file) {
217218
}
218219

219220
// Add symbols in File to the symbol table.
220-
void elf::parseFile(InputFile *file) {
221-
switch (config->ekind) {
222-
case ELF32LEKind:
223-
doParseFile<ELF32LE>(file);
224-
return;
225-
case ELF32BEKind:
226-
doParseFile<ELF32BE>(file);
227-
return;
228-
case ELF64LEKind:
229-
doParseFile<ELF64LE>(file);
230-
return;
231-
case ELF64BEKind:
232-
doParseFile<ELF64BE>(file);
233-
return;
234-
default:
235-
llvm_unreachable("unknown ELFT");
236-
}
237-
}
221+
void elf::parseFile(InputFile *file) { invokeELFT(doParseFile, file); }
238222

239223
// Concatenates arguments to construct a string representing an error location.
240224
static std::string createFileLineMsg(StringRef path, unsigned line) {

lld/ELF/InputSection.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,7 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
8383
if (!zlib::isAvailable())
8484
error(toString(file) + ": contains a compressed section, " +
8585
"but zlib is not available");
86-
switch (config->ekind) {
87-
case ELF32LEKind:
88-
parseCompressedHeader<ELF32LE>();
89-
break;
90-
case ELF32BEKind:
91-
parseCompressedHeader<ELF32BE>();
92-
break;
93-
case ELF64LEKind:
94-
parseCompressedHeader<ELF64LE>();
95-
break;
96-
case ELF64BEKind:
97-
parseCompressedHeader<ELF64BE>();
98-
break;
99-
default:
100-
llvm_unreachable("unknown ELFT");
101-
}
86+
invokeELFT(parseCompressedHeader);
10287
}
10388
}
10489

0 commit comments

Comments
 (0)