Skip to content

Commit a5314af

Browse files
authored
Merge pull request #16117 from ahoppen/attributes
[libSyntax] Make parsing of attributes more structured
2 parents 15afed5 + 3e9ae80 commit a5314af

File tree

15 files changed

+759
-349
lines changed

15 files changed

+759
-349
lines changed

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function(handle_gyb_sources dependency_out_var_name sources_var_name arch)
116116
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/kinds.py"
117117
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/Node.py"
118118
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AttributeNodes.py"
119+
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/AvailabilityNodes.py"
119120
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/CommonNodes.py"
120121
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/DeclNodes.py"
121122
"${SWIFT_SOURCE_DIR}/utils/gyb_syntax_support/ExprNodes.py"

include/swift/Parse/Parser.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,16 +768,34 @@ class Parser {
768768
bool parseDeclAttributeList(DeclAttributes &Attributes,
769769
bool &FoundCodeCompletionToken);
770770

771-
/// Parse the optional modifiers before a declaration.
771+
/// Parse the optional modifiers before a declaration.
772772
bool parseDeclModifierList(DeclAttributes &Attributes, SourceLoc &StaticLoc,
773773
StaticSpellingKind &StaticSpelling);
774774

775+
/// Parse an availability attribute of the form
776+
/// @available(*, introduced: 1.0, deprecated: 3.1).
777+
/// \return \p nullptr if the platform name is invalid
778+
ParserResult<AvailableAttr>
779+
parseExtendedAvailabilitySpecList(SourceLoc AtLoc, SourceLoc AttrLoc,
780+
StringRef AttrName);
781+
782+
/// Parse the Objective-C selector inside @objc
783+
void parseObjCSelector(SmallVector<Identifier, 4> &Names,
784+
SmallVector<SourceLoc, 4> &NameLocs,
785+
bool &IsNullarySelector);
786+
775787
/// Parse the @_specialize attribute.
776788
/// \p closingBrace is the expected closing brace, which can be either ) or ]
777789
/// \p Attr is where to store the parsed attribute
778790
bool parseSpecializeAttribute(swift::tok ClosingBrace, SourceLoc AtLoc,
779791
SourceLoc Loc, SpecializeAttr *&Attr);
780792

793+
/// Parse the arguments inside the @_specialize attribute
794+
bool parseSpecializeAttributeArguments(
795+
swift::tok ClosingBrace, bool &DiscardAttribute, Optional<bool> &Exported,
796+
Optional<SpecializeAttr::SpecializationKind> &Kind,
797+
TrailingWhereClause *&TrailingWhereClause);
798+
781799
/// Parse the @_implements attribute.
782800
/// \p Attr is where to store the parsed attribute
783801
ParserResult<ImplementsAttr> parseImplementsAttribute(SourceLoc AtLoc,

0 commit comments

Comments
 (0)