PTAL.
  use OwningPtr to fix the leak.
  I personally like this variant less than my first variant
  since here we construct OwningPtr from a part of JumpDest object.
  But this works too.

Hi nicholas,

http://llvm-reviews.chandlerc.com/D2472

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D2472?vs=6269&id=6271#toc

Files:
  lib/CodeGen/CGStmt.cpp

Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -19,6 +19,7 @@
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"
@@ -1237,6 +1238,7 @@
 
 void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
   JumpDest SwitchExit = getJumpDestInCurrentScope("sw.epilog");
+  OwningPtr<llvm::BasicBlock> SwitchExitOwner(SwitchExit.getBlock());
 
   RunCleanupsScope ConditionScope(*this);
 
@@ -1321,7 +1323,7 @@
   ConditionScope.ForceCleanup();
 
   // Emit continuation.
-  EmitBlock(SwitchExit.getBlock(), true);
+  EmitBlock(SwitchExitOwner.take(), true);
 
   SwitchInsn = SavedSwitchInsn;
   CaseRangeBlock = SavedCRBlock;
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -19,6 +19,7 @@
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/TargetInfo.h"
+#include "llvm/ADT/OwningPtr.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"
@@ -1237,6 +1238,7 @@
 
 void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
   JumpDest SwitchExit = getJumpDestInCurrentScope("sw.epilog");
+  OwningPtr<llvm::BasicBlock> SwitchExitOwner(SwitchExit.getBlock());
 
   RunCleanupsScope ConditionScope(*this);
 
@@ -1321,7 +1323,7 @@
   ConditionScope.ForceCleanup();
 
   // Emit continuation.
-  EmitBlock(SwitchExit.getBlock(), true);
+  EmitBlock(SwitchExitOwner.take(), true);
 
   SwitchInsn = SavedSwitchInsn;
   CaseRangeBlock = SavedCRBlock;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to