[lld] r262586 - Replace ECRAII class with a function.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 2 22:22:30 PST 2016
Author: ruiu
Date: Thu Mar 3 00:22:29 2016
New Revision: 262586
URL: http://llvm.org/viewvc/llvm-project?rev=262586&view=rev
Log:
Replace ECRAII class with a function.
RCRAII class was a bit tricky. This patch removes that.
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=262586&r1=262585&r2=262586&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Thu Mar 3 00:22:29 2016
@@ -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() {
More information about the llvm-commits
mailing list