Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ WARNING(escaped_parameter_name,none,

ERROR(forbidden_interpolated_string,none,
"%0 cannot be an interpolated string literal", (StringRef))
ERROR(forbidden_extended_escaping_string,none,
"%0 cannot be an extended escaping string literal", (StringRef))

ERROR(expected_identifier_in_module_selector,none,
"expected module name in module selector", ())
Expand Down
15 changes: 7 additions & 8 deletions lib/Parse/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,12 +1170,6 @@ std::optional<StringRef>
Parser::getStringLiteralIfNotInterpolated(SourceLoc Loc, StringRef DiagText) {
assert(Tok.is(tok::string_literal));

// FIXME: Support extended escaping string literal.
if (Tok.getCustomDelimiterLen()) {
diagnose(Loc, diag::forbidden_extended_escaping_string, DiagText);
return std::nullopt;
}

SmallVector<Lexer::StringSegment, 1> Segments;
L->getStringLiteralSegments(Tok, Segments);
if (Segments.size() != 1 ||
Expand All @@ -1184,8 +1178,13 @@ Parser::getStringLiteralIfNotInterpolated(SourceLoc Loc, StringRef DiagText) {
return std::nullopt;
}

return SourceMgr.extractText(CharSourceRange(Segments.front().Loc,
Segments.front().Length));
llvm::SmallString<256> Buf;
StringRef EncodedStr = L->getEncodedStringSegment(Segments.front(), Buf);
if (!Buf.empty()) {
EncodedStr = Context.AllocateCopy(EncodedStr);
}

return EncodedStr;
}

struct ParserUnit::Implementation {
Expand Down
4 changes: 2 additions & 2 deletions test/Parse/diagnose_availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ emptyMessage()
// expected-error@-1{{'emptyMessage()' is unavailable: }}
// expected-note@-3{{'emptyMessage()' has been explicitly marked unavailable here}}

// expected-error@+1{{'message' cannot be an extended escaping string literal}}
// OK.
@available(*, unavailable, message: #"""
foobar message.
"""#)
func extendedEscapedMultilineMessage() {}

// expected-error@+1{{'renamed' cannot be an extended escaping string literal}}
// OK.
@available(*, unavailable, renamed: #"available()"#)
func extendedEscapedRenamed() {}
13 changes: 13 additions & 0 deletions test/Parse/line-directive-executable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,16 @@ check() // CHECK-NEXT: .swift:[[@LINE]]


check() // CHECK-NEXT: {{^}}k.swift:1002

#sourceLocation(file: #"C:\l.swift"#, line: 1100)
check() // CHECK-NEXT: {{^}}C:\l.swift:1100

#sourceLocation(file: """
m.swift
n.swift
""",
line: 1200
)
check()
// CHECK-NEXT: {{^}}m.swift
// CHECK-NEXT: {{^}}n.swift:1200