Skip to content

Commit 0bdaa52

Browse files
authored
Merge pull request #25918 from gottesmm/pr-30c3bd84dd6a3d388dda37c71df157036987edf2
[sil] Add dumpers for ResilienceExpansion/TypeLowering.
2 parents 5cddc40 + 6c6bfc2 commit 0bdaa52

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

include/swift/AST/ResilienceExpansion.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#ifndef SWIFT_AST_RESILIENCE_EXPANSION_H
1414
#define SWIFT_AST_RESILIENCE_EXPANSION_H
1515

16+
#include "llvm/Support/raw_ostream.h"
17+
1618
namespace swift {
1719

1820
/// A specification for how much to expand resilient types.
@@ -44,6 +46,16 @@ enum class ResilienceExpansion : unsigned {
4446
Last_ResilienceExpansion = Maximal
4547
};
4648

49+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &os,
50+
ResilienceExpansion expansion) {
51+
switch (expansion) {
52+
case ResilienceExpansion::Minimal:
53+
return os << "Minimal";
54+
case ResilienceExpansion::Maximal:
55+
return os << "Maximal";
56+
}
57+
}
58+
4759
} // namespace swift
4860

4961
#endif // LLVM_SWIFT_AST_CAPTURE_INFO_H

include/swift/SIL/TypeLowering.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ class TypeLowering {
250250

251251
virtual ~TypeLowering() {}
252252

253+
/// Print out the internal state of this type lowering into \p os.
254+
void print(llvm::raw_ostream &os) const;
255+
256+
/// Dump out the internal state of this type lowering to llvm::dbgs().
257+
LLVM_ATTRIBUTE_DEPRECATED(void dump() const, "Only for use in the debugger");
258+
253259
/// Are r-values of this type passed as arguments indirectly by formal
254260
/// convention?
255261
///

lib/SIL/TypeLowering.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2687,3 +2687,22 @@ unsigned TypeConverter::countNumberOfFields(SILType Ty,
26872687
TypeFields[key] = fieldsCount;
26882688
return std::max(fieldsCount, 1U);
26892689
}
2690+
2691+
void TypeLowering::print(llvm::raw_ostream &os) const {
2692+
auto BOOL = [&](bool b) -> StringRef {
2693+
if (b)
2694+
return "true";
2695+
return "false";
2696+
};
2697+
os << "Type Lowering for lowered type: " << LoweredType << ".\n"
2698+
<< "Expansion: " << ResilienceExpansion(ForExpansion) << "\n"
2699+
<< "isTrivial: " << BOOL(Properties.isTrivial()) << ".\n"
2700+
<< "isFixedABI: " << BOOL(Properties.isFixedABI()) << ".\n"
2701+
<< "isAddressOnly: " << BOOL(Properties.isAddressOnly()) << ".\n"
2702+
<< "isResilient: " << BOOL(Properties.isResilient()) << ".\n"
2703+
<< "\n";
2704+
}
2705+
2706+
void TypeLowering::dump() const {
2707+
print(llvm::dbgs());
2708+
}

0 commit comments

Comments
 (0)