Skip to content

Commit 633f9e1

Browse files
committed
clang-format IRGenDebugInfo.
1 parent 248ba62 commit 633f9e1

File tree

1 file changed

+75
-81
lines changed

1 file changed

+75
-81
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 75 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
#include "swift/ClangImporter/ClangImporter.h"
3131
#include "swift/ClangImporter/ClangModule.h"
3232
#include "swift/Demangling/ManglingMacros.h"
33-
#include "swift/Serialization/SerializedModuleLoader.h"
3433
#include "swift/SIL/SILArgument.h"
3534
#include "swift/SIL/SILBasicBlock.h"
3635
#include "swift/SIL/SILDebugScope.h"
3736
#include "swift/SIL/SILModule.h"
37+
#include "swift/Serialization/SerializedModuleLoader.h"
3838
#include "clang/AST/ASTContext.h"
3939
#include "clang/AST/Decl.h"
4040
#include "clang/AST/ExternalASTSource.h"
@@ -140,7 +140,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
140140
llvm::DenseSet<UUSTuple> PreviousLineEntries;
141141
SILLocation::DebugLoc PreviousDebugLoc;
142142
#endif
143-
143+
144144
public:
145145
IRGenDebugInfoImpl(const IRGenOptions &Opts, ClangImporter &CI,
146146
IRGenModule &IGM, llvm::Module &M,
@@ -484,8 +484,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
484484
}
485485

486486
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);
489489
return BumpAllocatedString(Name);
490490
}
491491

@@ -518,8 +518,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
518518
auto FnTy = SILTy.getAs<SILFunctionType>();
519519
if (!FnTy) {
520520
LLVM_DEBUG(llvm::dbgs() << "Unexpected function type: ";
521-
SILTy.print(llvm::dbgs());
522-
llvm::dbgs() << "\n");
521+
SILTy.print(llvm::dbgs()); llvm::dbgs() << "\n");
523522
return CanSILFunctionType();
524523
}
525524

@@ -582,7 +581,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
582581
void createParameterType(llvm::SmallVectorImpl<llvm::Metadata *> &Parameters,
583582
SILType type) {
584583
auto RealType = type.getASTType();
585-
auto DbgTy = DebugTypeInfo::getFromTypeInfo(RealType, IGM.getTypeInfo(type));
584+
auto DbgTy =
585+
DebugTypeInfo::getFromTypeInfo(RealType, IGM.getTypeInfo(type));
586586
Parameters.push_back(getOrCreateType(DbgTy));
587587
}
588588

@@ -721,7 +721,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
721721
return Desc;
722722
return None;
723723
}
724-
724+
725725
llvm::DIModule *getOrCreateModule(ModuleDecl::ImportedModule IM) {
726726
ModuleDecl *M = IM.importedModule;
727727
if (Optional<ASTSourceDescriptor> ModuleDesc = getClangModule(*M))
@@ -795,15 +795,15 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
795795

796796
break;
797797
}
798-
798+
799799
// TODO: Eliminate substitutions in SILFunctionTypes for now.
800800
// On platforms where the substitutions affect representation, we will need
801801
// to preserve this info and teach type reconstruction about it.
802-
Ty = Ty->replaceSubstitutedSILFunctionTypesWithUnsubstituted(IGM.getSILModule());
802+
Ty = Ty->replaceSubstitutedSILFunctionTypesWithUnsubstituted(
803+
IGM.getSILModule());
803804

804805
Mangle::ASTMangler Mangler;
805-
std::string Result = Mangler.mangleTypeForDebugger(
806-
Ty, nullptr);
806+
std::string Result = Mangler.mangleTypeForDebugger(Ty, nullptr);
807807

