Skip to content

Commit aa65455

Browse files
committed
[SyntaxParse] Release created token in LibSyntaxGenerator::createToken()
This used to cause memory leaks. rdar://problem/55712090
1 parent c56421c commit aa65455

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/swift/Parse/LibSyntaxGenerator.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class LibSyntaxGenerator {
4444

4545
auto Recorded = Recorder.recordToken(Kind, Range, LeadingTriviaPieces,
4646
TrailingTriviaPieces);
47-
auto Raw = static_cast<RawSyntax *>(Recorded.takeOpaqueNode());
47+
RC<RawSyntax> Raw{static_cast<RawSyntax *>(Recorded.takeOpaqueNode())};
48+
Raw->Release(); // -1 since it's transfer of ownership.
4849
return make<TokenSyntax>(Raw);
4950
}
5051

@@ -55,7 +56,7 @@ class LibSyntaxGenerator {
5556
auto Children = Node.getDeferredChildren();
5657

5758
auto Recorded = Recorder.recordRawSyntax(Kind, Children);
58-
RC<RawSyntax> Raw {static_cast<RawSyntax *>(Recorded.takeOpaqueNode()) };
59+
RC<RawSyntax> Raw{static_cast<RawSyntax *>(Recorded.takeOpaqueNode())};
5960
Raw->Release(); // -1 since it's transfer of ownership.
6061
return make<SyntaxNode>(Raw);
6162
}

0 commit comments

Comments
 (0)