diff options
| author | Rumeet Dhindsa <rdhindsa@google.com> | 2019-06-26 03:00:57 +0000 |
|---|---|---|
| committer | Rumeet Dhindsa <rdhindsa@google.com> | 2019-06-26 03:00:57 +0000 |
| commit | 4ee933c76bf2a81e7d843c878ac80e8d67eaa535 (patch) | |
| tree | 5a004357b109458fd083942082dee251e1c91504 /llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp | |
| parent | 4e3f00e999876195f5047c8bc903bdc3afd0cfad (diff) | |
| download | bcm5719-llvm-4ee933c76bf2a81e7d843c878ac80e8d67eaa535.tar.gz bcm5719-llvm-4ee933c76bf2a81e7d843c878ac80e8d67eaa535.zip | |
Revert [llvm-objcopy][NFC] Refactor output target parsing
This reverts r364254 (git commit 545f001d1b9a7b58a68d75e70bfc36c841de8999)
This change causes some llvm-obcopy tests to fail with valgrind.
Following is the output for basic-keep.test
Command Output (stderr):
--
==107406== Conditional jump or move depends on uninitialised value(s)
==107406== at 0x1A30DD: executeObjcopy(llvm::objcopy::CopyConfig const&) (llvm-objcopy.cpp:235)
==107406== by 0x1A3935: main (llvm-objcopy.cpp:294)
llvm-svn: 364379
Diffstat (limited to 'llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp')
| -rw-r--r-- | llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp index b366c6e5598..b6af729afe8 100644 --- a/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp +++ b/llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp @@ -154,14 +154,12 @@ static std::unique_ptr<Writer> createELFWriter(const CopyConfig &Config, static std::unique_ptr<Writer> createWriter(const CopyConfig &Config, Object &Obj, Buffer &Buf, ElfType 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); - } + 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); })(); } template <class ELFT> |