808808
if (!Opts.DisableRoundTripDebugTypes) {
809809
// Make sure we can reconstruct mangled types for the debugger.
@@ -845,17 +845,17 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
845845
return DITy;
846846
}
847847

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) {
851852
SmallVector<llvm::Metadata *, 16> Elements;
852853
unsigned OffsetInBits = 0;
853854
auto genericSig = IGM.getCurGenericContext();
854855
for (auto ElemTy : TupleTy->getElementTypes()) {
855856
auto &elemTI = IGM.getTypeInfoForUnlowered(
856857
AbstractionPattern(genericSig, ElemTy->getCanonicalType()), ElemTy);
857-
auto DbgTy =
858-
DebugTypeInfo::getFromTypeInfo(ElemTy, elemTI);
858+
auto DbgTy = DebugTypeInfo::getFromTypeInfo(ElemTy, elemTI);
859859
Elements.push_back(createMemberType(DbgTy, StringRef(), OffsetInBits,
860860
Scope, File, Flags));
861861
}
@@ -1017,14 +1017,14 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
10171017
/// anchor any typedefs that may appear in parameters so they can be
10181018
/// resolved in the debugger without needing to query the Swift module.
10191019
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);
10261026
}
1027-
1027+
10281028
/// Create a sized container for a sizeless type. Used to represent
10291029
/// BoundGenericEnums that may have different sizes depending on what they are
10301030
/// bound to, but still share a mangled name.
@@ -1048,9 +1048,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
10481048
InnerTypeCache[UID] = llvm::TrackingMDNodeRef(UniqueType);
10491049
}
10501050

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)};
10541053
return DBuilder.createStructType(
10551054
Scope, "", File, Line, SizeInBits, AlignInBits, Flags,
10561055
/* DerivedFrom */ nullptr, DBuilder.getOrCreateArray(Elements),
@@ -1230,8 +1229,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
12301229

12311230
if (!BaseTy) {
12321231
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");
12351233
if (!InternalType) {
12361234
StringRef Name = "<internal>";
12371235
InternalType = DBuilder.createForwardDecl(
@@ -1428,8 +1426,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
14281426
// Emit the protocols the archetypes conform to.
14291427
SmallVector<llvm::Metadata *, 4> Protocols;
14301428
for (auto *ProtocolDecl : Archetype->getConformsTo()) {
1431-
auto PTy = IGM.getLoweredType(ProtocolDecl->getInterfaceType())
1432-
.getASTType();
1429+
auto PTy =
1430+
IGM.getLoweredType(ProtocolDecl->getInterfaceType()).getASTType();
14331431
auto PDbgTy = DebugTypeInfo::getFromTypeInfo(
14341432
ProtocolDecl->getInterfaceType(), IGM.getTypeInfoForLowered(PTy));
14351433
auto PDITy = getOrCreateType(PDbgTy);
@@ -1513,22 +1511,21 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
15131511
}
15141512

15151513
// Reference storage types.
1516-
#define REF_STORAGE(Name, ...) \
1517-
case TypeKind::Name##Storage:
1514+
#define REF_STORAGE(Name, ...) case TypeKind::Name##Storage:
15181515
#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+
}
15301527

1531-
// Sugared types.
1528+
// Sugared types.
15321529

15331530
case TypeKind::TypeAlias: {
15341531
auto *TypeAliasTy = cast<TypeAliasType>(BaseTy);
@@ -1564,9 +1561,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
15641561
case TypeKind::GenericTypeParam: {
15651562
// FIXME: Provide a more meaningful debug type.
15661563
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);
15701566
}
15711567

15721568
// The following types exist primarily for internal use by the type
@@ -1582,8 +1578,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
15821578
case TypeKind::BuiltinUnsafeValueBuffer:
15831579

15841580
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");
15871582
MangledName = "<unknown>";
15881583
}
15891584
return DBuilder.createBasicType(MangledName, SizeInBits, Encoding);
@@ -1704,7 +1699,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
17041699
llvm::dwarf::DW_LANG_Swift, 0, 0, llvm::DINode::FlagFwdDecl,
17051700
MangledName);
17061701
ReplaceMap.emplace_back(
1707-
std::piecewise_construct, std::make_tuple(DbgTy.getType()),
1702+
std::piecewise_construct, std::make_tuple(DbgTy.getType()),
17081703
std::make_tuple(static_cast<llvm::Metadata *>(FwdDecl)));
17091704
return FwdDecl;
17101705
}
@@ -1779,12 +1774,11 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
17791774
}
17801775

17811776
TheCU = DBuilder.createCompileUnit(
1782-
Lang, MainFile,
1783-
Producer, Opts.shouldOptimize(), Opts.getDebugFlags(PD),
1777+
Lang, MainFile, Producer, Opts.shouldOptimize(), Opts.getDebugFlags(PD),
17841778
MajorRuntimeVersion, SplitName,
17851779
Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
17861780
? llvm::DICompileUnit::FullDebug
1787-
: llvm::DICompileUnit::LineTablesOnly,
1781+
: llvm::DICompileUnit::LineTablesOnly,
17881782
/* DWOId */ 0, /* SplitDebugInlining */ true,
17891783
/* DebugInfoForProfiling */ false,
17901784
llvm::DICompileUnit::DebugNameTableKind::Default,
@@ -1820,9 +1814,14 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
18201814
OS << '"';
18211815
for (char c : Macro)
18221816
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;
18261825
}
18271826
OS << '"';
18281827
}
@@ -1954,20 +1953,20 @@ void IRGenDebugInfoImpl::addFailureMessageToCurrentLoc(IRBuilder &Builder,
19541953
FuncName += failureMsg;
19551954

19561955
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);
19601959

