diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-03-03 06:22:29 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-03-03 06:22:29 +0000 |
| commit | eb3413e43a88264494cbf8404c253b622fcb195d (patch) | |
| tree | 2bde1a44bc86c9d24cc0eec9637890d51841ebd8 | |
| parent | 5ba9718abe53e678b52fb414b315c388c398292f (diff) | |
| download | bcm5719-llvm-eb3413e43a88264494cbf8404c253b622fcb195d.tar.gz bcm5719-llvm-eb3413e43a88264494cbf8404c253b622fcb195d.zip | |
Replace ECRAII class with a function.
RCRAII class was a bit tricky. This patch removes that.
llvm-svn: 262586
| -rw-r--r-- | lld/ELF/InputFiles.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 8b8cf02a8de..393c52b874d 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -25,19 +25,17 @@ using namespace llvm::sys::fs; using namespace lld; using namespace lld::elf; -namespace { -class ECRAII { +template <class ELFT> +static ELFFile<ELFT> createELFObj(MemoryBufferRef MB) { std::error_code EC; - -public: - std::error_code &getEC() { return EC; } - ~ECRAII() { fatal(EC); } -}; + ELFFile<ELFT> F(MB.getBuffer(), EC); + fatal(EC); + return F; } template <class ELFT> -ELFFileBase<ELFT>::ELFFileBase(Kind K, MemoryBufferRef M) - : InputFile(K, M), ELFObj(MB.getBuffer(), ECRAII().getEC()) {} +ELFFileBase<ELFT>::ELFFileBase(Kind K, MemoryBufferRef MB) + : InputFile(K, MB), ELFObj(createELFObj<ELFT>(MB)) {} template <class ELFT> ELFKind ELFFileBase<ELFT>::getELFKind() { |

