r208161 - PR19562: Fix memory leak when ObjC interface types cause the creation of further interfaces.

David Blaikie dblaikie at gmail.com
Tue May 6 23:18:00 PDT 2014


Author: dblaikie
Date: Wed May  7 01:18:00 2014
New Revision: 208161

URL: http://llvm.org/viewvc/llvm-project?rev=208161&view=rev
Log:
PR19562: Fix memory leak when ObjC interface types cause the creation of further interfaces.

Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=208161&r1=208160&r2=208161&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed May  7 01:18:00 2014
@@ -3332,11 +3332,15 @@ void CGDebugInfo::finalize() {
     Ty.replaceAllUsesWith(CGM.getLLVMContext(), RepTy);
   }
 
-  for (auto E : ObjCInterfaceCache)
+  // Creating types might create further types - invalidating the current
+  // element and the size(), so don't cache/reference them.
+  for (size_t i = 0; i != ObjCInterfaceCache.size(); ++i) {
+    ObjCInterfaceCacheEntry E = ObjCInterfaceCache[i];
     E.Decl.replaceAllUsesWith(CGM.getLLVMContext(),
                               E.Type->getDecl()->getDefinition()
                                   ? CreateTypeDefinition(E.Type, E.Unit)
                                   : E.Decl);
+  }
 
   // We keep our own list of retained types, because we need to look
   // up the final type in the type cache.





More information about the cfe-commits mailing list