Commit Graph

13 Commits

Author SHA1 Message Date
Pavel Yaskevich
36c61bdd3e [Tests] NFC: Remove ResultBuilderASTTransform references from tests 2023-03-15 14:29:04 -07:00
Allan Shortlidge
d480410931 Sema: Diagnose unsupported clang decls for #_hasSymbol.
Progress towards rdar://103408651.
2022-12-22 10:55:29 -05:00
Allan Shortlidge
466335b5d3 Tests: #_hasSymbol support for members of opaque/existential types.
Resolves rdar://101063734
2022-12-01 13:39:22 -08:00
Allan Shortlidge
164ac421d6 Sema: Lift restriction preventing use of #_hasSymbol on non-Darwin platforms.
An early approach to codegen for `#_hasSymbol` relied on the Darwin platfom SDK, but now that the feature lowers directly to NULL checks in LLVM IR a platform restriction is no longer needed.

However, the tests for `#_hasSymbol` remain unsupported on Windows since that OS does not support weak linking.
2022-11-30 14:58:28 -08:00
Allan Shortlidge
3da18b6e68 SIL: Serialize and deserialize has_symbol instructions. 2022-11-16 16:07:59 -08:00
Allan Shortlidge
01a32639f0 Sema: Ensure that use of availability macros in closures in fragile functions is diagnosed.
Type checking of closure bodies does not invoke `TypeChecker::typeCheckStmtConditionElement()` so use of availability macros inside closure bodies written in fragile (inlinable) functions was undiagnosed. Move the diagnostic logic to `MiscDiagnostics.cpp` which implements diagnostics that are emitted regardless of the typechecking model used.

Additionally, remove the `DC->getAsDecl() != nullptr` check from `diagnoseHasSymbolCondition()` which was preventing similar fragile function diagnostics for `if #_hasSymbol` from being emitted when a closure was involved.

Resolves rdar://100581013
2022-10-14 15:33:27 -07:00
Allan Shortlidge
8a9eb40965 Sema: Reject #_hasSymbol conditions in inlinable code. 2022-10-13 21:00:24 -07:00
Allan Shortlidge
64e8a0334d Sema: Diagnose if #_hasSymbol as unsupported on non-Darwin targets. 2022-10-08 00:09:34 -07:00
Allan Shortlidge
631dd4c90c Sema: Update if #_hasSymbol diagnostic to use consistent style. 2022-10-07 22:15:52 -07:00
Allan Shortlidge
8729801eb4 Sema: Store an 'invalid' bit in PoundHasSymbolInfo to avoid repeated if #_hasSymbol diagnostics. 2022-09-29 11:47:30 -07:00
Allan Shortlidge
034e53ad20 Sema: Accept if #_hasSymbol() conditions in closure contexts.
Resolves rdar://100129165
2022-09-29 10:55:08 -07:00
Allan Shortlidge
9c628904d9 Sema: Temporarily reject if #_hasSymbol in a closure context.
We'll need to implement appropriate constraint generation to support them in such a context.
2022-09-19 11:27:08 -07:00
Allan Shortlidge
ba46170b54 Implement type checking for the #_hasSymbol directive. The directive takes an expression which must resolve at compile time to a single concrete declaration. There are a few kinds of expressions which we intend to accept:
- Unapplied functions: `if #_hasSymbol(foo(_:))`
- Member references: `if #_hasSymbol(a.x)`
- `.self` expressions on static metatypes: `if #_hasSymbol(SomeEnum.self)`
- Dot syntax call expressions with unapplied functions: `if #_hasSymbol(SomeType.init(_:)`

Additionally, we diagnose when the concretely referenced declaration is not weak linked since this likely indicates that the programmer misidentified the declaration they wish to check or the build is not configured in a way such that the check will be meaningful.

Resolves rdar://99826340
2022-09-19 10:40:37 -07:00