From: Rui Ueyama Date: Thu, 3 Mar 2016 06:22:29 +0000 (+0000) Subject: Replace ECRAII class with a function. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb3413e43a88264494cbf8404c253b622fcb195d;p=platform%2Fupstream%2Fllvm.git Replace ECRAII class with a function. RCRAII class was a bit tricky. This patch removes that. llvm-svn: 262586 --- diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 8b8cf02..393c52b 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 +static ELFFile createELFObj(MemoryBufferRef MB) { std::error_code EC; - -public: - std::error_code &getEC() { return EC; } - ~ECRAII() { fatal(EC); } -}; + ELFFile F(MB.getBuffer(), EC); + fatal(EC); + return F; } template -ELFFileBase::ELFFileBase(Kind K, MemoryBufferRef M) - : InputFile(K, M), ELFObj(MB.getBuffer(), ECRAII().getEC()) {} +ELFFileBase::ELFFileBase(Kind K, MemoryBufferRef MB) + : InputFile(K, MB), ELFObj(createELFObj(MB)) {} template ELFKind ELFFileBase::getELFKind() {