Skip to content

Commit b2ad45e

Browse files
committed
Revert "Merge pull request #71238 from ahoppen/ahoppen/source-location-parser-changes"
This reverts commit 12fe866, reversing changes made to 956d6d2.
1 parent 23519be commit b2ad45e

File tree

6 files changed

+20
-52
lines changed

6 files changed

+20
-52
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ WARNING(escaped_parameter_name,none,
8888

8989
ERROR(forbidden_interpolated_string,none,
9090
"%0 cannot be an interpolated string literal", (StringRef))
91-
ERROR(forbidden_multiline_string,none,
92-
"%0 cannot be a multi-line string literal", (StringRef))
9391
ERROR(forbidden_extended_escaping_string,none,
9492
"%0 cannot be an extended escaping string literal", (StringRef))
9593

include/swift/Parse/Parser.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,8 @@ class Parser {
718718
///
719719
/// \param Loc where to diagnose.
720720
/// \param DiagText name for the string literal in the diagnostic.
721-
/// \param AllowMultiline Whether the string literal can be a multiline string
722-
/// literal.
723721
llvm::Optional<StringRef>
724-
getStringLiteralIfNotInterpolated(SourceLoc Loc, StringRef DiagText,
725-
bool AllowMultiline);
722+
getStringLiteralIfNotInterpolated(SourceLoc Loc, StringRef DiagText);
726723

727724
/// Returns true to indicate that experimental concurrency syntax should be
728725
/// parsed if the parser is generating only a syntax tree or if the user has

lib/Parse/ParseDecl.cpp

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ ParserResult<AvailableAttr> Parser::parseExtendedAvailabilitySpecList(
568568
}
569569

570570
auto Value = getStringLiteralIfNotInterpolated(
571-
AttrLoc, ("'" + ArgumentKindStr + "'").str(),
572-
/*AllowMultiline=*/true);
571+
AttrLoc, ("'" + ArgumentKindStr + "'").str());
573572
consumeToken();
574573
if (!Value) {
575574
AnyArgumentInvalid = true;
@@ -1461,8 +1460,7 @@ bool Parser::parseExternAttribute(DeclAttributes &Attributes,
14611460
return std::nullopt;
14621461
}
14631462
llvm::Optional<StringRef> importModuleName =
1464-
getStringLiteralIfNotInterpolated(Loc, ("'" + AttrName + "'").str(),
1465-
/*AllowMultiline=*/false);
1463+
getStringLiteralIfNotInterpolated(Loc, ("'" + AttrName + "'").str());
14661464
consumeToken(tok::string_literal);
14671465

14681466
if (!importModuleName.has_value()) {
@@ -3242,8 +3240,8 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
32423240
return makeParserSuccess();
32433241
}
32443242

3245-
AsmName = getStringLiteralIfNotInterpolated(
3246-
Loc, ("'" + AttrName + "'").str(), /*AllowMultiline=*/false);
3243+
AsmName =
3244+
getStringLiteralIfNotInterpolated(Loc, ("'" + AttrName + "'").str());
32473245

32483246
consumeToken(tok::string_literal);
32493247

@@ -3314,7 +3312,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
33143312
}
33153313

33163314
auto Name = getStringLiteralIfNotInterpolated(
3317-
Loc, ("'" + AttrName + "'").str(), /*AllowMultiline=*/false);
3315+
Loc, ("'" + AttrName + "'").str());
33183316

33193317
consumeToken(tok::string_literal);
33203318

@@ -3401,7 +3399,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
34013399
}
34023400

34033401
auto Value = getStringLiteralIfNotInterpolated(
3404-
Loc, ("'" + AttrName + "'").str(), /*AllowMultiline=*/false);
3402+
Loc, ("'" + AttrName + "'").str());
34053403

34063404
consumeToken(tok::string_literal);
34073405

@@ -3464,8 +3462,8 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
34643462
// Parse the next string literal as the original module name.
34653463
auto ModuleNameLoc = Tok.getLoc();
34663464
if (Tok.is(tok::string_literal)) {
3467-
auto NameOp = getStringLiteralIfNotInterpolated(
3468-
Tok.getLoc(), "original module name", /*AllowMultiline=*/false);
3465+
auto NameOp = getStringLiteralIfNotInterpolated(Tok.getLoc(),
3466+
"original module name");
34693467
if (NameOp.has_value())
34703468
OriginalModuleName = *NameOp;
34713469
consumeToken();
@@ -3554,8 +3552,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
35543552
diagnose(ColonLoc, diag::attr_private_import_expected_sourcefile_name);
35553553
return makeParserSuccess();
35563554
}
3557-
filename = getStringLiteralIfNotInterpolated(Loc, "_private",
3558-
/*AllowMultiline=*/false);
3555+
filename = getStringLiteralIfNotInterpolated(Loc, "_private");
35593556
if (!filename.has_value()) {
35603557
diagnose(ColonLoc, diag::attr_private_import_expected_sourcefile_name);
35613558
return makeParserSuccess();
@@ -3828,8 +3825,8 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
38283825
return makeParserSuccess();
38293826
}
38303827

