Skip to content

Commit 3f02037

Browse files
authored
Merge pull request #61378 from beccadax/an-argument-about-attribution
[NFC] Add parsing helpers for @attr(<identifier>)
2 parents b50e795 + 0cd4a39 commit 3f02037

File tree

5 files changed

+151
-214
lines changed

5 files changed

+151
-214
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,9 @@ ERROR(attr_expected_integer_literal,none,
14691469
ERROR(attr_expected_option_such_as,none,
14701470
"expected '%0' option such as '%1'", (StringRef, StringRef))
14711471

1472+
ERROR(attr_expected_option_identifier,none,
1473+
"expected '%0' option to be an identifier", (StringRef))
1474+
14721475
ERROR(attr_unknown_option,none,
14731476
"unknown option '%0' for attribute '%1'", (StringRef, StringRef))
14741477

@@ -1482,18 +1485,9 @@ ERROR(attr_expected_colon_after_label,none,
14821485
ERROR(alignment_must_be_positive_integer,none,
14831486
"alignment value must be a positive integer literal", ())
14841487

1485-
ERROR(swift_native_objc_runtime_base_must_be_identifier,none,
1486-
"@_swift_native_objc_runtime_base class name must be an identifier", ())
1487-
1488-
ERROR(objc_runtime_name_must_be_identifier,none,
1489-
"@_objcRuntimeName name must be an identifier", ())
1490-
14911488
ERROR(attr_only_at_non_local_scope, none,
14921489
"attribute '%0' can only be used in a non-local scope", (StringRef))
14931490

1494-
ERROR(projection_value_property_not_identifier,none,
1495-
"@_projectedValueProperty name must be an identifier", ())
1496-
14971491
// Access control
14981492
ERROR(attr_access_expected_set,none,
14991493
"expected 'set' as subject of '%0' modifier", (StringRef))

include/swift/AST/KnownIdentifiers.def

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,18 @@ IDENTIFIER(storageKeyPath)
316316
IDENTIFIER(memberwise)
317317
IDENTIFIER_WITH_NAME(localStorageVar, "_storage")
318318

319+
// Attribute options
320+
IDENTIFIER_(_always)
321+
IDENTIFIER_(assumed)
322+
IDENTIFIER(checked)
323+
IDENTIFIER(never)
324+
IDENTIFIER(none)
325+
IDENTIFIER(safe)
326+
IDENTIFIER(size)
327+
IDENTIFIER(speed)
328+
IDENTIFIER(unchecked)
329+
IDENTIFIER(unsafe)
330+
319331
// The singleton instance of TupleTypeDecl in the Builtin module
320332
IDENTIFIER(TheTupleType)
321333

include/swift/Parse/Parser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ class Parser {
896896

897897
/// Parse the specified expected token and return its location on success. On failure, emit the specified
898898
/// error diagnostic, a note at the specified note location, and return the location of the previous token.
899-
bool parseMatchingToken(tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
899+
bool parseMatchingToken(tok K, SourceLoc &TokLoc, Diagnostic ErrorDiag,
900900
SourceLoc OtherLoc);
901901

902902
/// Returns the proper location for a missing right brace, parenthesis, etc.

0 commit comments

Comments
 (0)