Skip to content

Commit a46582d

Browse files
committed
Swift: replace friend in TrapLabel with unsafeCreateFromExplicitId
1 parent e679612 commit a46582d

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

swift/extractor/trap/TrapArena.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TrapArena {
1616
public:
1717
template <typename Tag>
1818
TrapLabel<Tag> allocateLabel() {
19-
return {id_++};
19+
return TrapLabel<Tag>::unsafeCreateFromExplicitId(id_++);
2020
}
2121
};
2222

swift/extractor/trap/TrapLabel.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,14 @@ class TrapLabel : public UntypedTrapLabel {
3434

3535
using UntypedTrapLabel::UntypedTrapLabel;
3636

37-
// we want one authority tasked with creating labels to avoid conflicts, having access to the
38-
// private constructor
39-
// this is the TrapArena class for the moment
40-
friend class TrapArena;
41-
4237
public:
4338
using Tag = TagParam;
4439

4540
TrapLabel() = default;
4641

42+
// The caller is responsible for ensuring ID uniqueness.
43+
static TrapLabel unsafeCreateFromExplicitId(uint64_t id) { return {id}; }
44+
4745
template <typename OtherTag>
4846
TrapLabel(const TrapLabel<OtherTag>& other) : UntypedTrapLabel(other) {
4947
// we temporarily need to bypass the label type system for unknown AST nodes and types

0 commit comments

Comments
 (0)