Skip to content

Commit 4527711

Browse files
committed
[SyntaxParses] Address memory issue in popTokenSyntax()
Don't return reference for local temporary object rdar://problem/55421369
1 parent 9f642f0 commit 4527711

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

include/swift/Parse/SyntaxParsingContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ class alignas(1 << SyntaxAlignInBits) SyntaxParsingContext {
300300
return SyntaxNode(std::move(rawNode));
301301
}
302302

303-
ParsedTokenSyntax &&popToken();
303+
ParsedTokenSyntax popToken();
304304

305305
/// Create a node using the tail of the collected parts. The number of parts
306306
/// is automatically determined from \c Kind. Node: limited number of \c Kind

lib/Parse/SyntaxParsingContext.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ const SyntaxParsingContext *SyntaxParsingContext::getRoot() const {
163163
return Curr;
164164
}
165165

166-
ParsedTokenSyntax &&SyntaxParsingContext::popToken() {
167-
return std::move(popIf<ParsedTokenSyntax>().getValue());
166+
ParsedTokenSyntax SyntaxParsingContext::popToken() {
167+
auto tok = popIf<ParsedTokenSyntax>();
168+
return std::move(tok.getValue());
168169
}
169170

170171
/// Add Token with Trivia to the parts.

0 commit comments

Comments
 (0)