Skip to content

Commit 96cb756

Browse files
authored
Merge pull request #36165 from ahoppen/pr/dont-ref-count-rawsyntax
[libSyntax] Don't reference count RawSyntax
2 parents a57f2d8 + 9ff88b2 commit 96cb756

30 files changed

+1397
-1206
lines changed

include/swift/Parse/Parser.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,10 +1826,12 @@ bool isKeywordPossibleDeclStart(const Token &Tok);
18261826

18271827
/// Lex and return a vector of `TokenSyntax` tokens, which include
18281828
/// leading and trailing trivia.
1829-
std::vector<std::pair<RC<syntax::RawSyntax>, syntax::AbsoluteOffsetPosition>>
1829+
std::vector<
1830+
std::pair<const syntax::RawSyntax *, syntax::AbsoluteOffsetPosition>>
18301831
tokenizeWithTrivia(const LangOptions &LangOpts, const SourceManager &SM,
1831-
unsigned BufferID, unsigned Offset = 0,
1832-
unsigned EndOffset = 0, DiagnosticEngine *Diags = nullptr);
1832+
unsigned BufferID, const RC<SyntaxArena> &Arena,
1833+
unsigned Offset = 0, unsigned EndOffset = 0,
1834+
DiagnosticEngine *Diags = nullptr);
18331835
} // end namespace swift
18341836

18351837
#endif

include/swift/Syntax/AbsoluteRawSyntax.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ class SyntaxIndexInTree {
3232

3333
/// Assuming that this index points to the start of \p Raw, advance it so that
3434
/// it points to the next sibling of \p Raw.
35-
SyntaxIndexInTree advancedBy(const RC<RawSyntax> &Raw) const;
35+
SyntaxIndexInTree advancedBy(const RawSyntax *Raw) const;
3636

3737
/// Assuming that this index points to the next sibling of \p Raw, reverse it
3838
/// so that it points to the start of \p Raw.
39-
SyntaxIndexInTree reversedBy(const RC<RawSyntax> &Raw) const;
39+
SyntaxIndexInTree reversedBy(const RawSyntax *Raw) const;
4040

4141
/// Advance this index to point to its first immediate child.
4242
SyntaxIndexInTree advancedToFirstChild() const;
@@ -84,14 +84,14 @@ class SyntaxIdentifier {
8484

8585
/// Assuming that this identifier points to the start of \p Raw, advance it so
8686
/// that it points to the next sibling of \p Raw.
87-
SyntaxIdentifier advancedBy(const RC<RawSyntax> &Raw) const {
87+
SyntaxIdentifier advancedBy(const RawSyntax *Raw) const {
8888
auto NewIndexInTree = IndexInTree.advancedBy(Raw);
8989
return SyntaxIdentifier(RootId, NewIndexInTree);
9090
}
9191

9292
/// Assuming that this identifier points to the next sibling of \p Raw,
9393
/// reverse it so that it points to the start of \p Raw.
94-
SyntaxIdentifier reversedBy(const RC<RawSyntax> &Raw) const {
94+
SyntaxIdentifier reversedBy(const RawSyntax *Raw) const {
9595
auto NewIndexInTree = IndexInTree.reversedBy(Raw);
9696
return SyntaxIdentifier(RootId, NewIndexInTree);
9797
}
@@ -138,11 +138,11 @@ class AbsoluteSyntaxPosition {
138138

139139
/// Assuming that this position points to the start of \p Raw, advance it so
140140
/// that it points to the next sibling of \p Raw.
141-
AbsoluteSyntaxPosition advancedBy(const RC<RawSyntax> &Raw) const;
141+
AbsoluteSyntaxPosition advancedBy(const RawSyntax *Raw) const;
142142

143143
/// Assuming that this position points to the next sibling of \p Raw, reverse
144144
/// it so that it points to the start of \p Raw.
145-
AbsoluteSyntaxPosition reversedBy(const RC<RawSyntax> &Raw) const;
145+
AbsoluteSyntaxPosition reversedBy(const RawSyntax *Raw) const;
146146

147147
/// Get the position of the node's first immediate child.
148148
AbsoluteSyntaxPosition advancedToFirstChild() const {
@@ -189,15 +189,15 @@ class AbsoluteSyntaxInfo {
189189

190190
/// Assuming that this info points to the start of \p Raw, advance it so
191191
/// that it points to the next sibling of \p Raw.
192-
AbsoluteSyntaxInfo advancedBy(const RC<RawSyntax> &Raw) const {
192+
AbsoluteSyntaxInfo advancedBy(const RawSyntax *Raw) const {
193193
auto NewNodeId = NodeId.advancedBy(Raw);
194194
auto NewPosition = Position.advancedBy(Raw);
195195
return AbsoluteSyntaxInfo(NewPosition, NewNodeId);
196196
}
197197

198198
/// Assuming that this info points to the next sibling of \p Raw, reverse
199199
/// it so that it points to the start of \p Raw.
200-
AbsoluteSyntaxInfo reversedBy(const RC<RawSyntax> &Raw) const {
200+
AbsoluteSyntaxInfo reversedBy(const RawSyntax *Raw) const {
201201
auto NewNodeId = NodeId.reversedBy(Raw);
202202
auto NewPosition = Position.reversedBy(Raw);
203203
return AbsoluteSyntaxInfo(NewPosition, NewNodeId);
@@ -214,20 +214,20 @@ class AbsoluteSyntaxInfo {
214214
/// A \c RawSyntax node that is enrichted with information of its position
215215
/// within the syntax tree it lives in.
216216
struct AbsoluteRawSyntax {
217-
const RC<RawSyntax> Raw;
217+
const RawSyntax *Raw;
218218
const AbsoluteSyntaxInfo Info;
219219

220220
public:
221-
AbsoluteRawSyntax(const RC<RawSyntax> &Raw, AbsoluteSyntaxInfo Info)
221+
AbsoluteRawSyntax(const RawSyntax *Raw, AbsoluteSyntaxInfo Info)
222222
: Raw(Raw), Info(Info) {}
223223

224224
/// Construct a \c AbsoluteRawSyntax for a \c RawSyntax node that represents
225225
/// the syntax tree's root.
226-
static AbsoluteRawSyntax forRoot(const RC<RawSyntax> &Raw) {
226+
static AbsoluteRawSyntax forRoot(const RawSyntax *Raw) {
227227
return AbsoluteRawSyntax(Raw, AbsoluteSyntaxInfo::forRoot());
228228
}
229229

230-
const RC<RawSyntax> &getRaw() const { return Raw; }
230+
const RawSyntax *getRaw() const { return Raw; }
231231

232232
AbsoluteSyntaxInfo getInfo() const { return Info; }
233233

@@ -245,7 +245,7 @@ struct AbsoluteRawSyntax {
245245
/// - the \p NewRaw as the backing storage
246246
/// - the \p NewRootId as the RootId
247247
AbsoluteRawSyntax
248-
replacingSelf(const RC<RawSyntax> &NewRaw,
248+
replacingSelf(const RawSyntax *NewRaw,
249249
SyntaxIdentifier::RootIdType NewRootId) const {
250250
SyntaxIdentifier NewNodeId(NewRootId, Info.getNodeId().getIndexInTree());
251251
AbsoluteSyntaxInfo NewInfo(Info.getPosition(), NewNodeId);

0 commit comments

Comments
 (0)