summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
diff options
context:
space:
mode:
authorSeiya Nuta <nuta@seiya.me>2019-06-25 00:02:04 +0000
committerSeiya Nuta <nuta@seiya.me>2019-06-25 00:02:04 +0000
commit545f001d1b9a7b58a68d75e70bfc36c841de8999 (patch)
tree1b673409a65874c1611e89ba852379e90acfda51 /llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
parentf895e1bded031fb503bd12ad25d7139d6a6ee6c0 (diff)
downloadbcm5719-llvm-545f001d1b9a7b58a68d75e70bfc36c841de8999.tar.gz
bcm5719-llvm-545f001d1b9a7b58a68d75e70bfc36c841de8999.zip
[llvm-objcopy][NFC] Refactor output target parsing
Summary: Use an enum instead of string to hold the output file format in Config.InputFormat and Config.OutputFormat. It's essential to support other output file formats other than ELF. Reviewers: espindola, alexshap, rupprecht, jhenderson Reviewed By: rupprecht, jhenderson Subscribers: jyknight, compnerd, emaste, arichardson, fedor.sergeev, jakehehrlich, MaskRay, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63239 llvm-svn: 364254
Diffstat (limited to 'llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
index b6af729afe8..b366c6e5598 100644
--- a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
+++ b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
@@ -154,12 +154,14 @@ static std::unique_ptr<Writer> createELFWriter(const CopyConfig &Config,
static std::unique_ptr<Writer> createWriter(const CopyConfig &Config,
Object &Obj, Buffer &Buf,
ElfType OutputElfType) {
- using Functor = std::function<std::unique_ptr<Writer>()>;
- return StringSwitch<Functor>(Config.OutputFormat)
- .Case("binary", [&] { return llvm::make_unique<BinaryWriter>(Obj, Buf); })
- .Case("ihex", [&] { return llvm::make_unique<IHexWriter>(Obj, Buf); })
- .Default(
- [&] { return createELFWriter(Config, Obj, Buf, OutputElfType); })();
+ switch (Config.OutputFormat) {
+ case FileFormat::Binary:
+ return llvm::make_unique<BinaryWriter>(Obj, Buf);
+ case FileFormat::IHex:
+ return llvm::make_unique<IHexWriter>(Obj, Buf);
+ default:
+ return createELFWriter(Config, Obj, Buf, OutputElfType);
+ }
}
template <class ELFT>
OpenPOWER on IntegriCloud