diff options
author | Reid Kleckner <rnk@google.com> | 2017-10-06 17:21:49 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-10-06 17:21:49 +0000 |
commit | 4c4422f9a5813706410a99a9e756f8600be138eb (patch) | |
tree | d6b13d1e4f5ba089c0d2ae9b959154b4d995bc74 /llvm/lib/MC/MCStreamer.cpp | |
parent | 80e31f1f84b3d28e0eb91607dea08b7c63f555c9 (diff) | |
download | bcm5719-llvm-4c4422f9a5813706410a99a9e756f8600be138eb.tar.gz bcm5719-llvm-4c4422f9a5813706410a99a9e756f8600be138eb.zip |
[MC] Use unique_ptr to manage WinFrameInfos, NFC
The FrameInfo cannot be stored directly in the vector because chained
frames may refer to parent frames, so we need pointers that are stable
across a vector resize.
llvm-svn: 315080
Diffstat (limited to 'llvm/lib/MC/MCStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCStreamer.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp index 61f65c5f946..7521a752fe5 100644 --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -56,17 +56,12 @@ MCStreamer::MCStreamer(MCContext &Ctx) SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>()); } -MCStreamer::~MCStreamer() { - for (unsigned i = 0; i < getNumWinFrameInfos(); ++i) - delete WinFrameInfos[i]; -} +MCStreamer::~MCStreamer() {} void MCStreamer::reset() { DwarfFrameInfos.clear(); - for (unsigned i = 0; i < getNumWinFrameInfos(); ++i) - delete WinFrameInfos[i]; - WinFrameInfos.clear(); CurrentWinFrameInfo = nullptr; + WinFrameInfos.clear(); SymbolOrdering.clear(); SectionStack.clear(); SectionStack.push_back(std::pair<MCSectionSubPair, MCSectionSubPair>()); @@ -538,8 +533,9 @@ void MCStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) { MCSymbol *StartProc = EmitCFILabel(); - WinFrameInfos.push_back(new WinEH::FrameInfo(Symbol, StartProc)); - CurrentWinFrameInfo = WinFrameInfos.back(); + WinFrameInfos.emplace_back( + llvm::make_unique<WinEH::FrameInfo>(Symbol, StartProc)); + CurrentWinFrameInfo = WinFrameInfos.back().get(); CurrentWinFrameInfo->TextSection = getCurrentSectionOnly(); } @@ -557,9 +553,9 @@ void MCStreamer::EmitWinCFIStartChained() { MCSymbol *StartProc = EmitCFILabel(); - WinFrameInfos.push_back(new WinEH::FrameInfo(CurrentWinFrameInfo->Function, - StartProc, CurrentWinFrameInfo)); - CurrentWinFrameInfo = WinFrameInfos.back(); + WinFrameInfos.emplace_back(llvm::make_unique<WinEH::FrameInfo>( + CurrentWinFrameInfo->Function, StartProc, CurrentWinFrameInfo)); + CurrentWinFrameInfo = WinFrameInfos.back().get(); CurrentWinFrameInfo->TextSection = getCurrentSectionOnly(); } |