@@ -564,7 +564,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
564
564
// Create a Forward-declared type.
565
565
auto Loc = getDebugLoc (*this , NTD);
566
566
auto File = getOrCreateFile (Loc.Filename );
567
- auto Line = Loc.Line ;
567
+ // No line numbers are attached to type forward declarations.
568
+ auto Line = 0 ;
568
569
auto FwdDecl = DBuilder.createReplaceableCompositeType (
569
570
llvm::dwarf::DW_TAG_structure_type, NTD->getName ().str (),
570
571
getOrCreateContext (DC->getParent ()), File, Line,
@@ -1301,14 +1302,19 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1301
1302
auto *Decl = StructTy->getDecl ();
1302
1303
auto L = getDebugLoc (*this , Decl);
1303
1304
auto *File = getOrCreateFile (L.Filename );
1305
+ unsigned FwdDeclLine = 0 ;
1304
1306
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
1305
1307
return createStructType (DbgTy, Decl, StructTy, Scope, File, L.Line ,
1306
- SizeInBits, AlignInBits, Flags,
1307
- nullptr , // DerivedFrom
1308
+ SizeInBits, AlignInBits, Flags, nullptr ,
1308
1309
llvm::dwarf::DW_LANG_Swift, MangledName);
1309
1310
else
1310
- return createOpaqueStruct (Scope, Decl->getName ().str (), File, L.Line ,
1311
- SizeInBits, AlignInBits, Flags, MangledName);
1311
+ // No line numbers are attached to type forward declarations. This is
1312
+ // intentional: It interfers with the efficacy of incremental builds. We
1313
+ // don't want a whitespace change to an secondary file trigger a
1314
+ // recompilation of the debug info of a primary source file.
1315
+ return createOpaqueStruct (Scope, Decl->getName ().str (), File,
1316
+ FwdDeclLine, SizeInBits, AlignInBits, Flags,
1317
+ MangledName);
1312
1318
}
1313
1319
1314
1320
case TypeKind::Class: {
@@ -1318,68 +1324,76 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1318
1324
auto *ClassTy = BaseTy->castTo <ClassType>();
1319
1325
auto *Decl = ClassTy->getDecl ();
1320
1326
auto L = getDebugLoc (*this , Decl);
1327
+ auto *File = getOrCreateFile (L.Filename );
1328
+ unsigned FwdDeclLine = 0 ;
1321
1329
assert (SizeInBits == CI.getTargetInfo ().getPointerWidth (0 ));
1322
- return createPointerSizedStruct (Scope, Decl->getNameStr (),
1323
- getOrCreateFile (L.Filename ), L.Line ,
1324
- Flags, MangledName);
1330
+ return createPointerSizedStruct (Scope, Decl->getNameStr (), File,
1331
+ FwdDeclLine, Flags, MangledName);
1325
1332
}
1326
1333
1327
1334
case TypeKind::Protocol: {
1328
1335
auto *ProtocolTy = BaseTy->castTo <ProtocolType>();
1329
1336
auto *Decl = ProtocolTy->getDecl ();
1330
1337
// FIXME: (LLVM branch) This should probably be a DW_TAG_interface_type.
1331
1338
auto L = getDebugLoc (*this , Decl);
1332
- auto File = getOrCreateFile (L.Filename );
1339
+ auto *File = getOrCreateFile (L.Filename );
1340
+ unsigned FwdDeclLine = 0 ;
1333
1341
return createOpaqueStruct (Scope, Decl ? Decl->getNameStr () : MangledName,
1334
- File, L. Line , SizeInBits, AlignInBits, Flags ,
1335
- MangledName);
1342
+ File, FwdDeclLine , SizeInBits, AlignInBits,
1343
+ Flags, MangledName);
1336
1344
}
1337
1345
1338
1346
case TypeKind::ProtocolComposition: {
1339
1347
auto *Decl = DbgTy.getDecl ();
1340
1348
auto L = getDebugLoc (*this , Decl);
1341
- auto File = getOrCreateFile (L.Filename );
1342
-
1343
- // FIXME: emit types
1344
- // auto ProtocolCompositionTy = BaseTy->castTo<ProtocolCompositionType>();
1349
+ auto *File = getOrCreateFile (L.Filename );
1350
+ unsigned FwdDeclLine = 0 ;
1345
1351
return createOpaqueStruct (Scope, Decl ? Decl->getNameStr () : MangledName,
1346
- File, L. Line , SizeInBits, AlignInBits, Flags ,
1347
- MangledName);
1352
+ File, FwdDeclLine , SizeInBits, AlignInBits,
1353
+ Flags, MangledName);
1348
1354
}
1349
1355
1350
1356
case TypeKind::UnboundGeneric: {
1351
1357
auto *UnboundTy = BaseTy->castTo <UnboundGenericType>();
1352
1358
auto *Decl = UnboundTy->getDecl ();
1353
1359
auto L = getDebugLoc (*this , Decl);
1360
+ auto *File = getOrCreateFile (L.Filename );
1361
+ unsigned FwdDeclLine = 0 ;
1354
1362
assert (SizeInBits == CI.getTargetInfo ().getPointerWidth (0 ));
1355
1363
return createPointerSizedStruct (Scope,
1356
1364
Decl ? Decl->getNameStr () : MangledName,
1357
- File, L. Line , Flags, MangledName);
1365
+ File, FwdDeclLine , Flags, MangledName);
1358
1366
}
1359
1367
1360
1368
case TypeKind::BoundGenericStruct: {
1361
1369
auto *StructTy = BaseTy->castTo <BoundGenericStructType>();
1362
1370
auto *Decl = StructTy->getDecl ();
1363
1371
auto L = getDebugLoc (*this , Decl);
1372
+ auto *File = getOrCreateFile (L.Filename );
1373
+ unsigned FwdDeclLine = 0 ;
1364
1374
return createOpaqueStructWithSizedContainer (
1365
- Scope, Decl ? Decl->getNameStr () : " " , File, L. Line , SizeInBits,
1375
+ Scope, Decl ? Decl->getNameStr () : " " , File, FwdDeclLine , SizeInBits,
1366
1376
AlignInBits, Flags, MangledName, collectGenericParams (StructTy));
1367
1377
}
1368
1378
1369
1379
case TypeKind::BoundGenericClass: {
1370
1380
auto *ClassTy = BaseTy->castTo <BoundGenericClassType>();
1371
1381
auto *Decl = ClassTy->getDecl ();
1372
1382
auto L = getDebugLoc (*this , Decl);
1383
+ auto *File = getOrCreateFile (L.Filename );
1384
+ unsigned FwdDeclLine = 0 ;
1385
+
1373
1386
// TODO: We may want to peek at Decl->isObjC() and set this
1374
1387
// attribute accordingly.
1375
1388
assert (SizeInBits == CI.getTargetInfo ().getPointerWidth (0 ));
1376
1389
return createPointerSizedStruct (Scope,
1377
1390
Decl ? Decl->getNameStr () : MangledName,
1378
- File, L. Line , Flags, MangledName);
1391
+ File, FwdDeclLine , Flags, MangledName);
1379
1392
}
1380
1393
1381
1394
case TypeKind::Tuple: {
1382
- // Tuples are also represented as structs.
1395
+ // Tuples are also represented as structs. Since tuples are ephemeral
1396
+ // (not nominal) they don't have a source location.
1383
1397
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
1384
1398
return createTuple (DbgTy, Scope, SizeInBits, AlignInBits, Flags,
1385
1399
MangledName);
@@ -1400,14 +1414,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1400
1414
if (auto nested = dyn_cast<NestedArchetypeType>(Archetype))
1401
1415
assocType = nested->getAssocType ();
1402
1416
auto L = getDebugLoc (*this , assocType);
1417
+ auto *File = getOrCreateFile (L.Filename );
1418
+ unsigned FwdDeclLine = 0 ;
1403
1419
auto Superclass = Archetype->getSuperclass ();
1404
1420
auto DerivedFrom = Superclass.isNull ()
1405
1421
? nullptr
1406
1422
: getOrCreateDesugaredType (Superclass, DbgTy);
1407
1423
auto FwdDecl = llvm::TempDIType (DBuilder.createReplaceableCompositeType (
1408
- llvm::dwarf::DW_TAG_structure_type, MangledName, Scope, File, L. Line ,
1409
- llvm::dwarf::DW_LANG_Swift, SizeInBits, AlignInBits, Flags ,
1410
- MangledName));
1424
+ llvm::dwarf::DW_TAG_structure_type, MangledName, Scope, File,
1425
+ FwdDeclLine, llvm::dwarf::DW_LANG_Swift, SizeInBits, AlignInBits,
1426
+ Flags, MangledName));
1411
1427
1412
1428
// Emit the protocols the archetypes conform to.
1413
1429
SmallVector<llvm::Metadata *, 4 > Protocols;
@@ -1421,7 +1437,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1421
1437
DBuilder.createInheritance (FwdDecl.get (), PDITy, 0 , 0 , Flags));
1422
1438
}
1423
1439
auto DITy = DBuilder.createStructType (
1424
- Scope, MangledName, File, L. Line , SizeInBits, AlignInBits, Flags,
1440
+ Scope, MangledName, File, FwdDeclLine , SizeInBits, AlignInBits, Flags,
1425
1441
DerivedFrom, DBuilder.getOrCreateArray (Protocols),
1426
1442
llvm::dwarf::DW_LANG_Swift, nullptr , MangledName);
1427
1443
@@ -1435,9 +1451,11 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1435
1451
// storage.
1436
1452
Flags |= llvm::DINode::FlagArtificial;
1437
1453
auto L = getDebugLoc (*this , DbgTy.getDecl ());
1438
- auto File = getOrCreateFile (L.Filename );
1454
+ auto *File = getOrCreateFile (L.Filename );
1455
+ unsigned FwdDeclLine = 0 ;
1456
+
1439
1457
return DBuilder.createStructType (
1440
- Scope, MangledName, File, L. Line , SizeInBits, AlignInBits, Flags,
1458
+ Scope, MangledName, File, FwdDeclLine , SizeInBits, AlignInBits, Flags,
1441
1459
nullptr , nullptr , llvm::dwarf::DW_LANG_Swift, nullptr , MangledName);
1442
1460
}
1443
1461
@@ -1457,34 +1475,40 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1457
1475
auto *Decl = EnumTy->getDecl ();
1458
1476
auto L = getDebugLoc (*this , Decl);
1459
1477
auto *File = getOrCreateFile (L.Filename );
1478
+ unsigned FwdDeclLine = 0 ;
1479
+
1460
1480
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
1461
1481
return createEnumType (DbgTy, Decl, MangledName, Scope, File, L.Line ,
1462
1482
Flags);
1463
1483
else
1464
- return createOpaqueStruct (Scope, Decl->getName ().str (), File, L.Line ,
1465
- SizeInBits, AlignInBits, Flags, MangledName);
1484
+ return createOpaqueStruct (Scope, Decl->getName ().str (), File,
1485
+ FwdDeclLine, SizeInBits, AlignInBits, Flags,
1486
+ MangledName);
1466
1487
}
1467
1488
1468
1489
case TypeKind::BoundGenericEnum: {
1469
1490
auto *EnumTy = BaseTy->castTo <BoundGenericEnumType>();
1470
1491
auto *Decl = EnumTy->getDecl ();
1471
1492
auto L = getDebugLoc (*this , Decl);
1472
1493
auto *File = getOrCreateFile (L.Filename );
1494
+ unsigned FwdDeclLine = 0 ;
1495
+
1473
1496
return createOpaqueStructWithSizedContainer (
1474
- Scope, Decl->getName ().str (), File, L. Line , SizeInBits, AlignInBits ,
1475
- Flags, MangledName, collectGenericParams (EnumTy));
1497
+ Scope, Decl->getName ().str (), File, FwdDeclLine , SizeInBits,
1498
+ AlignInBits, Flags, MangledName, collectGenericParams (EnumTy));
1476
1499
}
1477
1500
1478
1501
case TypeKind::BuiltinVector: {
1479
- (void )MangledName; // FIXME emit the name somewhere.
1502
+ // FIXME: Emit the name somewhere.
1503
+ (void )MangledName;
1480
1504
auto *BuiltinVectorTy = BaseTy->castTo <BuiltinVectorType>();
1481
1505
auto ElemTy = BuiltinVectorTy->getElementType ();
1482
1506
auto ElemDbgTy = DebugTypeInfo::getFromTypeInfo (
1483
1507
ElemTy, IGM.getTypeInfoForUnlowered (ElemTy));
1484
1508
unsigned Count = BuiltinVectorTy->getNumElements ();
1485
1509
auto Subscript = DBuilder.getOrCreateSubrange (0 , Count ? Count : -1 );
1486
- return DBuilder.createVectorType (SizeInBits,
1487
- AlignInBits, getOrCreateType (ElemDbgTy),
1510
+ return DBuilder.createVectorType (SizeInBits, AlignInBits,
1511
+ getOrCreateType (ElemDbgTy),
1488
1512
DBuilder.getOrCreateArray (Subscript));
1489
1513
}
1490
1514
@@ -1496,9 +1520,12 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1496
1520
auto *ReferenceTy = cast<ReferenceStorageType>(BaseTy);
1497
1521
auto CanTy = ReferenceTy->getReferentType ();
1498
1522
auto L = getDebugLoc (*this , DbgTy.getDecl ());
1499
- auto File = getOrCreateFile (L.Filename );
1523
+ auto *File = getOrCreateFile (L.Filename );
1524
+ unsigned CompilerGeneratedLine = 0 ;
1525
+
1500
1526
return DBuilder.createTypedef (getOrCreateDesugaredType (CanTy, DbgTy),
1501
- MangledName, File, L.Line , File);
1527
+ MangledName, File, CompilerGeneratedLine,
1528
+ File);
1502
1529
}
1503
1530
1504
1531
// Sugared types.
@@ -1508,14 +1535,15 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1508
1535
auto *Decl = TypeAliasTy->getDecl ();
1509
1536
auto L = getDebugLoc (*this , Decl);
1510
1537
auto AliasedTy = TypeAliasTy->getSinglyDesugaredType ();
1511
- auto File = getOrCreateFile (L.Filename );
1538
+ auto *File = getOrCreateFile (L.Filename );
1539
+
1512
1540
// For TypeAlias types, the DeclContext for the aliased type is
1513
1541
// in the decl of the alias type.
1514
1542
DebugTypeInfo AliasedDbgTy (AliasedTy, DbgTy.getStorageType (),
1515
1543
DbgTy.getSize (), DbgTy.getAlignment (),
1516
1544
DbgTy.hasDefaultAlignment (), false );
1517
1545
return DBuilder.createTypedef (getOrCreateType (AliasedDbgTy), MangledName,
1518
- File, L. Line , Scope);
1546
+ File, 0 , Scope);
1519
1547
}
1520
1548
1521
1549
case TypeKind::Paren: {
0 commit comments