OSDN Git Service

My attempt at fixing the leak reported by the valgrind buildbots. Valgrind will
authorCharles Davis <cdavis@mines.edu>
Fri, 27 May 2011 02:01:08 +0000 (02:01 +0000)
committerCharles Davis <cdavis@mines.edu>
Fri, 27 May 2011 02:01:08 +0000 (02:01 +0000)
still report leaks, but they're spurious now. Valgrind cannot peer into
std::vector objects--or any dynamic array, for that matter--because it doesn't
know how big the array is.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132174 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCStreamer.cpp

index 88293f5..881bc8e 100644 (file)
@@ -28,6 +28,8 @@ MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx), EmitEHFrame(true),
 }
 
 MCStreamer::~MCStreamer() {
+  for (unsigned i = 0; i < getNumW64UnwindInfos(); ++i)
+    delete W64UnwindInfos[i];
 }
 
 const MCExpr *MCStreamer::BuildSymbolDiff(MCContext &Context,
@@ -321,7 +323,7 @@ void MCStreamer::EmitWin64EHStartProc(const MCSymbol *Symbol) {
   MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
   if (CurFrame && !CurFrame->End)
     report_fatal_error("Starting a function before ending the previous one!");
-  MCWin64EHUnwindInfo *Frame = new (getContext()) MCWin64EHUnwindInfo;
+  MCWin64EHUnwindInfo *Frame = new MCWin64EHUnwindInfo;
   Frame->Begin = getContext().CreateTempSymbol();
   Frame->Function = Symbol;
   EmitLabel(Frame->Begin);
@@ -339,7 +341,7 @@ void MCStreamer::EmitWin64EHEndProc() {
 
 void MCStreamer::EmitWin64EHStartChained() {
   EnsureValidW64UnwindInfo();
-  MCWin64EHUnwindInfo *Frame = new (getContext()) MCWin64EHUnwindInfo;
+  MCWin64EHUnwindInfo *Frame = new MCWin64EHUnwindInfo;
   MCWin64EHUnwindInfo *CurFrame = CurrentW64UnwindInfo;
   Frame->Begin = getContext().CreateTempSymbol();
   Frame->Function = CurFrame->Function;