@@ -1730,7 +1730,6 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
1730
1730
unsigned &InterpolationCount) {
1731
1731
SourceLoc Loc = EntireTok.getLoc ();
1732
1732
ParserStatus Status;
1733
- ParsedTrivia EmptyTrivia;
1734
1733
bool First = true ;
1735
1734
1736
1735
DeclNameRef appendLiteral (
@@ -1785,7 +1784,7 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
1785
1784
// such token to the context.
1786
1785
Token content (tok::string_segment,
1787
1786
CharSourceRange (Segment.Loc , Segment.Length ).str ());
1788
- SyntaxContext->addToken (content, EmptyTrivia, EmptyTrivia );
1787
+ SyntaxContext->addToken (content, StringRef (), StringRef () );
1789
1788
break ;
1790
1789
}
1791
1790
@@ -1799,14 +1798,14 @@ parseStringSegments(SmallVectorImpl<Lexer::StringSegment> &Segments,
1799
1798
// Backslash is part of an expression segment.
1800
1799
SourceLoc BackSlashLoc = Segment.Loc .getAdvancedLoc (-1 - DelimiterLen);
1801
1800
Token BackSlash (tok::backslash, CharSourceRange (BackSlashLoc, 1 ).str ());
1802
- ExprContext.addToken (BackSlash, EmptyTrivia, EmptyTrivia );
1801
+ ExprContext.addToken (BackSlash, StringRef (), StringRef () );
1803
1802
1804
1803
// Custom delimiter may be a part of an expression segment.
1805
1804
if (HasCustomDelimiter) {
1806
1805
SourceLoc DelimiterLoc = Segment.Loc .getAdvancedLoc (-DelimiterLen);
1807
1806
Token Delimiter (tok::raw_string_delimiter,
1808
1807
CharSourceRange (DelimiterLoc, DelimiterLen).str ());
1809
- ExprContext.addToken (Delimiter, EmptyTrivia, EmptyTrivia );
1808
+ ExprContext.addToken (Delimiter, StringRef (), StringRef () );
1810
1809
}
1811
1810
1812
1811
// Create a temporary lexer that lexes from the body of the string.
@@ -1909,20 +1908,17 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
1909
1908
// Make unknown tokens to represent the open and close quote.
1910
1909
Token OpenQuote (QuoteKind, OpenQuoteStr);
1911
1910
Token CloseQuote (QuoteKind, CloseQuoteStr);
1912
- ParsedTrivia EmptyTrivia;
1913
1911
StringRef EntireTrailingTrivia = TrailingTrivia;
1914
1912
1915
1913
if (HasCustomDelimiter) {
1916
- auto LeadingTriviaPieces = TriviaLexer::lexTrivia (LeadingTrivia);
1917
1914
Token OpenDelimiter (tok::raw_string_delimiter, OpenDelimiterStr);
1918
1915
// When a custom delimiter is present, it owns the leading trivia.
1919
- SyntaxContext->addToken (OpenDelimiter, LeadingTriviaPieces, EmptyTrivia );
1916
+ SyntaxContext->addToken (OpenDelimiter, LeadingTrivia, StringRef () );
1920
1917
1921
- SyntaxContext->addToken (OpenQuote, EmptyTrivia, EmptyTrivia );
1918
+ SyntaxContext->addToken (OpenQuote, StringRef (), StringRef () );
1922
1919
} else {
1923
- auto LeadingTriviaPieces = TriviaLexer::lexTrivia (LeadingTrivia);
1924
1920
// Without custom delimiter the quote owns trailing trivia.
1925
- SyntaxContext->addToken (OpenQuote, LeadingTriviaPieces, EmptyTrivia );
1921
+ SyntaxContext->addToken (OpenQuote, LeadingTrivia, StringRef () );
1926
1922
}
1927
1923
1928
1924
// The simple case: just a single literal segment.
@@ -1943,24 +1939,19 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
1943
1939
auto Segment = Segments.front ();
1944
1940
Token content (tok::string_segment,
1945
1941
CharSourceRange (Segment.Loc , Segment.Length ).str ());
1946
- SyntaxContext->addToken (content, EmptyTrivia, EmptyTrivia );
1942
+ SyntaxContext->addToken (content, StringRef (), StringRef () );
1947
1943
}
1948
1944
1949
1945
if (HasCustomDelimiter) {
1950
- SyntaxContext->addToken (CloseQuote, EmptyTrivia, EmptyTrivia );
1946
+ SyntaxContext->addToken (CloseQuote, StringRef (), StringRef () );
1951
1947
1952
1948
Token CloseDelimiter (tok::raw_string_delimiter, CloseDelimiterStr);
1953
1949
// When a custom delimiter is present it owns the trailing trivia.
1954
- auto EntireTrailingTriviaPieces =
1955
- TriviaLexer::lexTrivia (EntireTrailingTrivia);
1956
- SyntaxContext->addToken (CloseDelimiter, EmptyTrivia,
1957
- EntireTrailingTriviaPieces);
1950
+ SyntaxContext->addToken (CloseDelimiter, StringRef (),
1951
+ EntireTrailingTrivia);
1958
1952
} else {
1959
1953
// Without custom delimiter the quote owns trailing trivia.
1960
- auto EntireTrailingTriviaPieces =
1961
- TriviaLexer::lexTrivia (EntireTrailingTrivia);
1962
- SyntaxContext->addToken (CloseQuote, EmptyTrivia,
1963
- EntireTrailingTriviaPieces);
1954
+ SyntaxContext->addToken (CloseQuote, StringRef (), EntireTrailingTrivia);
1964
1955
}
1965
1956
1966
1957
return makeParserResult (
@@ -2019,20 +2010,16 @@ ParserResult<Expr> Parser::parseExprStringLiteral() {
2019
2010
}
2020
2011
2021
2012
if (HasCustomDelimiter) {
2022
- SyntaxContext->addToken (CloseQuote, EmptyTrivia, EmptyTrivia );
2013
+ SyntaxContext->addToken (CloseQuote, StringRef (), StringRef () );
2023
2014
2024
2015
Token CloseDelimiter (tok::raw_string_delimiter, CloseDelimiterStr);
2025
2016
// When a custom delimiter is present it owns the trailing trivia.
2026
- auto EntireTrailingTriviaPieces =
2027
- TriviaLexer::lexTrivia (EntireTrailingTrivia);
2028
- SyntaxContext->addToken (CloseDelimiter, EmptyTrivia,
2029
- EntireTrailingTriviaPieces);
2017
+ SyntaxContext->addToken (CloseDelimiter, StringRef (), EntireTrailingTrivia);
2030
2018
} else {
2031
2019
// Without custom delimiter the quote owns trailing trivia.
2032
2020
auto EntireTrailingTriviaPieces =
2033
2021
TriviaLexer::lexTrivia (EntireTrailingTrivia);
2034
- SyntaxContext->addToken (CloseQuote, EmptyTrivia,
2035
- EntireTrailingTriviaPieces);
2022
+ SyntaxContext->addToken (CloseQuote, StringRef (), EntireTrailingTrivia);
2036
2023
}
2037
2024
2038
2025
if (AppendingExpr->getBody ()->getNumElements () == 1 ) {
0 commit comments