diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-04-15 05:15:19 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-04-15 05:15:19 +0000 |
| commit | bb97e1b52ef5315fedf0b92101bcf95e2fae8ff3 (patch) | |
| tree | 9dd856a76f25307a4a37404ce0db143a7bace098 /llvm/lib/MC/MCModule.cpp | |
| parent | 9f008867c063919762189487e78bcb7ace2b256d (diff) | |
| download | bcm5719-llvm-bb97e1b52ef5315fedf0b92101bcf95e2fae8ff3.tar.gz bcm5719-llvm-bb97e1b52ef5315fedf0b92101bcf95e2fae8ff3.zip | |
Use unique_ptr to own MCFunctions within MCModule.
MCModule's ctor had to be moved out of line so the definition of
MCFunction was available. (ctor requires the dtor of members (in case
the ctor throws) which required access to the dtor of MCFunction)
llvm-svn: 206244
Diffstat (limited to 'llvm/lib/MC/MCModule.cpp')
| -rw-r--r-- | llvm/lib/MC/MCModule.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/MC/MCModule.cpp b/llvm/lib/MC/MCModule.cpp index 8a5b63f27da..3ed735689d7 100644 --- a/llvm/lib/MC/MCModule.cpp +++ b/llvm/lib/MC/MCModule.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/STLExtras.h" #include "llvm/MC/MCModule.h" #include "llvm/MC/MCAtom.h" #include "llvm/MC/MCFunction.h" @@ -99,8 +100,9 @@ MCAtom *MCModule::findFirstAtomAfter(uint64_t Addr) { } MCFunction *MCModule::createFunction(StringRef Name) { - Functions.push_back(new MCFunction(Name, this)); - return Functions.back(); + std::unique_ptr<MCFunction> MCF(new MCFunction(Name, this)); + Functions.push_back(std::move(MCF)); + return Functions.back().get(); } static bool CompBBToAtom(MCBasicBlock *BB, const MCTextAtom *Atom) { @@ -130,13 +132,11 @@ void MCModule::trackBBForAtom(const MCTextAtom *Atom, MCBasicBlock *BB) { BBsByAtom.insert(I, BB); } +MCModule::MCModule() : Entrypoint(0) { } + MCModule::~MCModule() { for (AtomListTy::iterator AI = atom_begin(), AE = atom_end(); AI != AE; ++AI) delete *AI; - for (FunctionListTy::iterator FI = func_begin(), - FE = func_end(); - FI != FE; ++FI) - delete *FI; } |