19611960
ScopeCache[TrapSc] = llvm::TrackingMDNodeRef(TrapSP);
19621961
LastScope = TrapSc;
1963-
1962+
19641963
assert(parentScopesAreSane(TrapSc) && "parent scope sanity check failed");
1965-
1964+
19661965
// Wrap the existing TrapLoc into the failure function.
19671966
auto DL = llvm::DebugLoc::get(0, 0, TrapSP, TrapLoc);
19681967
Builder.SetCurrentDebugLocation(DL);
19691968
}
1970-
1969+
19711970
void IRGenDebugInfoImpl::clearLoc(IRBuilder &Builder) {
19721971
LastDebugLoc = {};
19731972
LastScope = nullptr;
@@ -2287,7 +2286,7 @@ void IRGenDebugInfoImpl::emitVariableDeclaration(
22872286
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
22882287
if (Artificial || DITy->isArtificial() || DITy == InternalType)
22892288
Flags |= llvm::DINode::FlagArtificial;
2290-
2289+
22912290
// This could be Opts.Optimize if we would also unique DIVariables here.
22922291
bool Optimized = false;
22932292
// Create the descriptor for the variable.
@@ -2413,8 +2412,7 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
24132412

24142413
void IRGenDebugInfoImpl::emitTypeMetadata(IRGenFunction &IGF,
24152414
llvm::Value *Metadata, unsigned Depth,
2416-
unsigned Index,
2417-
StringRef Name) {
2415+
unsigned Index, StringRef Name) {
24182416
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
24192417
return;
24202418

@@ -2452,12 +2450,10 @@ std::unique_ptr<IRGenDebugInfo> IRGenDebugInfo::createIRGenDebugInfo(
24522450
const IRGenOptions &Opts, ClangImporter &CI, IRGenModule &IGM,
24532451
llvm::Module &M, StringRef MainOutputFilenameForDebugInfo,
24542452
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);
24582455
}
24592456

2460-
24612457
IRGenDebugInfo::~IRGenDebugInfo() {}
24622458

24632459
// Forwarding to the private implementation.
@@ -2472,8 +2468,8 @@ void IRGenDebugInfo::setCurrentLoc(IRBuilder &Builder, const SILDebugScope *DS,
24722468

24732469
void IRGenDebugInfo::addFailureMessageToCurrentLoc(IRBuilder &Builder,
24742470
StringRef failureMsg) {
2475-
static_cast<IRGenDebugInfoImpl *>(this)->
2476-
addFailureMessageToCurrentLoc(Builder, failureMsg);
2471+
static_cast<IRGenDebugInfoImpl *>(this)->addFailureMessageToCurrentLoc(
2472+
Builder, failureMsg);
24772473
}
24782474

24792475
void IRGenDebugInfo::clearLoc(IRBuilder &Builder) {
@@ -2513,10 +2509,9 @@ void IRGenDebugInfo::emitImport(ImportDecl *D) {
25132509
llvm::DISubprogram *
25142510
IRGenDebugInfo::emitFunction(const SILDebugScope *DS, llvm::Function *Fn,
25152511
SILFunctionTypeRepresentation Rep, SILType Ty,
2516-
DeclContext *DeclCtx,
2517-
GenericEnvironment *GE) {
2512+
DeclContext *DeclCtx, GenericEnvironment *GE) {
25182513
return static_cast<IRGenDebugInfoImpl *>(this)->emitFunction(DS, Fn, Rep, Ty,
2519-
DeclCtx);
2514+
DeclCtx);
25202515
}
25212516

25222517
llvm::DISubprogram *IRGenDebugInfo::emitFunction(SILFunction &SILFn,
@@ -2525,10 +2520,9 @@ llvm::DISubprogram *IRGenDebugInfo::emitFunction(SILFunction &SILFn,
25252520
}
25262521

25272522
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);
25322526
}
25332527

25342528
void IRGenDebugInfo::emitVariableDeclaration(
@@ -2559,8 +2553,8 @@ void IRGenDebugInfo::emitGlobalVariableDeclaration(
25592553
void IRGenDebugInfo::emitTypeMetadata(IRGenFunction &IGF, llvm::Value *Metadata,
25602554
unsigned Depth, unsigned Index,
25612555
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);
25642558
}
25652559

25662560
llvm::DIBuilder &IRGenDebugInfo::getBuilder() {

0 commit comments

Comments
 (0)