15
15
// ===----------------------------------------------------------------------===//
16
16
17
17
#include " IRGenDebugInfo.h"
18
+ #include " GenEnum.h"
18
19
#include " GenOpaque.h"
19
20
#include " GenStruct.h"
20
21
#include " GenType.h"
@@ -1525,7 +1526,9 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1525
1526
? 0
1526
1527
: DbgTy.getAlignment ().getValue () * SizeOfByte;
1527
1528
unsigned Encoding = 0 ;
1528
- uint32_t NumExtraInhabitants = 0 ;
1529
+ uint32_t NumExtraInhabitants =
1530
+ DbgTy.getNumExtraInhabitants () ? *DbgTy.getNumExtraInhabitants () : 0 ;
1531
+
1529
1532
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
1530
1533
1531
1534
TypeBase *BaseTy = DbgTy.getType ();
@@ -1549,17 +1552,13 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1549
1552
Encoding = llvm::dwarf::DW_ATE_unsigned;
1550
1553
if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy))
1551
1554
SizeInBits = getSizeOfBasicType (*CompletedDbgTy);
1552
- if (auto DbgTyNumExtraInhabitants = DbgTy.getNumExtraInhabitants ())
1553
- NumExtraInhabitants = *DbgTyNumExtraInhabitants;
1554
1555
break ;
1555
1556
}
1556
1557
1557
1558
case TypeKind::BuiltinIntegerLiteral: {
1558
1559
Encoding = llvm::dwarf::DW_ATE_unsigned; // ?
1559
1560
if (auto CompletedDbgTy = CompletedDebugTypeInfo::get (DbgTy))
1560
1561
SizeInBits = getSizeOfBasicType (*CompletedDbgTy);
1561
- if (auto DbgTyNumExtraInhabitants = DbgTy.getNumExtraInhabitants ())
1562
- NumExtraInhabitants = *DbgTyNumExtraInhabitants;
1563
1562
break ;
1564
1563
}
1565
1564
@@ -1568,48 +1567,30 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1568
1567
// Assuming that the bitwidth and FloatTy->getFPKind() are identical.
1569
1568
SizeInBits = FloatTy->getBitWidth ();
1570
1569
Encoding = llvm::dwarf::DW_ATE_float;
1571
- if (auto DbgTyNumExtraInhabitants = DbgTy.getNumExtraInhabitants ())
1572
- NumExtraInhabitants = *DbgTyNumExtraInhabitants;
1573
1570
break ;
1574
1571
}
1575
1572
1576
- case TypeKind::BuiltinNativeObject: {
1577
- unsigned PtrSize = CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
1578
- auto PTy = DBuilder.createPointerType (nullptr , PtrSize, 0 ,
1579
- /* DWARFAddressSpace */ llvm::None,
1580
- MangledName);
1581
- return DBuilder.createObjectPointerType (PTy);
1582
- }
1583
-
1584
- case TypeKind::BuiltinBridgeObject: {
1585
- unsigned PtrSize = CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
1586
- auto PTy = DBuilder.createPointerType (nullptr , PtrSize, 0 ,
1587
- /* DWARFAddressSpace */ llvm::None,
1588
- MangledName);
1589
- return DBuilder.createObjectPointerType (PTy);
1590
- }
1591
-
1592
- case TypeKind::BuiltinRawPointer: {
1593
- unsigned PtrSize = CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
1594
- return DBuilder.createPointerType (nullptr , PtrSize, 0 ,
1595
- /* DWARFAddressSpace */ llvm::None,
1596
- MangledName);
1597
- }
1573
+ case TypeKind::BuiltinNativeObject:
1574
+ case TypeKind::BuiltinBridgeObject:
1575
+ case TypeKind::BuiltinRawPointer:
1576
+ case TypeKind::BuiltinRawUnsafeContinuation:
1577
+ case TypeKind::BuiltinJob: {
1578
+ unsigned PtrSize =
1579
+ CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
1580
+ if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes) {
1581
+ Flags |= llvm::DINode::FlagArtificial;
1582
+ llvm::DICompositeType *PTy = DBuilder.createStructType (
1583
+ Scope, MangledName, File, 0 , PtrSize, 0 , Flags, nullptr , nullptr ,
1584
+ llvm::dwarf::DW_LANG_Swift, nullptr , {}, NumExtraInhabitants);
1585
+ return PTy;
1598
1586
1599
- case TypeKind::BuiltinRawUnsafeContinuation: {
1600
- unsigned PtrSize = CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
1601
- return DBuilder.createPointerType (nullptr , PtrSize, 0 ,
1602
- /* DWARFAddressSpace */ llvm::None,
1603
- MangledName);
1604
- }
1587
+ }
1588
+ llvm::DIDerivedType *PTy = DBuilder.createPointerType (
1589
+ nullptr , PtrSize, 0 ,
1590
+ /* DWARFAddressSpace */ llvm::None, MangledName);
1605
1591
1606
- case TypeKind::BuiltinJob: {
1607
- unsigned PtrSize = CI.getTargetInfo ().getPointerWidth (clang::LangAS::Default);
1608
- return DBuilder.createPointerType (nullptr , PtrSize, 0 ,
1609
- /* DWARFAddressSpace */ llvm::None,
1610
- MangledName);
1592
+ return DBuilder.createObjectPointerType (PTy);
1611
1593
}
1612
-
1613
1594
case TypeKind::BuiltinExecutor: {
1614
1595
return createDoublePointerSizedStruct (
1615
1596
Scope, " Builtin.Executor" , nullptr , MainFile, 0 ,
@@ -2033,6 +2014,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2033
2014
}
2034
2015
#endif
2035
2016
2017
+ void createSpecialStlibBuiltinTypes () {
2018
+ if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::ASTTypes)
2019
+ return ;
2020
+ for (auto BuiltinType: IGM.getSpecialBuiltinTypes ()) {
2021
+ auto DbgTy = DebugTypeInfo::getFromTypeInfo (
2022
+ BuiltinType, IGM.getTypeInfoForUnlowered (BuiltinType), IGM, false );
2023
+ DBuilder.retainType (getOrCreateType (DbgTy));
2024
+ }
2025
+ }
2026
+
2036
2027
llvm::DIType *getOrCreateType (DebugTypeInfo DbgTy) {
2037
2028
// Is this an empty type?
2038
2029
if (DbgTy.isNull ())
@@ -2079,6 +2070,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
2079
2070
TypeDecl = ND;
2080
2071
Context = ND->getParent ();
2081
2072
ClangDecl = ND->getClangDecl ();
2073
+ } else if (auto BNO = dyn_cast<BuiltinType>(DbgTy.getType ())) {
2074
+ Context = BNO->getASTContext ().TheBuiltinModule ;
2082
2075
}
2083
2076
if (ClangDecl) {
2084
2077
clang::ASTReader &Reader = *CI.getClangInstance ().getASTReader ();
@@ -2255,6 +2248,7 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
2255
2248
}
2256
2249
OS << ' "' ;
2257
2250
}
2251
+ createSpecialStlibBuiltinTypes ();
2258
2252
}
2259
2253
2260
2254
void IRGenDebugInfoImpl::finalize () {
0 commit comments