DebugInfo: Prepare for deletion of subclasses of DIScope

Prepare for the deletion in LLVM of the subclasses of (the already
deleted) `DIScope` by using the raw pointers they were wrapping
directly.

llvm-svn: 235355
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-20 22:09:57 +00:00
parent 41758517bf
commit a7fbcbfe00
2 changed files with 128 additions and 128 deletions

View File

@ -243,7 +243,7 @@ StringRef CGDebugInfo::getClassName(const RecordDecl *RD) {
} }
/// getOrCreateFile - Get the file debug info descriptor for the input location. /// getOrCreateFile - Get the file debug info descriptor for the input location.
llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) { llvm::MDFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
if (!Loc.isValid()) if (!Loc.isValid())
// If Location is not valid then use main input file. // If Location is not valid then use main input file.
return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory()); return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory());
@ -265,14 +265,15 @@ llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
return cast<llvm::MDFile>(V); return cast<llvm::MDFile>(V);
} }
llvm::DIFile F = DBuilder.createFile(PLoc.getFilename(), getCurrentDirname()); llvm::MDFile *F =
DBuilder.createFile(PLoc.getFilename(), getCurrentDirname());
DIFileCache[fname].reset(F); DIFileCache[fname].reset(F);
return F; return F;
} }
/// getOrCreateMainFile - Get the file info for main compile unit. /// getOrCreateMainFile - Get the file info for main compile unit.
llvm::DIFile CGDebugInfo::getOrCreateMainFile() { llvm::MDFile *CGDebugInfo::getOrCreateMainFile() {
return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory()); return DBuilder.createFile(TheCU->getFilename(), TheCU->getDirectory());
} }
@ -535,7 +536,8 @@ llvm::MDType *CGDebugInfo::CreateType(const ComplexType *Ty) {
/// CreateCVRType - Get the qualified type from the cache or create /// CreateCVRType - Get the qualified type from the cache or create
/// a new one if necessary. /// a new one if necessary.
llvm::MDType *CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile Unit) { llvm::MDType *CGDebugInfo::CreateQualifiedType(QualType Ty,
llvm::MDFile *Unit) {
QualifierCollector Qc; QualifierCollector Qc;
const Type *T = Qc.strip(Ty); const Type *T = Qc.strip(Ty);
@ -569,7 +571,7 @@ llvm::MDType *CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile Unit) {
} }
llvm::MDType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty, llvm::MDType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
// The frontend treats 'id' as a typedef to an ObjCObjectType, // The frontend treats 'id' as a typedef to an ObjCObjectType,
// whereas 'id<protocol>' is treated as an ObjCPointerType. For the // whereas 'id<protocol>' is treated as an ObjCPointerType. For the
@ -582,7 +584,7 @@ llvm::MDType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
} }
llvm::MDType *CGDebugInfo::CreateType(const PointerType *Ty, llvm::MDType *CGDebugInfo::CreateType(const PointerType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty, return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty,
Ty->getPointeeType(), Unit); Ty->getPointeeType(), Unit);
} }
@ -591,7 +593,7 @@ llvm::MDType *CGDebugInfo::CreateType(const PointerType *Ty,
/// on their mangled names, if they're external. /// on their mangled names, if they're external.
static SmallString<256> getUniqueTagTypeName(const TagType *Ty, static SmallString<256> getUniqueTagTypeName(const TagType *Ty,
CodeGenModule &CGM, CodeGenModule &CGM,
llvm::DICompileUnit TheCU) { llvm::MDCompileUnit *TheCU) {
SmallString<256> FullName; SmallString<256> FullName;
// FIXME: ODR should apply to ObjC++ exactly the same wasy it does to C++. // FIXME: ODR should apply to ObjC++ exactly the same wasy it does to C++.
// For now, only apply ODR with C++. // For now, only apply ODR with C++.
@ -633,7 +635,7 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty,
const RecordDecl *RD = Ty->getDecl(); const RecordDecl *RD = Ty->getDecl();
if (llvm::MDType *T = getTypeOrNull(CGM.getContext().getRecordType(RD))) if (llvm::MDType *T = getTypeOrNull(CGM.getContext().getRecordType(RD)))
return cast<llvm::MDCompositeType>(T); return cast<llvm::MDCompositeType>(T);
llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation()); llvm::MDFile *DefUnit = getOrCreateFile(RD->getLocation());
unsigned Line = getLineNumber(RD->getLocation()); unsigned Line = getLineNumber(RD->getLocation());
StringRef RDName = getClassName(RD); StringRef RDName = getClassName(RD);
@ -660,7 +662,7 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty,
llvm::MDType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag, llvm::MDType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag,
const Type *Ty, const Type *Ty,
QualType PointeeTy, QualType PointeeTy,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
if (Tag == llvm::dwarf::DW_TAG_reference_type || if (Tag == llvm::dwarf::DW_TAG_reference_type ||
Tag == llvm::dwarf::DW_TAG_rvalue_reference_type) Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
return DBuilder.createReferenceType(Tag, getOrCreateType(PointeeTy, Unit)); return DBuilder.createReferenceType(Tag, getOrCreateType(PointeeTy, Unit));
@ -688,7 +690,7 @@ llvm::MDType *CGDebugInfo::getOrCreateStructPtrType(StringRef Name,
} }
llvm::MDType *CGDebugInfo::CreateType(const BlockPointerType *Ty, llvm::MDType *CGDebugInfo::CreateType(const BlockPointerType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
if (BlockLiteralGeneric) if (BlockLiteralGeneric)
return BlockLiteralGeneric; return BlockLiteralGeneric;
@ -746,7 +748,7 @@ llvm::MDType *CGDebugInfo::CreateType(const BlockPointerType *Ty,
} }
llvm::MDType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, llvm::MDType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
assert(Ty->isTypeAlias()); assert(Ty->isTypeAlias());
llvm::MDType *Src = getOrCreateType(Ty->getAliasedType(), Unit); llvm::MDType *Src = getOrCreateType(Ty->getAliasedType(), Unit);
@ -769,7 +771,7 @@ llvm::MDType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,
} }
llvm::MDType *CGDebugInfo::CreateType(const TypedefType *Ty, llvm::MDType *CGDebugInfo::CreateType(const TypedefType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
// We don't set size information, but do specify where the typedef was // We don't set size information, but do specify where the typedef was
// declared. // declared.
SourceLocation Loc = Ty->getDecl()->getLocation(); SourceLocation Loc = Ty->getDecl()->getLocation();
@ -782,7 +784,7 @@ llvm::MDType *CGDebugInfo::CreateType(const TypedefType *Ty,
} }
llvm::MDType *CGDebugInfo::CreateType(const FunctionType *Ty, llvm::MDType *CGDebugInfo::CreateType(const FunctionType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
SmallVector<llvm::Metadata *, 16> EltTys; SmallVector<llvm::Metadata *, 16> EltTys;
// Add the result type at least. // Add the result type at least.
@ -871,7 +873,7 @@ void CGDebugInfo::CollectRecordLambdaFields(
const LambdaCapture &C = *I; const LambdaCapture &C = *I;
if (C.capturesVariable()) { if (C.capturesVariable()) {
VarDecl *V = C.getCapturedVar(); VarDecl *V = C.getCapturedVar();
llvm::DIFile VUnit = getOrCreateFile(C.getLocation()); llvm::MDFile *VUnit = getOrCreateFile(C.getLocation());
StringRef VName = V->getName(); StringRef VName = V->getName();
uint64_t SizeInBitsOverride = 0; uint64_t SizeInBitsOverride = 0;
if (Field->isBitField()) { if (Field->isBitField()) {
@ -889,7 +891,7 @@ void CGDebugInfo::CollectRecordLambdaFields(
// by using AT_object_pointer for the function and having that be // by using AT_object_pointer for the function and having that be
// used as 'this' for semantic references. // used as 'this' for semantic references.
FieldDecl *f = *Field; FieldDecl *f = *Field;
llvm::DIFile VUnit = getOrCreateFile(f->getLocation()); llvm::MDFile *VUnit = getOrCreateFile(f->getLocation());
QualType type = f->getType(); QualType type = f->getType();
llvm::MDType *fieldType = createFieldType( llvm::MDType *fieldType = createFieldType(
"this", type, 0, f->getLocation(), f->getAccess(), "this", type, 0, f->getLocation(), f->getAccess(),
@ -907,7 +909,7 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::MDType *RecordTy,
// Create the descriptor for the static variable, with or without // Create the descriptor for the static variable, with or without
// constant initializers. // constant initializers.
Var = Var->getCanonicalDecl(); Var = Var->getCanonicalDecl();
llvm::DIFile VUnit = getOrCreateFile(Var->getLocation()); llvm::MDFile *VUnit = getOrCreateFile(Var->getLocation());
llvm::MDType *VTy = getOrCreateType(Var->getType(), VUnit); llvm::MDType *VTy = getOrCreateType(Var->getType(), VUnit);
unsigned LineNumber = getLineNumber(Var->getLocation()); unsigned LineNumber = getLineNumber(Var->getLocation());
@ -932,7 +934,7 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::MDType *RecordTy,
/// CollectRecordNormalField - Helper for CollectRecordFields. /// CollectRecordNormalField - Helper for CollectRecordFields.
void CGDebugInfo::CollectRecordNormalField( void CGDebugInfo::CollectRecordNormalField(
const FieldDecl *field, uint64_t OffsetInBits, llvm::DIFile tunit, const FieldDecl *field, uint64_t OffsetInBits, llvm::MDFile *tunit,
SmallVectorImpl<llvm::Metadata *> &elements, llvm::MDType *RecordTy, SmallVectorImpl<llvm::Metadata *> &elements, llvm::MDType *RecordTy,
const RecordDecl *RD) { const RecordDecl *RD) {
StringRef name = field->getName(); StringRef name = field->getName();
@ -958,7 +960,7 @@ void CGDebugInfo::CollectRecordNormalField(
/// CollectRecordFields - A helper function to collect debug info for /// CollectRecordFields - A helper function to collect debug info for
/// record fields. This is used while creating debug info entry for a Record. /// record fields. This is used while creating debug info entry for a Record.
void CGDebugInfo::CollectRecordFields( void CGDebugInfo::CollectRecordFields(
const RecordDecl *record, llvm::DIFile tunit, const RecordDecl *record, llvm::MDFile *tunit,
SmallVectorImpl<llvm::Metadata *> &elements, SmallVectorImpl<llvm::Metadata *> &elements,
llvm::MDCompositeType *RecordTy) { llvm::MDCompositeType *RecordTy) {
const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(record); const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(record);
@ -1000,7 +1002,7 @@ void CGDebugInfo::CollectRecordFields(
/// routine to get a method type which includes "this" pointer. /// routine to get a method type which includes "this" pointer.
llvm::MDSubroutineType * llvm::MDSubroutineType *
CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method, CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
const FunctionProtoType *Func = Method->getType()->getAs<FunctionProtoType>(); const FunctionProtoType *Func = Method->getType()->getAs<FunctionProtoType>();
if (Method->isStatic()) if (Method->isStatic())
return cast_or_null<llvm::MDSubroutineType>( return cast_or_null<llvm::MDSubroutineType>(
@ -1010,7 +1012,7 @@ CGDebugInfo::getOrCreateMethodType(const CXXMethodDecl *Method,
} }
llvm::MDSubroutineType *CGDebugInfo::getOrCreateInstanceMethodType( llvm::MDSubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
QualType ThisPtr, const FunctionProtoType *Func, llvm::DIFile Unit) { QualType ThisPtr, const FunctionProtoType *Func, llvm::MDFile *Unit) {
// Add "this" pointer. // Add "this" pointer.
llvm::DITypeArray Args( llvm::DITypeArray Args(
cast<llvm::MDSubroutineType>(getOrCreateType(QualType(Func, 0), Unit)) cast<llvm::MDSubroutineType>(getOrCreateType(QualType(Func, 0), Unit))
@ -1072,9 +1074,9 @@ static bool isFunctionLocalClass(const CXXRecordDecl *RD) {
return false; return false;
} }
/// CreateCXXMemberFunction - A helper function to create a DISubprogram for /// CreateCXXMemberFunction - A helper function to create a subprogram for
/// a single member function GlobalDecl. /// a single member function GlobalDecl.
llvm::DISubprogram CGDebugInfo::CreateCXXMemberFunction( llvm::MDSubprogram *CGDebugInfo::CreateCXXMemberFunction(
const CXXMethodDecl *Method, llvm::MDFile *Unit, llvm::MDType *RecordTy) { const CXXMethodDecl *Method, llvm::MDFile *Unit, llvm::MDType *RecordTy) {
bool IsCtorOrDtor = bool IsCtorOrDtor =
isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method); isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method);
@ -1089,7 +1091,7 @@ llvm::DISubprogram CGDebugInfo::CreateCXXMemberFunction(
MethodLinkageName = CGM.getMangledName(Method); MethodLinkageName = CGM.getMangledName(Method);
// Get the location for the method. // Get the location for the method.
llvm::DIFile MethodDefUnit; llvm::MDFile *MethodDefUnit = nullptr;
unsigned MethodLine = 0; unsigned MethodLine = 0;
if (!Method->isImplicit()) { if (!Method->isImplicit()) {
MethodDefUnit = getOrCreateFile(Method->getLocation()); MethodDefUnit = getOrCreateFile(Method->getLocation());
@ -1138,7 +1140,7 @@ llvm::DISubprogram CGDebugInfo::CreateCXXMemberFunction(
Flags |= llvm::DebugNode::FlagRValueReference; Flags |= llvm::DebugNode::FlagRValueReference;
llvm::DIArray TParamsArray = CollectFunctionTemplateParams(Method, Unit); llvm::DIArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
llvm::DISubprogram SP = DBuilder.createMethod( llvm::MDSubprogram *SP = DBuilder.createMethod(
RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine, RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
MethodTy, /*isLocalToUnit=*/false, MethodTy, /*isLocalToUnit=*/false,
/* isDefinition=*/false, Virtuality, VIndex, ContainingType, Flags, /* isDefinition=*/false, Virtuality, VIndex, ContainingType, Flags,
@ -1233,7 +1235,7 @@ void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::MDFile *Unit,
llvm::DIArray llvm::DIArray
CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
ArrayRef<TemplateArgument> TAList, ArrayRef<TemplateArgument> TAList,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
SmallVector<llvm::Metadata *, 16> TemplateParams; SmallVector<llvm::Metadata *, 16> TemplateParams;
for (unsigned i = 0, e = TAList.size(); i != e; ++i) { for (unsigned i = 0, e = TAList.size(); i != e; ++i) {
const TemplateArgument &TA = TAList[i]; const TemplateArgument &TA = TAList[i];
@ -1350,7 +1352,7 @@ CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList,
/// CollectFunctionTemplateParams - A helper function to collect debug /// CollectFunctionTemplateParams - A helper function to collect debug
/// info for function template parameters. /// info for function template parameters.
llvm::DIArray CGDebugInfo::CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIArray CGDebugInfo::CollectFunctionTemplateParams(const FunctionDecl *FD,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
if (FD->getTemplatedKind() == if (FD->getTemplatedKind() ==
FunctionDecl::TK_FunctionTemplateSpecialization) { FunctionDecl::TK_FunctionTemplateSpecialization) {
const TemplateParameterList *TList = FD->getTemplateSpecializationInfo() const TemplateParameterList *TList = FD->getTemplateSpecializationInfo()
@ -1365,7 +1367,7 @@ llvm::DIArray CGDebugInfo::CollectFunctionTemplateParams(const FunctionDecl *FD,
/// CollectCXXTemplateParams - A helper function to collect debug info for /// CollectCXXTemplateParams - A helper function to collect debug info for
/// template parameters. /// template parameters.
llvm::DIArray CGDebugInfo::CollectCXXTemplateParams( llvm::DIArray CGDebugInfo::CollectCXXTemplateParams(
const ClassTemplateSpecializationDecl *TSpecial, llvm::DIFile Unit) { const ClassTemplateSpecializationDecl *TSpecial, llvm::MDFile *Unit) {
// Always get the full list of parameters, not just the ones from // Always get the full list of parameters, not just the ones from
// the specialization. // the specialization.
TemplateParameterList *TPList = TemplateParameterList *TPList =
@ -1375,7 +1377,7 @@ llvm::DIArray CGDebugInfo::CollectCXXTemplateParams(
} }
/// getOrCreateVTablePtrType - Return debug info descriptor for vtable. /// getOrCreateVTablePtrType - Return debug info descriptor for vtable.
llvm::MDType *CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile Unit) { llvm::MDType *CGDebugInfo::getOrCreateVTablePtrType(llvm::MDFile *Unit) {
if (VTablePtrType) if (VTablePtrType)
return VTablePtrType; return VTablePtrType;
@ -1400,7 +1402,7 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) {
/// CollectVTableInfo - If the C++ class has vtable info then insert appropriate /// CollectVTableInfo - If the C++ class has vtable info then insert appropriate
/// debug info entry in EltTys vector. /// debug info entry in EltTys vector.
void CGDebugInfo::CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit, void CGDebugInfo::CollectVTableInfo(const CXXRecordDecl *RD, llvm::MDFile *Unit,
SmallVectorImpl<llvm::Metadata *> &EltTys) { SmallVectorImpl<llvm::Metadata *> &EltTys) {
const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD); const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
@ -1544,7 +1546,7 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
RecordDecl *RD = Ty->getDecl(); RecordDecl *RD = Ty->getDecl();
// Get overall information about the record type for the debug info. // Get overall information about the record type for the debug info.
llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation()); llvm::MDFile *DefUnit = getOrCreateFile(RD->getLocation());
// Records and classes and unions can all be recursive. To handle them, we // Records and classes and unions can all be recursive. To handle them, we
// first generate a debug descriptor for the struct as a forward declaration. // first generate a debug descriptor for the struct as a forward declaration.
@ -1602,7 +1604,7 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
/// CreateType - get objective-c object type. /// CreateType - get objective-c object type.
llvm::MDType *CGDebugInfo::CreateType(const ObjCObjectType *Ty, llvm::MDType *CGDebugInfo::CreateType(const ObjCObjectType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
// Ignore protocols. // Ignore protocols.
return getOrCreateType(Ty->getBaseType(), Unit); return getOrCreateType(Ty->getBaseType(), Unit);
} }
@ -1633,13 +1635,13 @@ static bool hasDefaultSetterName(const ObjCPropertyDecl *PD,
/// CreateType - get objective-c interface type. /// CreateType - get objective-c interface type.
llvm::MDType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, llvm::MDType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
ObjCInterfaceDecl *ID = Ty->getDecl(); ObjCInterfaceDecl *ID = Ty->getDecl();
if (!ID) if (!ID)
return nullptr; return nullptr;
// Get overall information about the record type for the debug info. // Get overall information about the record type for the debug info.
llvm::DIFile DefUnit = getOrCreateFile(ID->getLocation()); llvm::MDFile *DefUnit = getOrCreateFile(ID->getLocation());
unsigned Line = getLineNumber(ID->getLocation()); unsigned Line = getLineNumber(ID->getLocation());
auto RuntimeLang = auto RuntimeLang =
static_cast<llvm::dwarf::SourceLanguage>(TheCU->getSourceLanguage()); static_cast<llvm::dwarf::SourceLanguage>(TheCU->getSourceLanguage());
@ -1659,9 +1661,9 @@ llvm::MDType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
} }
llvm::MDType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm::MDType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
ObjCInterfaceDecl *ID = Ty->getDecl(); ObjCInterfaceDecl *ID = Ty->getDecl();
llvm::DIFile DefUnit = getOrCreateFile(ID->getLocation()); llvm::MDFile *DefUnit = getOrCreateFile(ID->getLocation());
unsigned Line = getLineNumber(ID->getLocation()); unsigned Line = getLineNumber(ID->getLocation());
unsigned RuntimeLang = TheCU->getSourceLanguage(); unsigned RuntimeLang = TheCU->getSourceLanguage();
@ -1701,7 +1703,7 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
// Create entries for all of the properties. // Create entries for all of the properties.
for (const auto *PD : ID->properties()) { for (const auto *PD : ID->properties()) {
SourceLocation Loc = PD->getLocation(); SourceLocation Loc = PD->getLocation();
llvm::DIFile PUnit = getOrCreateFile(Loc); llvm::MDFile *PUnit = getOrCreateFile(Loc);
unsigned PLine = getLineNumber(Loc); unsigned PLine = getLineNumber(Loc);
ObjCMethodDecl *Getter = PD->getGetterMethodDecl(); ObjCMethodDecl *Getter = PD->getGetterMethodDecl();
ObjCMethodDecl *Setter = PD->getSetterMethodDecl(); ObjCMethodDecl *Setter = PD->getSetterMethodDecl();
@ -1730,7 +1732,7 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
continue; continue;
// Get the location for the field. // Get the location for the field.
llvm::DIFile FieldDefUnit = getOrCreateFile(Field->getLocation()); llvm::MDFile *FieldDefUnit = getOrCreateFile(Field->getLocation());
unsigned FieldLine = getLineNumber(Field->getLocation()); unsigned FieldLine = getLineNumber(Field->getLocation());
QualType FType = Field->getType(); QualType FType = Field->getType();
uint64_t FieldSize = 0; uint64_t FieldSize = 0;
@ -1775,7 +1777,7 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) { ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) {
if (ObjCPropertyDecl *PD = PImpD->getPropertyDecl()) { if (ObjCPropertyDecl *PD = PImpD->getPropertyDecl()) {
SourceLocation Loc = PD->getLocation(); SourceLocation Loc = PD->getLocation();
llvm::DIFile PUnit = getOrCreateFile(Loc); llvm::MDFile *PUnit = getOrCreateFile(Loc);
unsigned PLine = getLineNumber(Loc); unsigned PLine = getLineNumber(Loc);
ObjCMethodDecl *Getter = PD->getGetterMethodDecl(); ObjCMethodDecl *Getter = PD->getGetterMethodDecl();
ObjCMethodDecl *Setter = PD->getSetterMethodDecl(); ObjCMethodDecl *Setter = PD->getSetterMethodDecl();
@ -1803,7 +1805,8 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
return RealDecl; return RealDecl;
} }
llvm::MDType *CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) { llvm::MDType *CGDebugInfo::CreateType(const VectorType *Ty,
llvm::MDFile *Unit) {
llvm::MDType *ElementTy = getOrCreateType(Ty->getElementType(), Unit); llvm::MDType *ElementTy = getOrCreateType(Ty->getElementType(), Unit);
int64_t Count = Ty->getNumElements(); int64_t Count = Ty->getNumElements();
if (Count == 0) if (Count == 0)
@ -1820,7 +1823,7 @@ llvm::MDType *CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) {
return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray); return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray);
} }
llvm::MDType *CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIFile Unit) { llvm::MDType *CGDebugInfo::CreateType(const ArrayType *Ty, llvm::MDFile *Unit) {
uint64_t Size; uint64_t Size;
uint64_t Align; uint64_t Align;
@ -1873,19 +1876,19 @@ llvm::MDType *CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIFile Unit) {
} }
llvm::MDType *CGDebugInfo::CreateType(const LValueReferenceType *Ty, llvm::MDType *CGDebugInfo::CreateType(const LValueReferenceType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
return CreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type, Ty, return CreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type, Ty,
Ty->getPointeeType(), Unit); Ty->getPointeeType(), Unit);
} }
llvm::MDType *CGDebugInfo::CreateType(const RValueReferenceType *Ty, llvm::MDType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty, return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
Ty->getPointeeType(), Unit); Ty->getPointeeType(), Unit);
} }
llvm::MDType *CGDebugInfo::CreateType(const MemberPointerType *Ty, llvm::MDType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
llvm::DIFile U) { llvm::MDFile *U) {
llvm::MDType *ClassType = getOrCreateType(QualType(Ty->getClass(), 0), U); llvm::MDType *ClassType = getOrCreateType(QualType(Ty->getClass(), 0), U);
if (!Ty->getPointeeType()->isFunctionType()) if (!Ty->getPointeeType()->isFunctionType())
return DBuilder.createMemberPointerType( return DBuilder.createMemberPointerType(
@ -1901,7 +1904,7 @@ llvm::MDType *CGDebugInfo::CreateType(const MemberPointerType *Ty,
ClassType, CGM.getContext().getTypeSize(Ty)); ClassType, CGM.getContext().getTypeSize(Ty));
} }
llvm::MDType *CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile U) { llvm::MDType *CGDebugInfo::CreateType(const AtomicType *Ty, llvm::MDFile *U) {
// Ignore the atomic wrapping // Ignore the atomic wrapping
// FIXME: What is the correct representation? // FIXME: What is the correct representation?
return getOrCreateType(Ty->getValueType(), U); return getOrCreateType(Ty->getValueType(), U);
@ -1924,7 +1927,7 @@ llvm::MDType *CGDebugInfo::CreateEnumType(const EnumType *Ty) {
if (!ED->getDefinition()) { if (!ED->getDefinition()) {
llvm::MDScope *EDContext = llvm::MDScope *EDContext =
getContextDescriptor(cast<Decl>(ED->getDeclContext())); getContextDescriptor(cast<Decl>(ED->getDeclContext()));
llvm::DIFile DefUnit = getOrCreateFile(ED->getLocation()); llvm::MDFile *DefUnit = getOrCreateFile(ED->getLocation());
unsigned Line = getLineNumber(ED->getLocation()); unsigned Line = getLineNumber(ED->getLocation());
StringRef EDName = ED->getName(); StringRef EDName = ED->getName();
llvm::MDType *RetTy = DBuilder.createReplaceableCompositeType( llvm::MDType *RetTy = DBuilder.createReplaceableCompositeType(
@ -1961,7 +1964,7 @@ llvm::MDType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
// Return a CompositeType for the enum itself. // Return a CompositeType for the enum itself.
llvm::DIArray EltArray = DBuilder.getOrCreateArray(Enumerators); llvm::DIArray EltArray = DBuilder.getOrCreateArray(Enumerators);
llvm::DIFile DefUnit = getOrCreateFile(ED->getLocation()); llvm::MDFile *DefUnit = getOrCreateFile(ED->getLocation());
unsigned Line = getLineNumber(ED->getLocation()); unsigned Line = getLineNumber(ED->getLocation());
llvm::MDScope *EnumContext = llvm::MDScope *EnumContext =
getContextDescriptor(cast<Decl>(ED->getDeclContext())); getContextDescriptor(cast<Decl>(ED->getDeclContext()));
@ -2057,7 +2060,7 @@ void CGDebugInfo::completeTemplateDefinition(
/// getOrCreateType - Get the type from the cache or create a new /// getOrCreateType - Get the type from the cache or create a new
/// one if necessary. /// one if necessary.
llvm::MDType *CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit) { llvm::MDType *CGDebugInfo::getOrCreateType(QualType Ty, llvm::MDFile *Unit) {
if (Ty.isNull()) if (Ty.isNull())
return nullptr; return nullptr;
@ -2104,7 +2107,7 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCInterfaceDecl(QualType Ty) {
} }
/// CreateTypeNode - Create a new debug type node. /// CreateTypeNode - Create a new debug type node.
llvm::MDType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) { llvm::MDType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::MDFile *Unit) {
// Handle qualifiers, which recursively handles what they refer to. // Handle qualifiers, which recursively handles what they refer to.
if (Ty.hasLocalQualifiers()) if (Ty.hasLocalQualifiers())
return CreateQualifiedType(Ty, Unit); return CreateQualifiedType(Ty, Unit);
@ -2187,7 +2190,7 @@ llvm::MDType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) {
/// getOrCreateLimitedType - Get the type from the cache or create a new /// getOrCreateLimitedType - Get the type from the cache or create a new
/// limited type if necessary. /// limited type if necessary.
llvm::MDType *CGDebugInfo::getOrCreateLimitedType(const RecordType *Ty, llvm::MDType *CGDebugInfo::getOrCreateLimitedType(const RecordType *Ty,
llvm::DIFile Unit) { llvm::MDFile *Unit) {
QualType QTy(Ty, 0); QualType QTy(Ty, 0);
auto *T = cast_or_null<llvm::MDCompositeTypeBase>(getTypeOrNull(QTy)); auto *T = cast_or_null<llvm::MDCompositeTypeBase>(getTypeOrNull(QTy));
@ -2216,7 +2219,7 @@ llvm::MDCompositeType *CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
RecordDecl *RD = Ty->getDecl(); RecordDecl *RD = Ty->getDecl();
// Get overall information about the record type for the debug info. // Get overall information about the record type for the debug info.
llvm::DIFile DefUnit = getOrCreateFile(RD->getLocation()); llvm::MDFile *DefUnit = getOrCreateFile(RD->getLocation());
unsigned Line = getLineNumber(RD->getLocation()); unsigned Line = getLineNumber(RD->getLocation());
StringRef RDName = getClassName(RD); StringRef RDName = getClassName(RD);
@ -2280,7 +2283,7 @@ void CGDebugInfo::CollectContainingType(const CXXRecordDecl *RD,
} }
/// CreateMemberType - Create new member and increase Offset by FType's size. /// CreateMemberType - Create new member and increase Offset by FType's size.
llvm::MDType *CGDebugInfo::CreateMemberType(llvm::DIFile Unit, QualType FType, llvm::MDType *CGDebugInfo::CreateMemberType(llvm::MDFile *Unit, QualType FType,
StringRef Name, uint64_t *Offset) { StringRef Name, uint64_t *Offset) {
llvm::MDType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit); llvm::MDType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
uint64_t FieldSize = CGM.getContext().getTypeSize(FType); uint64_t FieldSize = CGM.getContext().getTypeSize(FType);
@ -2292,7 +2295,7 @@ llvm::MDType *CGDebugInfo::CreateMemberType(llvm::DIFile Unit, QualType FType,
} }
void CGDebugInfo::collectFunctionDeclProps( void CGDebugInfo::collectFunctionDeclProps(
GlobalDecl GD, llvm::DIFile Unit, StringRef &Name, StringRef &LinkageName, GlobalDecl GD, llvm::MDFile *Unit, StringRef &Name, StringRef &LinkageName,
llvm::MDScope *&FDContext, llvm::DIArray &TParamsArray, unsigned &Flags) { llvm::MDScope *&FDContext, llvm::DIArray &TParamsArray, unsigned &Flags) {
const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl()); const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
Name = getFunctionName(FD); Name = getFunctionName(FD);
@ -2322,7 +2325,7 @@ void CGDebugInfo::collectFunctionDeclProps(
} }
} }
void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile &Unit, void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::MDFile *&Unit,
unsigned &LineNo, QualType &T, unsigned &LineNo, QualType &T,
StringRef &Name, StringRef &LinkageName, StringRef &Name, StringRef &LinkageName,
llvm::MDScope *&VDContext) { llvm::MDScope *&VDContext) {
@ -2367,13 +2370,13 @@ void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile &Unit,
VDContext = getContextDescriptor(dyn_cast<Decl>(DC)); VDContext = getContextDescriptor(dyn_cast<Decl>(DC));
} }
llvm::DISubprogram llvm::MDSubprogram *
CGDebugInfo::getFunctionForwardDeclaration(const FunctionDecl *FD) { CGDebugInfo::getFunctionForwardDeclaration(const FunctionDecl *FD) {
llvm::DIArray TParamsArray; llvm::DIArray TParamsArray;
StringRef Name, LinkageName; StringRef Name, LinkageName;
unsigned Flags = 0; unsigned Flags = 0;
SourceLocation Loc = FD->getLocation(); SourceLocation Loc = FD->getLocation();
llvm::DIFile Unit = getOrCreateFile(Loc); llvm::MDFile *Unit = getOrCreateFile(Loc);
llvm::MDScope *DContext = Unit; llvm::MDScope *DContext = Unit;
unsigned Line = getLineNumber(Loc); unsigned Line = getLineNumber(Loc);
@ -2403,7 +2406,7 @@ CGDebugInfo::getGlobalVariableForwardDeclaration(const VarDecl *VD) {
QualType T; QualType T;
StringRef Name, LinkageName; StringRef Name, LinkageName;
SourceLocation Loc = VD->getLocation(); SourceLocation Loc = VD->getLocation();
llvm::DIFile Unit = getOrCreateFile(Loc); llvm::MDFile *Unit = getOrCreateFile(Loc);
llvm::MDScope *DContext = Unit; llvm::MDScope *DContext = Unit;
unsigned Line = getLineNumber(Loc); unsigned Line = getLineNumber(Loc);
@ -2445,13 +2448,13 @@ llvm::DebugNode *CGDebugInfo::getDeclarationOrDefinition(const Decl *D) {
/// getFunctionDeclaration - Return debug info descriptor to describe method /// getFunctionDeclaration - Return debug info descriptor to describe method
/// declaration for the given method definition. /// declaration for the given method definition.
llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) { llvm::MDSubprogram *CGDebugInfo::getFunctionDeclaration(const Decl *D) {
if (!D || DebugKind <= CodeGenOptions::DebugLineTablesOnly) if (!D || DebugKind <= CodeGenOptions::DebugLineTablesOnly)
return llvm::DISubprogram(); return nullptr;
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D); const FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
if (!FD) if (!FD)
return llvm::DISubprogram(); return nullptr;
// Setup context. // Setup context.
auto *S = getContextDescriptor(cast<Decl>(D->getDeclContext())); auto *S = getContextDescriptor(cast<Decl>(D->getDeclContext()));
@ -2478,19 +2481,17 @@ llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) {
return SP; return SP;
} }
} }
return llvm::DISubprogram(); return nullptr;
} }
// getOrCreateFunctionType - Construct type. If it is a c++ method, include // getOrCreateFunctionType - Construct type. If it is a c++ method, include
// implicit parameter "this". // implicit parameter "this".
llvm::MDSubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D, llvm::MDSubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
QualType FnType, QualType FnType,
llvm::DIFile F) { llvm::MDFile *F) {
if (!D || DebugKind <= CodeGenOptions::DebugLineTablesOnly) if (!D || DebugKind <= CodeGenOptions::DebugLineTablesOnly)
// Create fake but valid subroutine type. Otherwise // Create fake but valid subroutine type. Otherwise -verify would fail, and
// llvm::DISubprogram::Verify() would return false, and // subprogram DIE will miss DW_AT_decl_file and DW_AT_decl_line fields.
// subprogram DIE will miss DW_AT_decl_file and
// DW_AT_decl_line fields.
return DBuilder.createSubroutineType(F, return DBuilder.createSubroutineType(F,
DBuilder.getOrCreateTypeArray(None)); DBuilder.getOrCreateTypeArray(None));
@ -2557,14 +2558,14 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
bool HasDecl = (D != nullptr); bool HasDecl = (D != nullptr);
unsigned Flags = 0; unsigned Flags = 0;
llvm::DIFile Unit = getOrCreateFile(Loc); llvm::MDFile *Unit = getOrCreateFile(Loc);
llvm::MDScope *FDContext = Unit; llvm::MDScope *FDContext = Unit;
llvm::DIArray TParamsArray; llvm::DIArray TParamsArray;
if (!HasDecl) { if (!HasDecl) {
// Use llvm function name. // Use llvm function name.
LinkageName = Fn->getName(); LinkageName = Fn->getName();
} else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) { } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
// If there is a DISubprogram for this function available then use it. // If there is a subprogram for this function available then use it.
auto FI = SPCache.find(FD->getCanonicalDecl()); auto FI = SPCache.find(FD->getCanonicalDecl());
if (FI != SPCache.end()) { if (FI != SPCache.end()) {
auto *SP = dyn_cast_or_null<llvm::MDSubprogram>(FI->second); auto *SP = dyn_cast_or_null<llvm::MDSubprogram>(FI->second);
@ -2601,7 +2602,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
// FunctionDecls. When/if we fix this we can have FDContext be TheCU/null for // FunctionDecls. When/if we fix this we can have FDContext be TheCU/null for
// all subprograms instead of the actual context since subprogram definitions // all subprograms instead of the actual context since subprogram definitions
// are emitted as CU level entities by the backend. // are emitted as CU level entities by the backend.
llvm::DISubprogram SP = DBuilder.createFunction( llvm::MDSubprogram *SP = DBuilder.createFunction(
FDContext, Name, LinkageName, Unit, LineNo, FDContext, Name, LinkageName, Unit, LineNo,
getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(), getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(),
true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize, Fn, true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize, Fn,
@ -2703,7 +2704,7 @@ llvm::MDType *CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD,
uint64_t FieldSize, FieldOffset; uint64_t FieldSize, FieldOffset;
unsigned FieldAlign; unsigned FieldAlign;
llvm::DIFile Unit = getOrCreateFile(VD->getLocation()); llvm::MDFile *Unit = getOrCreateFile(VD->getLocation());
QualType Type = VD->getType(); QualType Type = VD->getType();
FieldOffset = 0; FieldOffset = 0;
@ -2778,7 +2779,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::Tag Tag,
bool Unwritten = bool Unwritten =
VD->isImplicit() || (isa<Decl>(VD->getDeclContext()) && VD->isImplicit() || (isa<Decl>(VD->getDeclContext()) &&
cast<Decl>(VD->getDeclContext())->isImplicit()); cast<Decl>(VD->getDeclContext())->isImplicit());
llvm::DIFile Unit; llvm::MDFile *Unit = nullptr;
if (!Unwritten) if (!Unwritten)
Unit = getOrCreateFile(VD->getLocation()); Unit = getOrCreateFile(VD->getLocation());
llvm::MDType *Ty; llvm::MDType *Ty;
@ -2915,7 +2916,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
bool isByRef = VD->hasAttr<BlocksAttr>(); bool isByRef = VD->hasAttr<BlocksAttr>();
uint64_t XOffset = 0; uint64_t XOffset = 0;
llvm::DIFile Unit = getOrCreateFile(VD->getLocation()); llvm::MDFile *Unit = getOrCreateFile(VD->getLocation());
llvm::MDType *Ty; llvm::MDType *Ty;
if (isByRef) if (isByRef)
Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset); Ty = EmitTypeForVarWithBlocksAttr(VD, &XOffset);
@ -3002,7 +3003,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
// Collect some general information about the block's location. // Collect some general information about the block's location.
SourceLocation loc = blockDecl->getCaretLocation(); SourceLocation loc = blockDecl->getCaretLocation();
llvm::DIFile tunit = getOrCreateFile(loc); llvm::MDFile *tunit = getOrCreateFile(loc);
unsigned line = getLineNumber(loc); unsigned line = getLineNumber(loc);
unsigned column = getColumnNumber(loc); unsigned column = getColumnNumber(loc);
@ -3162,7 +3163,7 @@ CGDebugInfo::getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D) {
/// create static variables for them. The first time this is called it needs /// create static variables for them. The first time this is called it needs
/// to be on a union and then from there we can have additional unnamed fields. /// to be on a union and then from there we can have additional unnamed fields.
llvm::DIGlobalVariable CGDebugInfo::CollectAnonRecordDecls( llvm::DIGlobalVariable CGDebugInfo::CollectAnonRecordDecls(
const RecordDecl *RD, llvm::DIFile Unit, unsigned LineNo, const RecordDecl *RD, llvm::MDFile *Unit, unsigned LineNo,
StringRef LinkageName, llvm::GlobalVariable *Var, llvm::MDScope *DContext) { StringRef LinkageName, llvm::GlobalVariable *Var, llvm::MDScope *DContext) {
llvm::DIGlobalVariable GV; llvm::DIGlobalVariable GV;
@ -3191,7 +3192,7 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
const VarDecl *D) { const VarDecl *D) {
assert(DebugKind >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
// Create global variable debug descriptor. // Create global variable debug descriptor.
llvm::DIFile Unit; llvm::MDFile *Unit = nullptr;
llvm::MDScope *DContext = nullptr; llvm::MDScope *DContext = nullptr;
unsigned LineNo; unsigned LineNo;
StringRef DeclName, LinkageName; StringRef DeclName, LinkageName;
@ -3224,7 +3225,7 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD,
llvm::Constant *Init) { llvm::Constant *Init) {
assert(DebugKind >= CodeGenOptions::LimitedDebugInfo); assert(DebugKind >= CodeGenOptions::LimitedDebugInfo);
// Create the descriptor for the variable. // Create the descriptor for the variable.
llvm::DIFile Unit = getOrCreateFile(VD->getLocation()); llvm::MDFile *Unit = getOrCreateFile(VD->getLocation());
StringRef Name = VD->getName(); StringRef Name = VD->getName();
llvm::MDType *Ty = getOrCreateType(VD->getType(), Unit); llvm::MDType *Ty = getOrCreateType(VD->getType(), Unit);
if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(VD)) { if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(VD)) {
@ -3316,7 +3317,7 @@ CGDebugInfo::EmitNamespaceAlias(const NamespaceAliasDecl &NA) {
/// getOrCreateNamesSpace - Return namespace descriptor for the given /// getOrCreateNamesSpace - Return namespace descriptor for the given
/// namespace decl. /// namespace decl.
llvm::DINameSpace llvm::MDNamespace *
CGDebugInfo::getOrCreateNameSpace(const NamespaceDecl *NSDecl) { CGDebugInfo::getOrCreateNameSpace(const NamespaceDecl *NSDecl) {
NSDecl = NSDecl->getCanonicalDecl(); NSDecl = NSDecl->getCanonicalDecl();
auto I = NameSpaceCache.find(NSDecl); auto I = NameSpaceCache.find(NSDecl);
@ -3324,11 +3325,11 @@ CGDebugInfo::getOrCreateNameSpace(const NamespaceDecl *NSDecl) {
return cast<llvm::MDNamespace>(I->second); return cast<llvm::MDNamespace>(I->second);
unsigned LineNo = getLineNumber(NSDecl->getLocation()); unsigned LineNo = getLineNumber(NSDecl->getLocation());
llvm::DIFile FileD = getOrCreateFile(NSDecl->getLocation()); llvm::MDFile *FileD = getOrCreateFile(NSDecl->getLocation());
llvm::MDScope *Context = llvm::MDScope *Context =
getContextDescriptor(dyn_cast<Decl>(NSDecl->getDeclContext())); getContextDescriptor(dyn_cast<Decl>(NSDecl->getDeclContext()));
llvm::DINameSpace NS = llvm::MDNamespace *NS =
DBuilder.createNameSpace(Context, NSDecl->getName(), FileD, LineNo); DBuilder.createNameSpace(Context, NSDecl->getName(), FileD, LineNo);
NameSpaceCache[NSDecl].reset(NS); NameSpaceCache[NSDecl].reset(NS);
return NS; return NS;
} }

View File

@ -52,7 +52,7 @@ class CGDebugInfo {
CodeGenModule &CGM; CodeGenModule &CGM;
const CodeGenOptions::DebugInfoKind DebugKind; const CodeGenOptions::DebugInfoKind DebugKind;
llvm::DIBuilder DBuilder; llvm::DIBuilder DBuilder;
llvm::DICompileUnit TheCU; llvm::MDCompileUnit *TheCU = nullptr;
SourceLocation CurLoc; SourceLocation CurLoc;
llvm::MDType *VTablePtrType = nullptr; llvm::MDType *VTablePtrType = nullptr;
llvm::MDType *ClassTy = nullptr; llvm::MDType *ClassTy = nullptr;
@ -122,52 +122,52 @@ class CGDebugInfo {
unsigned Checksum(const ObjCInterfaceDecl *InterfaceDecl); unsigned Checksum(const ObjCInterfaceDecl *InterfaceDecl);
llvm::MDType *CreateType(const BuiltinType *Ty); llvm::MDType *CreateType(const BuiltinType *Ty);
llvm::MDType *CreateType(const ComplexType *Ty); llvm::MDType *CreateType(const ComplexType *Ty);
llvm::MDType *CreateQualifiedType(QualType Ty, llvm::DIFile Fg); llvm::MDType *CreateQualifiedType(QualType Ty, llvm::MDFile *Fg);
llvm::MDType *CreateType(const TypedefType *Ty, llvm::DIFile Fg); llvm::MDType *CreateType(const TypedefType *Ty, llvm::MDFile *Fg);
llvm::MDType *CreateType(const TemplateSpecializationType *Ty, llvm::MDType *CreateType(const TemplateSpecializationType *Ty,
llvm::DIFile Fg); llvm::MDFile *Fg);
llvm::MDType *CreateType(const ObjCObjectPointerType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const ObjCObjectPointerType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const PointerType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const PointerType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const BlockPointerType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const BlockPointerType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const FunctionType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const FunctionType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const RecordType *Tyg); llvm::MDType *CreateType(const RecordType *Tyg);
llvm::MDType *CreateTypeDefinition(const RecordType *Ty); llvm::MDType *CreateTypeDefinition(const RecordType *Ty);
llvm::MDCompositeType *CreateLimitedType(const RecordType *Ty); llvm::MDCompositeType *CreateLimitedType(const RecordType *Ty);
void CollectContainingType(const CXXRecordDecl *RD, void CollectContainingType(const CXXRecordDecl *RD,
llvm::MDCompositeType *CT); llvm::MDCompositeType *CT);
llvm::MDType *CreateType(const ObjCInterfaceType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const ObjCInterfaceType *Ty, llvm::MDFile *F);
llvm::MDType *CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm::MDType *CreateTypeDefinition(const ObjCInterfaceType *Ty,
llvm::DIFile F); llvm::MDFile *F);
llvm::MDType *CreateType(const ObjCObjectType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const ObjCObjectType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const VectorType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const VectorType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const ArrayType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const ArrayType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const LValueReferenceType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const LValueReferenceType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const RValueReferenceType *Ty, llvm::DIFile Unit); llvm::MDType *CreateType(const RValueReferenceType *Ty, llvm::MDFile *Unit);
llvm::MDType *CreateType(const MemberPointerType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const MemberPointerType *Ty, llvm::MDFile *F);
llvm::MDType *CreateType(const AtomicType *Ty, llvm::DIFile F); llvm::MDType *CreateType(const AtomicType *Ty, llvm::MDFile *F);
llvm::MDType *CreateEnumType(const EnumType *Ty); llvm::MDType *CreateEnumType(const EnumType *Ty);
llvm::MDType *CreateTypeDefinition(const EnumType *Ty); llvm::MDType *CreateTypeDefinition(const EnumType *Ty);
llvm::MDType *CreateSelfType(const QualType &QualTy, llvm::MDType *Ty); llvm::MDType *CreateSelfType(const QualType &QualTy, llvm::MDType *Ty);
llvm::MDType *getTypeOrNull(const QualType); llvm::MDType *getTypeOrNull(const QualType);
llvm::MDSubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method, llvm::MDSubroutineType *getOrCreateMethodType(const CXXMethodDecl *Method,
llvm::DIFile F); llvm::MDFile *F);
llvm::MDSubroutineType * llvm::MDSubroutineType *
getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func, getOrCreateInstanceMethodType(QualType ThisPtr, const FunctionProtoType *Func,
llvm::DIFile Unit); llvm::MDFile *Unit);
llvm::MDSubroutineType * llvm::MDSubroutineType *
getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::DIFile F); getOrCreateFunctionType(const Decl *D, QualType FnType, llvm::MDFile *F);
llvm::MDType *getOrCreateVTablePtrType(llvm::DIFile F); llvm::MDType *getOrCreateVTablePtrType(llvm::MDFile *F);
llvm::DINameSpace getOrCreateNameSpace(const NamespaceDecl *N); llvm::MDNamespace *getOrCreateNameSpace(const NamespaceDecl *N);
llvm::MDType *getOrCreateTypeDeclaration(QualType PointeeTy, llvm::DIFile F); llvm::MDType *getOrCreateTypeDeclaration(QualType PointeeTy, llvm::MDFile *F);
llvm::MDType *CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty, llvm::MDType *CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty,
QualType PointeeTy, llvm::DIFile F); QualType PointeeTy, llvm::MDFile *F);
llvm::Value *getCachedInterfaceTypeOrNull(const QualType Ty); llvm::Value *getCachedInterfaceTypeOrNull(const QualType Ty);
llvm::MDType *getOrCreateStructPtrType(StringRef Name, llvm::MDType *&Cache); llvm::MDType *getOrCreateStructPtrType(StringRef Name, llvm::MDType *&Cache);
llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method, llvm::MDSubprogram *CreateCXXMemberFunction(const CXXMethodDecl *Method,
llvm::MDFile *F, llvm::MDFile *F,
llvm::MDType *RecordTy); llvm::MDType *RecordTy);
void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, llvm::MDFile *F, void CollectCXXMemberFunctions(const CXXRecordDecl *Decl, llvm::MDFile *F,
SmallVectorImpl<llvm::Metadata *> &E, SmallVectorImpl<llvm::Metadata *> &E,
@ -177,15 +177,14 @@ class CGDebugInfo {
SmallVectorImpl<llvm::Metadata *> &EltTys, SmallVectorImpl<llvm::Metadata *> &EltTys,
llvm::MDType *RecordTy); llvm::MDType *RecordTy);
llvm::DIArray llvm::DIArray CollectTemplateParams(const TemplateParameterList *TPList,
CollectTemplateParams(const TemplateParameterList *TPList, ArrayRef<TemplateArgument> TAList,
ArrayRef<TemplateArgument> TAList, llvm::MDFile *Unit);
llvm::DIFile Unit); llvm::DIArray CollectFunctionTemplateParams(const FunctionDecl *FD,
llvm::DIArray llvm::MDFile *Unit);
CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit);
llvm::DIArray llvm::DIArray
CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS, CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TS,
llvm::DIFile F); llvm::MDFile *F);
llvm::MDType *createFieldType(StringRef name, QualType type, llvm::MDType *createFieldType(StringRef name, QualType type,
uint64_t sizeInBitsOverride, SourceLocation loc, uint64_t sizeInBitsOverride, SourceLocation loc,
@ -201,14 +200,14 @@ class CGDebugInfo {
llvm::MDType *RecordTy, llvm::MDType *RecordTy,
const RecordDecl *RD); const RecordDecl *RD);
void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits, void CollectRecordNormalField(const FieldDecl *Field, uint64_t OffsetInBits,
llvm::DIFile F, llvm::MDFile *F,
SmallVectorImpl<llvm::Metadata *> &E, SmallVectorImpl<llvm::Metadata *> &E,
llvm::MDType *RecordTy, const RecordDecl *RD); llvm::MDType *RecordTy, const RecordDecl *RD);
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F, void CollectRecordFields(const RecordDecl *Decl, llvm::MDFile *F,
SmallVectorImpl<llvm::Metadata *> &E, SmallVectorImpl<llvm::Metadata *> &E,
llvm::MDCompositeType *RecordTy); llvm::MDCompositeType *RecordTy);
void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::DIFile F, void CollectVTableInfo(const CXXRecordDecl *Decl, llvm::MDFile *F,
SmallVectorImpl<llvm::Metadata *> &EltTys); SmallVectorImpl<llvm::Metadata *> &EltTys);
// CreateLexicalBlock - Create a new lexical block node and push it on // CreateLexicalBlock - Create a new lexical block node and push it on
@ -336,28 +335,28 @@ private:
/// \brief Get the file debug info descriptor for the input /// \brief Get the file debug info descriptor for the input
/// location. /// location.
llvm::DIFile getOrCreateFile(SourceLocation Loc); llvm::MDFile *getOrCreateFile(SourceLocation Loc);
/// \brief Get the file info for main compile unit. /// \brief Get the file info for main compile unit.
llvm::DIFile getOrCreateMainFile(); llvm::MDFile *getOrCreateMainFile();
/// \brief Get the type from the cache or create a new type if /// \brief Get the type from the cache or create a new type if
/// necessary. /// necessary.
llvm::MDType *getOrCreateType(QualType Ty, llvm::DIFile Fg); llvm::MDType *getOrCreateType(QualType Ty, llvm::MDFile *Fg);
/// \brief Get the type from the cache or create a new /// \brief Get the type from the cache or create a new
/// partial type if necessary. /// partial type if necessary.
llvm::MDType *getOrCreateLimitedType(const RecordType *Ty, llvm::DIFile F); llvm::MDType *getOrCreateLimitedType(const RecordType *Ty, llvm::MDFile *F);
/// \brief Create type metadata for a source language type. /// \brief Create type metadata for a source language type.
llvm::MDType *CreateTypeNode(QualType Ty, llvm::DIFile Fg); llvm::MDType *CreateTypeNode(QualType Ty, llvm::MDFile *Fg);
/// \brief return the underlying ObjCInterfaceDecl /// \brief return the underlying ObjCInterfaceDecl
/// if Ty is an ObjCInterface or a pointer to one. /// if Ty is an ObjCInterface or a pointer to one.
ObjCInterfaceDecl* getObjCInterfaceDecl(QualType Ty); ObjCInterfaceDecl* getObjCInterfaceDecl(QualType Ty);
/// \brief Create new member and increase Offset by FType's size. /// \brief Create new member and increase Offset by FType's size.
llvm::MDType *CreateMemberType(llvm::DIFile Unit, QualType FType, llvm::MDType *CreateMemberType(llvm::MDFile *Unit, QualType FType,
StringRef Name, uint64_t *Offset); StringRef Name, uint64_t *Offset);
/// \brief Retrieve the DIDescriptor, if any, for the canonical form of this /// \brief Retrieve the DIDescriptor, if any, for the canonical form of this
@ -366,16 +365,16 @@ private:
/// \brief Return debug info descriptor to describe method /// \brief Return debug info descriptor to describe method
/// declaration for the given method definition. /// declaration for the given method definition.
llvm::DISubprogram getFunctionDeclaration(const Decl *D); llvm::MDSubprogram *getFunctionDeclaration(const Decl *D);
/// Return debug info descriptor to describe in-class static data member /// Return debug info descriptor to describe in-class static data member
/// declaration for the given out-of-class definition. /// declaration for the given out-of-class definition.
llvm::MDDerivedType * llvm::MDDerivedType *
getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D); getOrCreateStaticDataMemberDeclarationOrNull(const VarDecl *D);
/// \brief Create a DISubprogram describing the forward /// \brief Create a subprogram describing the forward
/// decalration represented in the given FunctionDecl. /// decalration represented in the given FunctionDecl.
llvm::DISubprogram getFunctionForwardDeclaration(const FunctionDecl *FD); llvm::MDSubprogram *getFunctionForwardDeclaration(const FunctionDecl *FD);
/// \brief Create a DIGlobalVariable describing the forward /// \brief Create a DIGlobalVariable describing the forward
/// decalration represented in the given VarDecl. /// decalration represented in the given VarDecl.
@ -384,7 +383,7 @@ private:
/// Return a global variable that represents one of the collection of /// Return a global variable that represents one of the collection of
/// global variables created for an anonmyous union. /// global variables created for an anonmyous union.
llvm::DIGlobalVariable llvm::DIGlobalVariable
CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile Unit, CollectAnonRecordDecls(const RecordDecl *RD, llvm::MDFile *Unit,
unsigned LineNo, StringRef LinkageName, unsigned LineNo, StringRef LinkageName,
llvm::GlobalVariable *Var, llvm::MDScope *DContext); llvm::GlobalVariable *Var, llvm::MDScope *DContext);
@ -418,13 +417,13 @@ private:
/// \brief Collect various properties of a FunctionDecl. /// \brief Collect various properties of a FunctionDecl.
/// \param GD A GlobalDecl whose getDecl() must return a FunctionDecl. /// \param GD A GlobalDecl whose getDecl() must return a FunctionDecl.
void collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile Unit, void collectFunctionDeclProps(GlobalDecl GD, llvm::MDFile *Unit,
StringRef &Name, StringRef &LinkageName, StringRef &Name, StringRef &LinkageName,
llvm::MDScope *&FDContext, llvm::MDScope *&FDContext,
llvm::DIArray &TParamsArray, unsigned &Flags); llvm::DIArray &TParamsArray, unsigned &Flags);
/// \brief Collect various properties of a VarDecl. /// \brief Collect various properties of a VarDecl.
void collectVarDeclProps(const VarDecl *VD, llvm::DIFile &Unit, void collectVarDeclProps(const VarDecl *VD, llvm::MDFile *&Unit,
unsigned &LineNo, QualType &T, StringRef &Name, unsigned &LineNo, QualType &T, StringRef &Name,
StringRef &LinkageName, llvm::MDScope *&VDContext); StringRef &LinkageName, llvm::MDScope *&VDContext);