-
Notifications
You must be signed in to change notification settings - Fork 10.6k
SE-0492: Stabilize @_section/@_used into @section/@used #85074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Removes the underscored prefixes from the @_section and @_used attributes, making them public as @section and @used respectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492. Major parts: - Renamed @_section to @section and @_used to @used - Removed the SymbolLinkageMarkers experimental feature - Added parsing support for the old underscored names with deprecation warnings - Updated all tests and examples to use the new attribute names - Added syntactic validation for @section to align with SE-0492 (reusing the legality checker by @artemcm) - Changed @DebugDescription macro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rules - Added a testcase for the various allowed and disallowed syntactic forms, `test/ConstValues/SectionSyntactic.swift`.
|
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of comments, mostly on the constant-value checking, but this is looking great! Thank you!
lib/Sema/LegalConstExprVerifier.cpp
Outdated
| if (auto *funcDecl = | ||
| dyn_cast<FuncDecl>(memberRef->getMember().getDecl())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it will let through references to instance methods, which can't be expressed as constants. Something like 17.negate, perhaps, would slip through the check?
|
+@kastiglione for the |
…yntactic checking
|
@swift-ci please test |
|
@swift-ci please test |
|
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic, thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DebugDescription macro looks good. Thanks
| /// into some other syntax, specifically as a tuple. | ||
| fileprivate mutating func appendInterpolation(swiftLiteral bytes: [UInt8]) { | ||
| let literalBytes = bytes.map({ "\($0) as UInt8" }).joined(separator: ", ") | ||
| let literalBytes = bytes.map({ "\($0)" }).joined(separator: ", ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it idiomatic to use interpolation for the case where a single variable is being converted to a string ("\($0)")?
Removes the underscored prefixes from the
@_sectionand@_usedattributes, making them public as@sectionand@usedrespectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492.Major parts:
@_sectionto@sectionand@_usedto@used@sectionto align with SE-0492 (reusing the legality checker by @artemcm)@DebugDescriptionmacro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rulestest/ConstValues/SectionSyntactic.swift.Note that there are is no code change for actual constant folding. This is already implemented in MandatoryPerformanceOptimizations based on
.mustBeInitializedStaticallyproperty being true for any@_section/@sectionannotated global.TODO:
@const"test/ConstValues/SectionSyntactic.swift@section-annotated globals in script mode / top-level mode