[PATCH] Fix leak in lib/CodeGen/CGException.cpp, PR18318

Chandler Carruth chandlerc at gmail.com
Thu Dec 26 01:03:16 PST 2013



================
Comment at: lib/CodeGen/CGException.cpp:1247-1248
@@ -1246,2 +1246,4 @@
   if (!CatchScope.hasEHBranches()) {
+    for (unsigned I = 0; I != NumHandlers; ++I)
+      delete CatchScope.getHandler(I).Block;
     EHStack.popCatch();
----------------
This should really be a method on the EHCatchScope object. I would call it 'clearHandlerBlocks()'.

I would also add a FIXME comment to that function which suggests switching EHCatchScope to *always* clear the blocks on destruction, and to add a 'takeHandler' or some such function which removes ownership from the EHCatchScope. Not asking that you make this change because of the innards of EHCatchScope I expect this change would be somewhat invasive and awkward to do.


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



More information about the cfe-commits mailing list