forked from OSchip/llvm-project
PR19562: Fix another temporary node leak in Clang debug info emission
While constructing ObjC Interface types we might create the declaration of some normal C++ types, thus adding things to the ReplaceMap. Make sure we process the ReplaceMap after the ObjC interfaces. In theory we know at this point, since we're at the end of the TU, that we won't be upgrading any declarations to definitions, so we could just construct non-temporary nodes, but that would require extra state in CGDebugInfo to conditionalize the creation of declaration nodes which seems annoying/more work than is appropriate. llvm-svn: 208226
This commit is contained in:
parent
e825c854a8
commit
87dab87a66
|
@ -3319,6 +3319,16 @@ CGDebugInfo::getOrCreateNameSpace(const NamespaceDecl *NSDecl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGDebugInfo::finalize() {
|
void CGDebugInfo::finalize() {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto p : ReplaceMap) {
|
for (auto p : ReplaceMap) {
|
||||||
assert(p.second);
|
assert(p.second);
|
||||||
llvm::DIType Ty(cast<llvm::MDNode>(p.second));
|
llvm::DIType Ty(cast<llvm::MDNode>(p.second));
|
||||||
|
@ -3332,16 +3342,6 @@ void CGDebugInfo::finalize() {
|
||||||
Ty.replaceAllUsesWith(CGM.getLLVMContext(), RepTy);
|
Ty.replaceAllUsesWith(CGM.getLLVMContext(), RepTy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// We keep our own list of retained types, because we need to look
|
||||||
// up the final type in the type cache.
|
// up the final type in the type cache.
|
||||||
for (std::vector<void *>::const_iterator RI = RetainedTypes.begin(),
|
for (std::vector<void *>::const_iterator RI = RetainedTypes.begin(),
|
||||||
|
|
Loading…
Reference in New Issue