Skip to content

Commit 08d77cd

Browse files
committed
[move-only] Make SILType::getRawASTType() private and make SILPrinter a friend so we can invoke that method.
The only place outside of SILType that uses getRawASTType() is in SILPrinter. It is really an inner detail of SILType that we don't want to expose. With that in mind, in this commit we: 1. Made SILType::getRawASTType() private. 2. Forward declared SILPrinter in SILType.h. We don't define it so no one can use it, but the declaration still lets us make it a friend class of SILType (allowing SILPrinter to still access getRawASTType()).
1 parent 9e69e4d commit 08d77cd

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

include/swift/SIL/SILType.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ enum class SILValueCategory : uint8_t {
8686
Address,
8787
};
8888

89+
class SILPrinter;
90+
8991
/// SILType - A Swift type that has been lowered to a SIL representation type.
9092
/// In addition to the Swift type system, SIL adds "address" types that can
9193
/// reference any Swift type (but cannot take the address of an address). *T
@@ -113,6 +115,8 @@ class SILType {
113115

114116
friend class Lowering::TypeConverter;
115117
friend struct llvm::DenseMapInfo<SILType>;
118+
friend class SILPrinter;
119+
116120
public:
117121
SILType() = default;
118122

@@ -186,6 +190,7 @@ class SILType {
186190
/// move only-ness of the value (which we can query separately anyways).
187191
CanType getASTType() const { return withoutMoveOnly().getRawASTType(); }
188192

193+
private:
189194
/// Returns the canonical AST type references by this SIL type without looking
190195
/// through move only. Should only be used by internal utilities of SILType.
191196
CanType getRawASTType() const { return CanType(value.getPointer()); }

lib/SIL/IR/SILPrinter.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,6 @@ static void printSILFunctionNameAndType(llvm::raw_ostream &OS,
532532
}
533533

534534
namespace {
535-
536-
class SILPrinter;
537535

538536
// 1. Accumulate opcode-specific comments in this stream.
539537
// 2. Start emitting comments: lineComments.start()
@@ -598,6 +596,10 @@ class LineComments : public raw_ostream {
598596
}
599597
};
600598

599+
} // namespace
600+
601+
namespace swift {
602+
601603
/// SILPrinter class - This holds the internal implementation details of
602604
/// printing SIL structures.
603605
class SILPrinter : public SILInstructionVisitor<SILPrinter> {
@@ -2740,7 +2742,8 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
27402742
}
27412743
}
27422744
};
2743-
} // end anonymous namespace
2745+
2746+
} // namespace swift
27442747

27452748
static void printBlockID(raw_ostream &OS, SILBasicBlock *bb) {
27462749
SILPrintContext Ctx(OS);

0 commit comments

Comments
 (0)