From: Duncan P. N. Exon Smith Date: Thu, 16 Apr 2015 01:00:56 +0000 (+0000) Subject: DebugInfo: Prepare for DIType to be gutted X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbdd3a1a5d98e0250e81fe04375b38485d4d05ca;p=clang DebugInfo: Prepare for DIType to be gutted `DIType` and its subclasses are about to be gutted in LLVM. Prepare for that by treating these like the raw pointers they wrap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@235063 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index b4d55476c7..1908ffa809 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1467,11 +1467,10 @@ void CGDebugInfo::completeType(const EnumDecl *ED) { QualType Ty = CGM.getContext().getEnumType(ED); void *TyPtr = Ty.getAsOpaquePtr(); auto I = TypeCache.find(TyPtr); - if (I == TypeCache.end() || - !llvm::DIType(cast(I->second)).isForwardDecl()) + if (I == TypeCache.end() || !cast(I->second)->isForwardDecl()) return; llvm::DIType Res = CreateTypeDefinition(Ty->castAs()); - assert(!Res.isForwardDecl()); + assert(!Res->isForwardDecl()); TypeCache[TyPtr].reset(Res); } @@ -1491,7 +1490,7 @@ void CGDebugInfo::completeRequiredType(const RecordDecl *RD) { QualType Ty = CGM.getContext().getRecordType(RD); llvm::DIType T = getTypeOrNull(Ty); - if (T && T.isForwardDecl()) + if (T && T->isForwardDecl()) completeClassData(RD); } @@ -1501,11 +1500,10 @@ void CGDebugInfo::completeClassData(const RecordDecl *RD) { QualType Ty = CGM.getContext().getRecordType(RD); void *TyPtr = Ty.getAsOpaquePtr(); auto I = TypeCache.find(TyPtr); - if (I != TypeCache.end() && - !llvm::DIType(cast(I->second)).isForwardDecl()) + if (I != TypeCache.end() && !cast(I->second)->isForwardDecl()) return; llvm::DIType Res = CreateTypeDefinition(Ty->castAs()); - assert(!Res.isForwardDecl()); + assert(!Res->isForwardDecl()); TypeCache[TyPtr].reset(Res); } @@ -1620,7 +1618,7 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) { if (FwdDecl->isTemporary()) FwdDecl = llvm::MDNode::replaceWithPermanent( - llvm::TempMDCompositeTypeBase(FwdDecl.get())); + llvm::TempMDCompositeTypeBase(FwdDecl)); RegionMap[Ty->getDecl()].reset(FwdDecl); return FwdDecl; @@ -2219,13 +2217,12 @@ llvm::DIType CGDebugInfo::getOrCreateLimitedType(const RecordType *Ty, llvm::DIFile Unit) { QualType QTy(Ty, 0); - llvm::DICompositeType T = - cast_or_null(getTypeOrNull(QTy)); + auto *T = cast_or_null(getTypeOrNull(QTy)); // We may have cached a forward decl when we could have created // a non-forward decl. Go ahead and create a non-forward decl // now. - if (T && !T.isForwardDecl()) + if (T && !T->isForwardDecl()) return T; // Otherwise create the type. @@ -2234,7 +2231,7 @@ llvm::DIType CGDebugInfo::getOrCreateLimitedType(const RecordType *Ty, // Propagate members from the declaration to the definition // CreateType(const RecordType*) will overwrite this with the members in the // correct order if the full type is needed. - DBuilder.replaceArrays(Res, T ? T.getElements() : llvm::DIArray()); + DBuilder.replaceArrays(Res, T ? T->getElements() : llvm::DIArray()); // And update the type cache. TypeCache[QTy.getAsOpaquePtr()].reset(Res); @@ -2255,9 +2252,9 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { // If we ended up creating the type during the context chain construction, // just return that. - llvm::DICompositeType T = cast_or_null( + auto *T = cast_or_null( getTypeOrNull(CGM.getContext().getRecordType(RD))); - if (T && (!T.isForwardDecl() || !RD->getDefinition())) + if (T && (!T->isForwardDecl() || !RD->getDefinition())) return T; // If this is just a forward or incomplete declaration, construct an @@ -3277,7 +3274,7 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, Ty = getOrCreateType(QualType(ED->getTypeForDecl(), 0), Unit); } // Do not use DIGlobalVariable for enums. - if (Ty.getTag() == llvm::dwarf::DW_TAG_enumeration_type) + if (Ty->getTag() == llvm::dwarf::DW_TAG_enumeration_type) return; // Do not emit separate definitions for function local const/statics. if (isa(VD->getDeclContext())) @@ -3390,8 +3387,8 @@ void CGDebugInfo::finalize() { for (auto p : ReplaceMap) { assert(p.second); - llvm::DIType Ty = cast(p.second); - assert(Ty.isForwardDecl()); + auto *Ty = cast(p.second); + assert(Ty->isForwardDecl()); auto it = TypeCache.find(p.first); assert(it != TypeCache.end());