-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Swiftify] Emit @availability when expansions contain Span #81320
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
This prevents errors when compiling for older targets using a newer compiler. rdar://150740330
@swift-ci please smoke test |
|
||
// Check that ClangImporter correctly infers and expands @_SwiftifyImport macros for functions with __counted_by __noescape parameters. | ||
|
||
import CountedByNoEscapeClang | ||
|
||
// CHECK: @lifetime(p: copy p) | ||
// CHECK: @available(macOS 10.14.4, *) |
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.
@DougGregor We only need availability for the target OS right?
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.
nvm I figured out a convenient way to get all platform availabilities regardless of target. This makes testing much easier
@swift-ci please smoke test |
@swift-ci please smoke test |
// CHECK: @_alwaysEmitIntoClient public func complexExpr(_ len: Int{{.*}}, _ offset: Int{{.*}}, _ p: RawSpan) | ||
// CHECK: @available(visionOS 1.1, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *) | ||
// CHECK-NEXT: @_alwaysEmitIntoClient public func complexExpr(_ len: Int{{.*}}, _ offset: Int{{.*}}, _ p: RawSpan) | ||
// CHECK-NEXT: @available(visionOS 1.1, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *) |
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.
Can we generalize the check lines so this test can work on platforms that don't have availability defined (e.g., Linux)?
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.
If we include inactive availability attributes we should always have the same output regardless of platform
ValueDecl *D = getDecl(Name); | ||
out << "\"" << Name << "\":" << "\""; | ||
llvm::SaveAndRestore<bool> hasAvailbilitySeparatorRestore(firstParam, true); | ||
for (auto attr : D->getSemanticAvailableAttrs(/*includingInactive=*/true)) { |
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.
We don't need the inactive availability attributes, do we?
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.
Oh right, I forgot to test whether that made a difference
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.
I tried this out now, and while we don't necessarily need to include inactive attributes, I think it kind of makes sense to include them. If we don't, we'll get @available(macOS 10.14.4, *)
when compiling for macOS, other stuff for other Darwin platforms, and nothing for Linux and Windows. If we include inactive attributes we'll always get @available(visionOS 1.1, tvOS 12.2, watchOS 5.2, iOS 12.2, macOS 10.14.4, *)
. This makes the output more consistent, making it significantly easier to test, and less confusing for someone reading the macro expansion.
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.
Alright, that makes sense.
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test windows |
[Swiftify] Emit @Availability when expansions contain Span (#81320)
This prevents errors when compiling for older targets using a newer compiler. rdar://150740330
This prevents errors when compiling for older targets using a newer compiler.
rdar://150740330