summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
diff options
context:
space:
mode:
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