3831-
llvm::Optional<StringRef> value = getStringLiteralIfNotInterpolated(
3832-
Tok.getLoc(), flag, /*AllowMultiline=*/false);
3828+
llvm::Optional<StringRef> value =
3829+
getStringLiteralIfNotInterpolated(Tok.getLoc(), flag);
38333830
if (!value)
38343831
return makeParserSuccess();
38353832
Token stringTok = Tok;
@@ -4555,8 +4552,7 @@ bool Parser::parseConventionAttributeInternal(SourceLoc atLoc, SourceLoc attrLoc
45554552
diagnose(Tok, diag::convention_attribute_ctype_expected_string);
45564553
return true;
45574554
}
4558-
if (auto ty = getStringLiteralIfNotInterpolated(Tok.getLoc(), "(C type)",
4559-
/*AllowMultiline=*/false)) {
4555+
if (auto ty = getStringLiteralIfNotInterpolated(Tok.getLoc(), "(C type)")) {
45604556
cType = Located<StringRef>(ty.value(), Tok.getLoc());
45614557
}
45624558
consumeToken(tok::string_literal);
@@ -7197,8 +7193,8 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
71977193
return makeParserError();
71987194
}
71997195

7200-
Filename = getStringLiteralIfNotInterpolated(Loc, "'#sourceLocation'",
7201-
/*AllowMultiline=*/false);
7196+
Filename =
7197+
getStringLiteralIfNotInterpolated(Loc, "'#sourceLocation'");
72027198
if (!Filename.has_value())
72037199
return makeParserError();
72047200
SourceLoc filenameLoc = consumeToken(tok::string_literal);
@@ -7216,11 +7212,6 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
72167212
}
72177213
SmallString<16> buffer;
72187214
auto text = stripUnderscoresIfNeeded(Tok.getText(), buffer);
7219-
if (text.find_first_not_of("0123456789") != StringRef::npos) {
7220-
// Disallow non-decimal line numbers in Swift 6.
7221-
diagnose(Tok, diag::expected_line_directive_number)
7222-
.warnUntilSwiftVersion(6);
7223-
}
72247215
if (text.getAsInteger(0, StartLine)) {
72257216
diagnose(Tok, diag::expected_line_directive_number);
72267217
return makeParserError();
@@ -7268,9 +7259,8 @@ ParserStatus Parser::parseLineDirective(bool isLine) {
72687259
diagnose(Tok, diag::expected_line_directive_name);
72697260
return makeParserError();
72707261
}
7271-
7272-
Filename = getStringLiteralIfNotInterpolated(Loc, "'#line'",
7273-
/*AllowMultiline=*/false);
7262+
7263+
Filename = getStringLiteralIfNotInterpolated(Loc, "'#line'");
72747264
if (!Filename.has_value())
72757265
return makeParserError();
72767266
}

lib/Parse/ParseStmt.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,9 +2773,8 @@ ParserResult<Stmt> Parser::parseStmtPoundAssert() {
27732773
return makeParserError();
27742774
}
27752775

2776-
auto messageOpt =
2777-
getStringLiteralIfNotInterpolated(Tok.getLoc(), "'#assert' message",
2778-
/*AllowMultiline=*/true);
2776+
auto messageOpt = getStringLiteralIfNotInterpolated(Tok.getLoc(),
2777+
"'#assert' message");
27792778
consumeToken();
27802779
if (!messageOpt)
27812780
return makeParserError();

lib/Parse/Parser.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,19 +1097,14 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
10971097
}
10981098

10991099
llvm::Optional<StringRef>
1100-
Parser::getStringLiteralIfNotInterpolated(SourceLoc Loc, StringRef DiagText,
1101-
bool AllowMultiline) {
1100+
Parser::getStringLiteralIfNotInterpolated(SourceLoc Loc, StringRef DiagText) {
11021101
assert(Tok.is(tok::string_literal));
11031102

11041103
// FIXME: Support extended escaping string literal.
11051104
if (Tok.getCustomDelimiterLen()) {
11061105
diagnose(Loc, diag::forbidden_extended_escaping_string, DiagText);
11071106
return llvm::None;
11081107
}
1109-
if (!AllowMultiline && Tok.isMultilineString()) {
1110-
diagnose(Loc, diag::forbidden_multiline_string, DiagText)
1111-
.warnUntilSwiftVersion(6);
1112-
}
11131108

11141109
SmallVector<Lexer::StringSegment, 1> Segments;
11151110
L->getStringLiteralSegments(Tok, Segments);

test/Parse/line-directive.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,6 @@ x // expected-error {{parameterless closing #sourceLocation() directive without
1414

1515
#sourceLocation(file: x.swift, line: 1) // expected-error{{expected filename string literal}}
1616

17-
// expected-warning@+1 {{expected starting line number for #sourceLocation directive; this is an error in Swift 6}}
18-
#sourceLocation(file: "x.swift", line: 0xff)
19-
20-
#sourceLocation()
21-
22-
// expected-warning@+1 {{'#sourceLocation' cannot be a multi-line string literal; this is an error in Swift 6}}
23-
#sourceLocation(file: """
24-
x.swift
25-
y.swift
26-
""", line: 42)
27-
2817
#sourceLocation(file: "x.swift", line: 42)
2918
x x ; // should be ignored by expected_error because it is in a different file
3019
x

0 commit comments

Comments
 (0)