Skip to content

Don't emit @_section attributes unless the macro target has SymbolLinkageMarkers. #1018

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

Merged
Merged
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
26 changes: 17 additions & 9 deletions Sources/TestingMacros/Support/TestContentGeneration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,19 @@ func makeTestContentRecordDecl(named name: TokenSyntax, in typeName: TypeSyntax?
IntegerLiteralExprSyntax(context, radix: .binary)
}

return """
var result: DeclSyntax = """
@available(*, deprecated, message: "This property is an implementation detail of the testing library. Do not use it directly.")
private nonisolated \(staticKeyword(for: typeName)) let \(name): Testing.__TestContentRecord = (
\(kindExpr), \(kind.commentRepresentation)
0,
\(accessorName),
\(contextExpr),
0
)
"""

#if hasFeature(SymbolLinkageMarkers)
result = """
#if hasFeature(SymbolLinkageMarkers)
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
@_section("__DATA_CONST,__swift5_tests")
Expand All @@ -74,13 +86,9 @@ func makeTestContentRecordDecl(named name: TokenSyntax, in typeName: TypeSyntax?
#endif
@_used
#endif
@available(*, deprecated, message: "This property is an implementation detail of the testing library. Do not use it directly.")
private nonisolated \(staticKeyword(for: typeName)) let \(name): Testing.__TestContentRecord = (
\(kindExpr), \(kind.commentRepresentation)
0,
\(accessorName),
\(contextExpr),
0
)
\(result)
"""
#endif

return result
}