@@ -929,28 +929,8 @@ static llvm::dwarf::Tag getNextQualifier(Qualifiers &Q) {
929
929
return (llvm::dwarf::Tag)0 ;
930
930
}
931
931
932
- // Strip MacroQualifiedTypeLoc and AttributedTypeLoc
933
- // as their corresponding types will be ignored
934
- // during code generation. Stripping them allows
935
- // to maintain proper TypeLoc for a given type
936
- // during code generation.
937
- static TypeLoc StripMacroAttributed (TypeLoc TL) {
938
- if (!TL)
939
- return TL;
940
-
941
- while (true ) {
942
- if (auto MTL = TL.getAs <MacroQualifiedTypeLoc>())
943
- TL = MTL.getInnerLoc ();
944
- else if (auto ATL = TL.getAs <AttributedTypeLoc>())
945
- TL = ATL.getModifiedLoc ();
946
- else
947
- break ;
948
- }
949
- return TL;
950
- }
951
-
952
- llvm::DIType *CGDebugInfo::CreateQualifiedType (QualType Ty, llvm::DIFile *Unit,
953
- TypeLoc TL) {
932
+ llvm::DIType *CGDebugInfo::CreateQualifiedType (QualType Ty,
933
+ llvm::DIFile *Unit) {
954
934
QualifierCollector Qc;
955
935
const Type *T = Qc.strip (Ty);
956
936
@@ -964,15 +944,7 @@ llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile *Unit,
964
944
return getOrCreateType (QualType (T, 0 ), Unit);
965
945
}
966
946
967
- QualType NextTy = Qc.apply (CGM.getContext (), T);
968
- TypeLoc NextTL;
969
- if (NextTy.hasQualifiers ())
970
- NextTL = TL;
971
- else if (TL) {
972
- if (auto QTL = TL.getAs <QualifiedTypeLoc>())
973
- NextTL = StripMacroAttributed (QTL.getNextTypeLoc ());
974
- }
975
- auto *FromTy = getOrCreateType (NextTy, Unit, NextTL);
947
+ auto *FromTy = getOrCreateType (Qc.apply (CGM.getContext (), T), Unit);
976
948
977
949
// No need to fill in the Name, Line, Size, Alignment, Offset in case of
978
950
// CVR derived types.
@@ -1016,10 +988,10 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty,
1016
988
Ty->getPointeeType (), Unit);
1017
989
}
1018
990
1019
- llvm::DIType *CGDebugInfo::CreateType (const PointerType *Ty, llvm::DIFile *Unit,
1020
- TypeLoc TL ) {
991
+ llvm::DIType *CGDebugInfo::CreateType (const PointerType *Ty,
992
+ llvm::DIFile *Unit ) {
1021
993
return CreatePointerLikeType (llvm::dwarf::DW_TAG_pointer_type, Ty,
1022
- Ty->getPointeeType (), Unit, TL );
994
+ Ty->getPointeeType (), Unit);
1023
995
}
1024
996
1025
997
// / \return whether a C++ mangling exists for the type defined by TD.
@@ -1160,8 +1132,7 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty,
1160
1132
llvm::DIType *CGDebugInfo::CreatePointerLikeType (llvm::dwarf::Tag Tag,
1161
1133
const Type *Ty,
1162
1134
QualType PointeeTy,
1163
- llvm::DIFile *Unit,
1164
- TypeLoc TL) {
1135
+ llvm::DIFile *Unit) {
1165
1136
// Bit size, align and offset of the type.
1166
1137
// Size is always the size of a pointer. We can't use getTypeSize here
1167
1138
// because that does not return the correct value for references.
@@ -1171,52 +1142,13 @@ llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag,
1171
1142
Optional<unsigned > DWARFAddressSpace =
1172
1143
CGM.getTarget ().getDWARFAddressSpace (AddressSpace);
1173
1144
1174
- llvm::DINodeArray Annotations = nullptr ;
1175
- TypeLoc NextTL;
1176
- if (TL) {
1177
- SmallVector<llvm::Metadata *, 4 > Annots;
1178
- NextTL = TL.getNextTypeLoc ();
1179
- if (NextTL) {
1180
- // Traverse all MacroQualifiedTypeLoc, QualifiedTypeLoc and
1181
- // AttributedTypeLoc type locations so we can collect
1182
- // BTFTypeTag attributes for this pointer.
1183
- while (true ) {
1184
- if (auto MTL = NextTL.getAs <MacroQualifiedTypeLoc>()) {
1185
- NextTL = MTL.getInnerLoc ();
1186
- } else if (auto QTL = NextTL.getAs <QualifiedTypeLoc>()) {
1187
- NextTL = QTL.getNextTypeLoc ();
1188
- } else if (auto ATL = NextTL.getAs <AttributedTypeLoc>()) {
1189
- if (const auto *A = ATL.getAttrAs <BTFTypeTagAttr>()) {
1190
- StringRef BTFTypeTag = A->getBTFTypeTag ();
1191
- if (!BTFTypeTag.empty ()) {
1192
- llvm::Metadata *Ops[2 ] = {
1193
- llvm::MDString::get (CGM.getLLVMContext (),
1194
- StringRef (" btf_type_tag" )),
1195
- llvm::MDString::get (CGM.getLLVMContext (), BTFTypeTag)};
1196
- Annots.insert (Annots.begin (),
1197
- llvm::MDNode::get (CGM.getLLVMContext (), Ops));
1198
- }
1199
- }
1200
- NextTL = ATL.getModifiedLoc ();
1201
- } else {
1202
- break ;
1203
- }
1204
- }
1205
- }
1206
-
1207
- NextTL = StripMacroAttributed (TL.getNextTypeLoc ());
1208
- if (Annots.size () > 0 )
1209
- Annotations = DBuilder.getOrCreateArray (Annots);
1210
- }
1211
-
1212
1145
if (Tag == llvm::dwarf::DW_TAG_reference_type ||
1213
1146
Tag == llvm::dwarf::DW_TAG_rvalue_reference_type)
1214
1147
return DBuilder.createReferenceType (Tag, getOrCreateType (PointeeTy, Unit),
1215
1148
Size, Align, DWARFAddressSpace);
1216
1149
else
1217
- return DBuilder.createPointerType (getOrCreateType (PointeeTy, Unit, NextTL),
1218
- Size, Align, DWARFAddressSpace,
1219
- StringRef (), Annotations);
1150
+ return DBuilder.createPointerType (getOrCreateType (PointeeTy, Unit), Size,
1151
+ Align, DWARFAddressSpace);
1220
1152
}
1221
1153
1222
1154
llvm::DIType *CGDebugInfo::getOrCreateStructPtrType (StringRef Name,
@@ -1333,11 +1265,8 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,
1333
1265
1334
1266
llvm::DIType *CGDebugInfo::CreateType (const TypedefType *Ty,
1335
1267
llvm::DIFile *Unit) {
1336
- TypeLoc TL;
1337
- if (const TypeSourceInfo *TSI = Ty->getDecl ()->getTypeSourceInfo ())
1338
- TL = TSI->getTypeLoc ();
1339
1268
llvm::DIType *Underlying =
1340
- getOrCreateType (Ty->getDecl ()->getUnderlyingType (), Unit, TL );
1269
+ getOrCreateType (Ty->getDecl ()->getUnderlyingType (), Unit);
1341
1270
1342
1271
if (Ty->getDecl ()->hasAttr <NoDebugAttr>())
1343
1272
return Underlying;
@@ -1411,7 +1340,7 @@ static llvm::DINode::DIFlags getRefFlags(const FunctionProtoType *Func) {
1411
1340
}
1412
1341
1413
1342
llvm::DIType *CGDebugInfo::CreateType (const FunctionType *Ty,
1414
- llvm::DIFile *Unit, TypeLoc TL ) {
1343
+ llvm::DIFile *Unit) {
1415
1344
const auto *FPT = dyn_cast<FunctionProtoType>(Ty);
1416
1345
if (FPT) {
1417
1346
if (llvm::DIType *QTy = CreateQualifiedType (FPT, Unit))
@@ -1423,41 +1352,17 @@ llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
1423
1352
SmallVector<llvm::Metadata *, 16 > EltTys;
1424
1353
1425
1354
// Add the result type at least.
1426
- TypeLoc RetTL;
1427
- if (TL) {
1428
- if (auto FTL = TL.getAs <FunctionTypeLoc>())
1429
- RetTL = FTL.getReturnLoc ();
1430
- }
1431
- EltTys.push_back (getOrCreateType (Ty->getReturnType (), Unit, RetTL));
1355
+ EltTys.push_back (getOrCreateType (Ty->getReturnType (), Unit));
1432
1356
1433
1357
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
1434
1358
// Set up remainder of arguments if there is a prototype.
1435
1359
// otherwise emit it as a variadic function.
1436
- if (!FPT) {
1360
+ if (!FPT)
1437
1361
EltTys.push_back (DBuilder.createUnspecifiedParameter ());
1438
- } else {
1362
+ else {
1439
1363
Flags = getRefFlags (FPT);
1440
- bool DoneWithTL = false ;
1441
- if (TL) {
1442
- if (auto FTL = TL.getAs <FunctionTypeLoc>()) {
1443
- DoneWithTL = true ;
1444
- int Idx = 0 ;
1445
- for (const QualType &ParamType : FPT->param_types ()) {
1446
- TypeLoc ParamTL;
1447
- if (ParmVarDecl *Param = FTL.getParam (Idx)) {
1448
- if (const TypeSourceInfo *TSI = Param->getTypeSourceInfo ())
1449
- ParamTL = TSI->getTypeLoc ();
1450
- }
1451
- EltTys.push_back (getOrCreateType (ParamType, Unit, ParamTL));
1452
- Idx++;
1453
- }
1454
- }
1455
- }
1456
-
1457
- if (!DoneWithTL) {
1458
- for (const QualType &ParamType : FPT->param_types ())
1459
- EltTys.push_back (getOrCreateType (ParamType, Unit));
1460
- }
1364
+ for (const QualType &ParamType : FPT->param_types ())
1365
+ EltTys.push_back (getOrCreateType (ParamType, Unit));
1461
1366
if (FPT->isVariadic ())
1462
1367
EltTys.push_back (DBuilder.createUnspecifiedParameter ());
1463
1368
}
@@ -1528,13 +1433,11 @@ llvm::DIType *CGDebugInfo::createBitFieldType(const FieldDecl *BitFieldDecl,
1528
1433
Flags, DebugType, Annotations);
1529
1434
}
1530
1435
1531
- llvm::DIType *
1532
- CGDebugInfo::createFieldType (StringRef name, QualType type, SourceLocation loc,
1533
- AccessSpecifier AS, uint64_t offsetInBits,
1534
- uint32_t AlignInBits, llvm::DIFile *tunit,
1535
- llvm::DIScope *scope, const RecordDecl *RD,
1536
- llvm::DINodeArray Annotations, TypeLoc TL) {
1537
- llvm::DIType *debugType = getOrCreateType (type, tunit, TL);
1436
+ llvm::DIType *CGDebugInfo::createFieldType (
1437
+ StringRef name, QualType type, SourceLocation loc, AccessSpecifier AS,
1438
+ uint64_t offsetInBits, uint32_t AlignInBits, llvm::DIFile *tunit,
1439
+ llvm::DIScope *scope, const RecordDecl *RD, llvm::DINodeArray Annotations) {
1440
+ llvm::DIType *debugType = getOrCreateType (type, tunit);
1538
1441
1539
1442
// Get the location for the field.
1540
1443
llvm::DIFile *file = getOrCreateFile (loc);
@@ -1642,12 +1545,9 @@ void CGDebugInfo::CollectRecordNormalField(
1642
1545
} else {
1643
1546
auto Align = getDeclAlignIfRequired (field, CGM.getContext ());
1644
1547
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations (field);
1645
- TypeLoc TL;
1646
- if (const TypeSourceInfo *TSI = field->getTypeSourceInfo ())
1647
- TL = TSI->getTypeLoc ();
1648
- FieldType = createFieldType (name, type, field->getLocation (),
1649
- field->getAccess (), OffsetInBits, Align, tunit,
1650
- RecordTy, RD, Annotations, TL);
1548
+ FieldType =
1549
+ createFieldType (name, type, field->getLocation (), field->getAccess (),
1550
+ OffsetInBits, Align, tunit, RecordTy, RD, Annotations);
1651
1551
}
1652
1552
1653
1553
elements.push_back (FieldType);
@@ -3405,8 +3305,7 @@ void CGDebugInfo::completeUnusedClass(const CXXRecordDecl &D) {
3405
3305
RetainedTypes.push_back (CGM.getContext ().getRecordType (&D).getAsOpaquePtr ());
3406
3306
}
3407
3307
3408
- llvm::DIType *CGDebugInfo::getOrCreateType (QualType Ty, llvm::DIFile *Unit,
3409
- TypeLoc TL) {
3308
+ llvm::DIType *CGDebugInfo::getOrCreateType (QualType Ty, llvm::DIFile *Unit) {
3410
3309
if (Ty.isNull ())
3411
3310
return nullptr ;
3412
3311
@@ -3423,7 +3322,7 @@ llvm::DIType *CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile *Unit,
3423
3322
if (auto *T = getTypeOrNull (Ty))
3424
3323
return T;
3425
3324
3426
- llvm::DIType *Res = CreateTypeNode (Ty, Unit, TL );
3325
+ llvm::DIType *Res = CreateTypeNode (Ty, Unit);
3427
3326
void *TyPtr = Ty.getAsOpaquePtr ();
3428
3327
3429
3328
// And update the type cache.
@@ -3467,11 +3366,10 @@ llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
3467
3366
return nullptr ;
3468
3367
}
3469
3368
3470
- llvm::DIType *CGDebugInfo::CreateTypeNode (QualType Ty, llvm::DIFile *Unit,
3471
- TypeLoc TL) {
3369
+ llvm::DIType *CGDebugInfo::CreateTypeNode (QualType Ty, llvm::DIFile *Unit) {
3472
3370
// Handle qualifiers, which recursively handles what they refer to.
3473
3371
if (Ty.hasLocalQualifiers ())
3474
- return CreateQualifiedType (Ty, Unit, TL );
3372
+ return CreateQualifiedType (Ty, Unit);
3475
3373
3476
3374
// Work out details of type.
3477
3375
switch (Ty->getTypeClass ()) {
@@ -3500,7 +3398,7 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit,
3500
3398
case Type::Complex:
3501
3399
return CreateType (cast<ComplexType>(Ty));
3502
3400
case Type::Pointer:
3503
- return CreateType (cast<PointerType>(Ty), Unit, TL );
3401
+ return CreateType (cast<PointerType>(Ty), Unit);
3504
3402
case Type::BlockPointer:
3505
3403
return CreateType (cast<BlockPointerType>(Ty), Unit);
3506
3404
case Type::Typedef:
@@ -3511,7 +3409,7 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit,
3511
3409
return CreateEnumType (cast<EnumType>(Ty));
3512
3410
case Type::FunctionProto:
3513
3411
case Type::FunctionNoProto:
3514
- return CreateType (cast<FunctionType>(Ty), Unit, TL );
3412
+ return CreateType (cast<FunctionType>(Ty), Unit);
3515
3413
case Type::ConstantArray:
3516
3414
case Type::VariableArray:
3517
3415
case Type::IncompleteArray:
@@ -4056,12 +3954,7 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateFunctionType(const Decl *D,
4056
3954
getDwarfCC (CC));
4057
3955
}
4058
3956
4059
- TypeLoc TL;
4060
- if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
4061
- if (const TypeSourceInfo *TSI = FD->getTypeSourceInfo ())
4062
- TL = TSI->getTypeLoc ();
4063
- }
4064
- return cast<llvm::DISubroutineType>(getOrCreateType (FnType, F, TL));
3957
+ return cast<llvm::DISubroutineType>(getOrCreateType (FnType, F));
4065
3958
}
4066
3959
4067
3960
QualType
@@ -4463,12 +4356,8 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
4463
4356
uint64_t XOffset = 0 ;
4464
4357
if (VD->hasAttr <BlocksAttr>())
4465
4358
Ty = EmitTypeForVarWithBlocksAttr (VD, &XOffset).WrappedType ;
4466
- else {
4467
- TypeLoc TL;
4468
- if (const TypeSourceInfo *TSI = VD->getTypeSourceInfo ())
4469
- TL = TSI->getTypeLoc ();
4470
- Ty = getOrCreateType (VD->getType (), Unit, TL);
4471
- }
4359
+ else
4360
+ Ty = getOrCreateType (VD->getType (), Unit);
4472
4361
4473
4362
// If there is no debug info for this type then do not emit debug info
4474
4363
// for this variable.
@@ -5192,14 +5081,10 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
5192
5081
}
5193
5082
AppendAddressSpaceXDeref (AddressSpace, Expr);
5194
5083
5195
- TypeLoc TL;
5196
- if (const TypeSourceInfo *TSI = D->getTypeSourceInfo ())
5197
- TL = TSI->getTypeLoc ();
5198
-
5199
5084
llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations (D);
5200
5085
GVE = DBuilder.createGlobalVariableExpression (
5201
- DContext, DeclName, LinkageName, Unit, LineNo,
5202
- getOrCreateType (T, Unit, TL), Var->hasLocalLinkage (), true ,
5086
+ DContext, DeclName, LinkageName, Unit, LineNo, getOrCreateType (T, Unit),
5087
+ Var->hasLocalLinkage (), true ,
5203
5088
Expr.empty () ? nullptr : DBuilder.createExpression (Expr),
5204
5089
getOrCreateStaticDataMemberDeclarationOrNull (D), TemplateParameters,
5205
5090
Align, Annotations);
0 commit comments