Use DICompositeType->replaceAllUsesWith().

This requires llvm rev. 76769 or higher.

llvm-svn: 76770
This commit is contained in:
Devang Patel 2009-07-22 18:57:00 +00:00
parent e85806f0d1
commit 06cceef545
1 changed files with 3 additions and 4 deletions

View File

@ -432,7 +432,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
// its members. Finally, we create a descriptor for the complete type (which
// may refer to the forward decl if the struct is recursive) and replace all
// uses of the forward declaration with the final definition.
llvm::DIType FwdDecl =
llvm::DICompositeType FwdDecl =
DebugFactory.CreateCompositeType(Tag, Unit, Name, DefUnit, Line, 0, 0, 0, 0,
llvm::DIType(), llvm::DIArray());
@ -506,14 +506,13 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
uint64_t Size = M->getContext().getTypeSize(Ty);
uint64_t Align = M->getContext().getTypeAlign(Ty);
llvm::DIType RealDecl =
llvm::DICompositeType RealDecl =
DebugFactory.CreateCompositeType(Tag, Unit, Name, DefUnit, Line, Size,
Align, 0, 0, llvm::DIType(), Elements);
// Now that we have a real decl for the struct, replace anything using the
// old decl with the new one. This will recursively update the debug info.
FwdDecl.getGV()->replaceAllUsesWith(RealDecl.getGV());
FwdDecl.getGV()->eraseFromParent();
FwdDecl.replaceAllUsesWith(RealDecl);
// Update TypeCache.
TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl;