30
30
#include " swift/ClangImporter/ClangImporter.h"
31
31
#include " swift/ClangImporter/ClangModule.h"
32
32
#include " swift/Demangling/ManglingMacros.h"
33
- #include " swift/Serialization/SerializedModuleLoader.h"
34
33
#include " swift/SIL/SILArgument.h"
35
34
#include " swift/SIL/SILBasicBlock.h"
36
35
#include " swift/SIL/SILDebugScope.h"
37
36
#include " swift/SIL/SILModule.h"
37
+ #include " swift/Serialization/SerializedModuleLoader.h"
38
38
#include " clang/AST/ASTContext.h"
39
39
#include " clang/AST/Decl.h"
40
40
#include " clang/AST/ExternalASTSource.h"
@@ -140,7 +140,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
140
140
llvm::DenseSet<UUSTuple> PreviousLineEntries;
141
141
SILLocation::DebugLoc PreviousDebugLoc;
142
142
#endif
143
-
143
+
144
144
public:
145
145
IRGenDebugInfoImpl (const IRGenOptions &Opts, ClangImporter &CI,
146
146
IRGenModule &IGM, llvm::Module &M,
@@ -484,8 +484,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
484
484
}
485
485
486
486
SmallVector<char , 64 > Buf;
487
- StringRef Name = (VD-> getBaseName (). userFacingName () +
488
- Twine (Kind)).toStringRef (Buf);
487
+ StringRef Name =
488
+ (VD-> getBaseName (). userFacingName () + Twine (Kind)).toStringRef (Buf);
489
489
return BumpAllocatedString (Name);
490
490
}
491
491
@@ -518,8 +518,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
518
518
auto FnTy = SILTy.getAs <SILFunctionType>();
519
519
if (!FnTy) {
520
520
LLVM_DEBUG (llvm::dbgs () << " Unexpected function type: " ;
521
- SILTy.print (llvm::dbgs ());
522
- llvm::dbgs () << " \n " );
521
+ SILTy.print (llvm::dbgs ()); llvm::dbgs () << " \n " );
523
522
return CanSILFunctionType ();
524
523
}
525
524
@@ -582,7 +581,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
582
581
void createParameterType (llvm::SmallVectorImpl<llvm::Metadata *> &Parameters,
583
582
SILType type) {
584
583
auto RealType = type.getASTType ();
585
- auto DbgTy = DebugTypeInfo::getFromTypeInfo (RealType, IGM.getTypeInfo (type));
584
+ auto DbgTy =
585
+ DebugTypeInfo::getFromTypeInfo (RealType, IGM.getTypeInfo (type));
586
586
Parameters.push_back (getOrCreateType (DbgTy));
587
587
}
588
588
@@ -721,7 +721,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
721
721
return Desc;
722
722
return None;
723
723
}
724
-
724
+
725
725
llvm::DIModule *getOrCreateModule (ModuleDecl::ImportedModule IM) {
726
726
ModuleDecl *M = IM.importedModule ;
727
727
if (Optional<ASTSourceDescriptor> ModuleDesc = getClangModule (*M))
@@ -795,15 +795,15 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
795
795
796
796
break ;
797
797
}
798
-
798
+
799
799
// TODO: Eliminate substitutions in SILFunctionTypes for now.
800
800
// On platforms where the substitutions affect representation, we will need
801
801
// to preserve this info and teach type reconstruction about it.
802
- Ty = Ty->replaceSubstitutedSILFunctionTypesWithUnsubstituted (IGM.getSILModule ());
802
+ Ty = Ty->replaceSubstitutedSILFunctionTypesWithUnsubstituted (
803
+ IGM.getSILModule ());
803
804
804
805
Mangle::ASTMangler Mangler;
805
- std::string Result = Mangler.mangleTypeForDebugger (
806
- Ty, nullptr );
806
+ std::string Result = Mangler.mangleTypeForDebugger (Ty, nullptr );
807
807
808
808
if (!Opts.DisableRoundTripDebugTypes ) {
809
809
// Make sure we can reconstruct mangled types for the debugger.
@@ -845,17 +845,17 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
845
845
return DITy;
846
846
}
847
847
848
- llvm::DINodeArray
849
- getTupleElements (TupleType *TupleTy, llvm::DIScope *Scope, llvm::DIFile *File,
850
- llvm::DINode::DIFlags Flags, unsigned &SizeInBits) {
848
+ llvm::DINodeArray getTupleElements (TupleType *TupleTy, llvm::DIScope *Scope,
849
+ llvm::DIFile *File,
850
+ llvm::DINode::DIFlags Flags,
851
+ unsigned &SizeInBits) {
851
852
SmallVector<llvm::Metadata *, 16 > Elements;
852
853
unsigned OffsetInBits = 0 ;
853
854
auto genericSig = IGM.getCurGenericContext ();
854
855
for (auto ElemTy : TupleTy->getElementTypes ()) {
855
856
auto &elemTI = IGM.getTypeInfoForUnlowered (
856
857
AbstractionPattern (genericSig, ElemTy->getCanonicalType ()), ElemTy);
857
- auto DbgTy =
858
- DebugTypeInfo::getFromTypeInfo (ElemTy, elemTI);
858
+ auto DbgTy = DebugTypeInfo::getFromTypeInfo (ElemTy, elemTI);
859
859
Elements.push_back (createMemberType (DbgTy, StringRef (), OffsetInBits,
860
860
Scope, File, Flags));
861
861
}
@@ -1017,14 +1017,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1017
1017
// / anchor any typedefs that may appear in parameters so they can be
1018
1018
// / resolved in the debugger without needing to query the Swift module.
1019
1019
llvm::DINodeArray collectGenericParams (BoundGenericType *BGT) {
1020
- SmallVector<llvm::Metadata *, 16 > TemplateParams;
1021
- for (auto Param : BGT->getGenericArgs ()) {
1022
- TemplateParams.push_back (DBuilder.createTemplateTypeParameter (
1023
- TheCU, " " , getOrCreateType (DebugTypeInfo::getForwardDecl (Param))));
1024
- }
1025
- return DBuilder.getOrCreateArray (TemplateParams);
1020
+ SmallVector<llvm::Metadata *, 16 > TemplateParams;
1021
+ for (auto Param : BGT->getGenericArgs ()) {
1022
+ TemplateParams.push_back (DBuilder.createTemplateTypeParameter (
1023
+ TheCU, " " , getOrCreateType (DebugTypeInfo::getForwardDecl (Param))));
1024
+ }
1025
+ return DBuilder.getOrCreateArray (TemplateParams);
1026
1026
}
1027
-
1027
+
1028
1028
// / Create a sized container for a sizeless type. Used to represent
1029
1029
// / BoundGenericEnums that may have different sizes depending on what they are
1030
1030
// / bound to, but still share a mangled name.
@@ -1048,9 +1048,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1048
1048
InnerTypeCache[UID] = llvm::TrackingMDNodeRef (UniqueType);
1049
1049
}
1050
1050
1051
- llvm::Metadata *Elements[] = {
1052
- DBuilder.createMemberType (Scope, " " , File, 0 , SizeInBits,
1053
- AlignInBits, 0 , Flags, UniqueType)};
1051
+ llvm::Metadata *Elements[] = {DBuilder.createMemberType (
1052
+ Scope, " " , File, 0 , SizeInBits, AlignInBits, 0 , Flags, UniqueType)};
1054
1053
return DBuilder.createStructType (
1055
1054
Scope, " " , File, Line, SizeInBits, AlignInBits, Flags,
1056
1055
/* DerivedFrom */ nullptr , DBuilder.getOrCreateArray (Elements),
@@ -1230,8 +1229,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1230
1229
1231
1230
if (!BaseTy) {
1232
1231
LLVM_DEBUG (llvm::dbgs () << " Type without TypeBase: " ;
1233
- DbgTy.getType ()->dump (llvm::dbgs ());
1234
- llvm::dbgs () << " \n " );
1232
+ DbgTy.getType ()->dump (llvm::dbgs ()); llvm::dbgs () << " \n " );
1235
1233
if (!InternalType) {
1236
1234
StringRef Name = " <internal>" ;
1237
1235
InternalType = DBuilder.createForwardDecl (
@@ -1428,8 +1426,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1428
1426
// Emit the protocols the archetypes conform to.
1429
1427
SmallVector<llvm::Metadata *, 4 > Protocols;
1430
1428
for (auto *ProtocolDecl : Archetype->getConformsTo ()) {
1431
- auto PTy = IGM. getLoweredType (ProtocolDecl-> getInterfaceType ())
1432
- .getASTType ();
1429
+ auto PTy =
1430
+ IGM. getLoweredType (ProtocolDecl-> getInterfaceType ()) .getASTType ();
1433
1431
auto PDbgTy = DebugTypeInfo::getFromTypeInfo (
1434
1432
ProtocolDecl->getInterfaceType (), IGM.getTypeInfoForLowered (PTy));
1435
1433
auto PDITy = getOrCreateType (PDbgTy);
@@ -1513,22 +1511,21 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1513
1511
}
1514
1512
1515
1513
// Reference storage types.
1516
- #define REF_STORAGE (Name, ...) \
1517
- case TypeKind::Name##Storage:
1514
+ #define REF_STORAGE (Name, ...) case TypeKind::Name##Storage:
1518
1515
#include " swift/AST/ReferenceStorage.def"
1519
- {
1520
- auto *ReferenceTy = cast<ReferenceStorageType>(BaseTy);
1521
- auto CanTy = ReferenceTy->getReferentType ();
1522
- auto L = getDebugLoc (*this , DbgTy.getDecl ());
1523
- auto *File = getOrCreateFile (L.Filename );
1524
- unsigned CompilerGeneratedLine = 0 ;
1525
-
1526
- return DBuilder.createTypedef (getOrCreateDesugaredType (CanTy, DbgTy),
1527
- MangledName, File, CompilerGeneratedLine,
1528
- File);
1529
- }
1516
+ {
1517
+ auto *ReferenceTy = cast<ReferenceStorageType>(BaseTy);
1518
+ auto CanTy = ReferenceTy->getReferentType ();
1519
+ auto L = getDebugLoc (*this , DbgTy.getDecl ());
1520
+ auto *File = getOrCreateFile (L.Filename );
1521
+ unsigned CompilerGeneratedLine = 0 ;
1522
+
1523
+ return DBuilder.createTypedef (getOrCreateDesugaredType (CanTy, DbgTy),
1524
+ MangledName, File, CompilerGeneratedLine,
1525
+ File);
1526
+ }
1530
1527
1531
- // Sugared types.
1528
+ // Sugared types.
1532
1529
1533
1530
case TypeKind::TypeAlias: {
1534
1531
auto *TypeAliasTy = cast<TypeAliasType>(BaseTy);
@@ -1564,9 +1561,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1564
1561
case TypeKind::GenericTypeParam: {
1565
1562
// FIXME: Provide a more meaningful debug type.
1566
1563
return DBuilder.createStructType (
1567
- Scope, MangledName, File, 0 , SizeInBits, AlignInBits, Flags,
1568
- nullptr , nullptr ,
1569
- llvm::dwarf::DW_LANG_Swift, nullptr , MangledName);
1564
+ Scope, MangledName, File, 0 , SizeInBits, AlignInBits, Flags, nullptr ,
1565
+ nullptr , llvm::dwarf::DW_LANG_Swift, nullptr , MangledName);
1570
1566
}
1571
1567
1572
1568
// The following types exist primarily for internal use by the type
@@ -1582,8 +1578,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1582
1578
case TypeKind::BuiltinUnsafeValueBuffer:
1583
1579
1584
1580
LLVM_DEBUG (llvm::dbgs () << " Unhandled type: " ;
1585
- DbgTy.getType ()->dump (llvm::dbgs ());
1586
- llvm::dbgs () << " \n " );
1581
+ DbgTy.getType ()->dump (llvm::dbgs ()); llvm::dbgs () << " \n " );
1587
1582
MangledName = " <unknown>" ;
1588
1583
}
1589
1584
return DBuilder.createBasicType (MangledName, SizeInBits, Encoding);
@@ -1704,7 +1699,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
1704
1699
llvm::dwarf::DW_LANG_Swift, 0 , 0 , llvm::DINode::FlagFwdDecl,
1705
1700
MangledName);
1706
1701
ReplaceMap.emplace_back (
1707
- std::piecewise_construct, std::make_tuple (DbgTy.getType ()),
1702
+ std::piecewise_construct, std::make_tuple (DbgTy.getType ()),
1708
1703
std::make_tuple (static_cast <llvm::Metadata *>(FwdDecl)));
1709
1704
return FwdDecl;
1710
1705
}
@@ -1779,12 +1774,11 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
1779
1774
}
1780
1775
1781
1776
TheCU = DBuilder.createCompileUnit (
1782
- Lang, MainFile,
1783
- Producer, Opts.shouldOptimize (), Opts.getDebugFlags (PD),
1777
+ Lang, MainFile, Producer, Opts.shouldOptimize (), Opts.getDebugFlags (PD),
1784
1778
MajorRuntimeVersion, SplitName,
1785
1779
Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
1786
1780
? llvm::DICompileUnit::FullDebug
1787
- : llvm::DICompileUnit::LineTablesOnly,
1781
+ : llvm::DICompileUnit::LineTablesOnly,
1788
1782
/* DWOId */ 0 , /* SplitDebugInlining */ true ,
1789
1783
/* DebugInfoForProfiling */ false ,
1790
1784
llvm::DICompileUnit::DebugNameTableKind::Default,
@@ -1820,9 +1814,14 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
1820
1814
OS << ' "' ;
1821
1815
for (char c : Macro)
1822
1816
switch (c) {
1823
- case ' \\ ' : OS << " \\\\ " ; break ;
1824
- case ' "' : OS << " \\\" " ; break ;
1825
- default : OS << c;
1817
+ case ' \\ ' :
1818
+ OS << " \\\\ " ;
1819
+ break ;
1820
+ case ' "' :
1821
+ OS << " \\\" " ;
1822
+ break ;
1823
+ default :
1824
+ OS << c;
1826
1825
}
1827
1826
OS << ' "' ;
1828
1827
}
@@ -1954,20 +1953,20 @@ void IRGenDebugInfoImpl::addFailureMessageToCurrentLoc(IRBuilder &Builder,
1954
1953
FuncName += failureMsg;
1955
1954
1956
1955
llvm::DISubprogram *TrapSP = DBuilder.createFunction (
1957
- MainModule, FuncName, StringRef (), TrapLoc->getFile (), 0 , DIFnTy, 0 ,
1958
- llvm::DINode::FlagArtificial, llvm::DISubprogram::SPFlagDefinition,
1959
- nullptr , nullptr , nullptr );
1956
+ MainModule, FuncName, StringRef (), TrapLoc->getFile (), 0 , DIFnTy, 0 ,
1957
+ llvm::DINode::FlagArtificial, llvm::DISubprogram::SPFlagDefinition,
1958
+ nullptr , nullptr , nullptr );
1960
1959
1961
1960
ScopeCache[TrapSc] = llvm::TrackingMDNodeRef (TrapSP);
1962
1961
LastScope = TrapSc;
1963
-
1962
+
1964
1963
assert (parentScopesAreSane (TrapSc) && " parent scope sanity check failed" );
1965
-
1964
+
1966
1965
// Wrap the existing TrapLoc into the failure function.
1967
1966
auto DL = llvm::DebugLoc::get (0 , 0 , TrapSP, TrapLoc);
1968
1967
Builder.SetCurrentDebugLocation (DL);
1969
1968
}
1970
-
1969
+
1971
1970
void IRGenDebugInfoImpl::clearLoc (IRBuilder &Builder) {
1972
1971
LastDebugLoc = {};
1973
1972
LastScope = nullptr ;
@@ -2287,7 +2286,7 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
2287
2286
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
2288
2287
if (Artificial || DITy->isArtificial () || DITy == InternalType)
2289
2288
Flags |= llvm::DINode::FlagArtificial;
2290
-
2289
+
2291
2290
// This could be Opts.Optimize if we would also unique DIVariables here.
2292
2291
bool Optimized = false ;
2293
2292
// Create the descriptor for the variable.
@@ -2413,8 +2412,7 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
2413
2412
2414
2413
void IRGenDebugInfoImpl::emitTypeMetadata (IRGenFunction &IGF,
2415
2414
llvm::Value *Metadata, unsigned Depth,
2416
- unsigned Index,
2417
- StringRef Name) {
2415
+ unsigned Index, StringRef Name) {
2418
2416
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
2419
2417
return ;
2420
2418
@@ -2452,12 +2450,10 @@ std::unique_ptr<IRGenDebugInfo> IRGenDebugInfo::createIRGenDebugInfo(
2452
2450
const IRGenOptions &Opts, ClangImporter &CI, IRGenModule &IGM,
2453
2451
llvm::Module &M, StringRef MainOutputFilenameForDebugInfo,
2454
2452
StringRef PrivateDiscriminator) {
2455
- return std::make_unique<IRGenDebugInfoImpl>(Opts, CI, IGM, M,
2456
- MainOutputFilenameForDebugInfo,
2457
- PrivateDiscriminator);
2453
+ return std::make_unique<IRGenDebugInfoImpl>(
2454
+ Opts, CI, IGM, M, MainOutputFilenameForDebugInfo, PrivateDiscriminator);
2458
2455
}
2459
2456
2460
-
2461
2457
IRGenDebugInfo::~IRGenDebugInfo () {}
2462
2458
2463
2459
// Forwarding to the private implementation.
@@ -2472,8 +2468,8 @@ void IRGenDebugInfo::setCurrentLoc(IRBuilder &Builder, const SILDebugScope *DS,
2472
2468
2473
2469
void IRGenDebugInfo::addFailureMessageToCurrentLoc (IRBuilder &Builder,
2474
2470
StringRef failureMsg) {
2475
- static_cast <IRGenDebugInfoImpl *>(this )->
2476
- addFailureMessageToCurrentLoc ( Builder, failureMsg);
2471
+ static_cast <IRGenDebugInfoImpl *>(this )->addFailureMessageToCurrentLoc (
2472
+ Builder, failureMsg);
2477
2473
}
2478
2474
2479
2475
void IRGenDebugInfo::clearLoc (IRBuilder &Builder) {
@@ -2513,10 +2509,9 @@ void IRGenDebugInfo::emitImport(ImportDecl *D) {
2513
2509
llvm::DISubprogram *
2514
2510
IRGenDebugInfo::emitFunction (const SILDebugScope *DS, llvm::Function *Fn,
2515
2511
SILFunctionTypeRepresentation Rep, SILType Ty,
2516
- DeclContext *DeclCtx,
2517
- GenericEnvironment *GE) {
2512
+ DeclContext *DeclCtx, GenericEnvironment *GE) {
2518
2513
return static_cast <IRGenDebugInfoImpl *>(this )->emitFunction (DS, Fn, Rep, Ty,
2519
- DeclCtx);
2514
+ DeclCtx);
2520
2515
}
2521
2516
2522
2517
llvm::DISubprogram *IRGenDebugInfo::emitFunction (SILFunction &SILFn,
@@ -2525,10 +2520,9 @@ llvm::DISubprogram *IRGenDebugInfo::emitFunction(SILFunction &SILFn,
2525
2520
}
2526
2521
2527
2522
void IRGenDebugInfo::emitArtificialFunction (IRBuilder &Builder,
2528
- llvm::Function *Fn,
2529
- SILType SILTy) {
2530
- static_cast <IRGenDebugInfoImpl *>(this )->emitArtificialFunction (Builder,
2531
- Fn, SILTy);
2523
+ llvm::Function *Fn, SILType SILTy) {
2524
+ static_cast <IRGenDebugInfoImpl *>(this )->emitArtificialFunction (Builder, Fn,
2525
+ SILTy);
2532
2526
}
2533
2527
2534
2528
void IRGenDebugInfo::emitVariableDeclaration (
@@ -2559,8 +2553,8 @@ void IRGenDebugInfo::emitGlobalVariableDeclaration(
2559
2553
void IRGenDebugInfo::emitTypeMetadata (IRGenFunction &IGF, llvm::Value *Metadata,
2560
2554
unsigned Depth, unsigned Index,
2561
2555
StringRef Name) {
2562
- static_cast <IRGenDebugInfoImpl *>(this )->emitTypeMetadata (
2563
- IGF, Metadata, Depth, Index, Name);
2556
+ static_cast <IRGenDebugInfoImpl *>(this )->emitTypeMetadata (IGF, Metadata,
2557
+ Depth, Index, Name);
2564
2558
}
2565
2559
2566
2560
llvm::DIBuilder &IRGenDebugInfo::getBuilder () {
0 commit comments