Commit Graph

164 Commits

Author SHA1 Message Date
Henrik G. Olsson
56ef1a9348 [DiagnosticVerifier] support quoting paths with ''
Windows paths can contain colons (etc. C:\foo\bar), which the diagnostic
verifier would confuse for the end of the path. By quoting them we can
ignore all colons until the matching single quote character.
2026-01-30 21:39:26 -08:00
Henrik G. Olsson
2718628ead remove unneeded experimental feature from test 2026-01-29 10:34:15 -08:00
Henrik G. Olsson
c0b30892a6 [Swiftify] don't attach macro if plugin unavailable
At the moment plugin paths do not get passed along when consuming a
textual interface of an imported module. Normally this is not an issue,
because all macros have already been expanded at this point, but this is
not the case for _SwiftifyImport which belongs to a clang module but is
expanded while gompiling a dependent Swift module. This would cause an
error when trying to expand the macro. Since most textual interfaces
don't call any safe wrappers at the moment, this unblocks the
compilation by checking whether the macro plugin can be loaded before
attaching the macro, and emitting a warning if not. Long term we'll want
to pass along the plugin path to swift-api-digester, but this will do
for now.

rdar://168967555
2026-01-29 10:34:11 -08:00
Henrik G. Olsson
5eb27e81cf macos -> macosx 2026-01-28 09:04:36 -08:00
Henrik G. Olsson
68196b5c66 fix availability test for watchOS and visionOS
rdar://168985007
2026-01-27 14:12:39 -08:00
Rintaro Ishizaki
dd04117df6 [Test] Disable a failing test case
rdar://168985007
2026-01-27 10:00:35 -08:00
Rintaro Ishizaki
f4ae57cab7 [Test] Disable a failing test case
rdar://168985007
2026-01-27 09:58:07 -08:00
Henrik G. Olsson
a65e5613d3 Merge pull request #86613 from hnrklssn/swiftify-clang-availability
[ClangImporter] Don't import empty availability attributes
2026-01-26 20:06:45 -08:00
Henrik G. Olsson
decfed10bc silence backtrace warning 2026-01-23 20:43:45 -08:00
Henrik G. Olsson
8d49c3c2c6 [ClangImporter] Don't import empty availability attributes
When compilng for tvOS, `availability(ios,introduced=2.0)` seems to
imply `availability(tvos)`. This gets imported as `@available(tvOS)`,
which is invalid Swift syntax. Normally this attribute has no effect,
but when attaching a macro to such a function the macro gets invalid
Swift syntax as input.

rdar://168272342
2026-01-23 20:04:06 -08:00
Henrik G. Olsson
398f09bb2e [Swiftify] get module from canonical decl
This aligns the logic in SwiftifyDecl.cpp for fetching the owning module
with that of the rest of the compiler. Previously we would fetch the
owning module from the clang decl directly associated with the Swift
decl, whereas the rest of the compiler looks at the canoncial (first)
decl to determine ownership. This mismatch resulted in a state where
swiftifyImpl did not think the decl originated in a bridging header
(because it was not imported into the __ObjC module), but it also didn't
find an owning module on the clang decl. This occured when a bridging
header would import a header from a module, and then redeclare a
function from that module.

rdar://168703691
2026-01-23 18:45:18 -08:00
Henrik G. Olsson
8c428f4463 replace å in test case with zz (NFC) 2026-01-16 12:38:12 -08:00
Henrik G. Olsson
607c7af3d3 [Swiftify] fix ForwardDeclaredConcreteTypeVisitor
This fixes two bugs:
 1) The outermost pointee type is not necessarily a nominal type. There
can e.g. be a pointer to an array (tuple) type. This would result in a
null pointer dereference. Instead of assuming direct pointee nominal
types, we now check for nominal types anywhere in the type hierarchy.

2) Enum types can also be forward declared. Instead of checking for
clang::RecordDecl, we now check for clang::TagDecl (which is a base
class of clang::RecordDecl and clang::EnumDecl).

rdar://165864358
2026-01-15 16:01:46 -08:00
Henrik G. Olsson
4388d43257 [Swiftify] fix tests after relanding bridging header import fix
Somehow these tests passed CI despite being incorrect from the start.
The original intention with the bridging header import fix was to only
stop re-importing the AST nodes from the bridging header, but still have
the macro expansions implicitly import the bridging header module. I
accidentally returned true instead of false in importBridgingHeader,
which resulted in the macro expansions not importing the bridging header
module. This turned out to be fine however, because the macro expansion
won't refer to anything in the bridging header. So instead update the
tests to reflect this. This also adds a test to verify that the macro
expansion can still access symbols from a C++ namespace despite not
importing the __ObjC module.
2026-01-09 18:39:15 -08:00
Henrik G. Olsson
8ba1d0c580 Revert "Merge pull request #86403 from swiftlang/revert-86367-bridging-header-multiple-includes"
This reverts commit 2de8565685, reversing
changes made to 6a0fa11355.
2026-01-09 17:57:28 -08:00
eeckstein
e0dee4f43f Revert "[Swiftify] don't re-import bridging header" 2026-01-09 07:19:56 +01:00
Henrik G. Olsson
e62f6fe78b Merge pull request #86084 from swiftlang/opaque-non-opaque
[Swiftify] don't add macro when required type is unavailable
2026-01-08 16:32:25 -08:00
Henrik G. Olsson
41c587caf0 [Swiftify] don't re-import bridging header
While the clang macro expansion SourceFile ought to resolve the bridging
header as an implicit import, the contents of the bridging header have
already been imported at this point, so there's no need to do it again.
Other than being bad for performance, this would also result in
compilation errors in non-ObjC mode when the header contained
definitions (not just declarations), since the same ClangImporter would
import the header twice, resulting in redefinitions (unless the header
contained header guards). In ObjC mode this would not manifest, because
the bridging header is imported using `#import` in that mode, so header
guards are not needed.

rdar://165851601
2026-01-07 15:55:04 -08:00
Henrik G. Olsson
1116884d00 consistent use of %{fs-sep} 2025-12-19 15:14:53 -08:00
Henrik G. Olsson
75a110cdc6 [Swiftify] don't attach macro when module does not import stdlib
This prevents stuff like memcmp from SwiftShims from being imported with
@_SwiftifyImport, which would then result in name lookup errors as it
does not import the Swift standard library module. This makes the
previous approach to disable safe interop when compiling with
-parse-stdlib redundant.

irdar://165856959
2025-12-18 21:14:58 -08:00
Henrik G. Olsson
ca3b77f6fc allow functions in modules to depend on decls with no owning module
Since decls with no module are imported to __ObjC this is not an issue,
because __ObjC is always implicitly imported. Added test case that would
previously assert.
2025-12-18 17:24:08 -08:00
Henrik G. Olsson
db7c13c3dd traverse imported Swift type rather than clang type
This fixes an assert when signatures contain
`struct forward_declared_t **`, and makes sure that
`struct foo { struct forward_declared_t *bar; }` does *not* block
swiftification, since `@_SwiftifyImport` does not need to access the
struct field.
2025-12-17 22:09:59 -08:00
Henrik G. Olsson
cd5d8e13d9 handle bridging header decls in ForwardDeclaredConcreteTypeVisitor 2025-12-17 16:26:19 -08:00
Henrik G. Olsson
270f1d8619 [Swiftify] don't add macro when required type is unavailable
A Swift module only imports a type definition once. This means that some
clang modules may have function signatures imported with
`UnsafePointer<qux>` even if `qux` is only forward declared in that
module (which would normally be imported as `OpaquePointer`), because
some Swift file in the module imported the clang module with the
definition, so ClangImporter sees the definition. The macro expansion
only imports the imports of the clang module it belongs to however, so
namelookup for `qux` fails. This patch detects when this will result in
an error and avoids attaching the macro in those cases.

rdar://165864358
2025-12-17 16:26:16 -08:00
Henrik G. Olsson
38827c837e [Swiftify] don't swiftify functions with sugared parameter lists
These cases would trigger an assert in both release and debug builds.
With this change they are ignored in release mode, and cases that are
both unhandled and unknown trigger an assert in debug mode.

rdar://166074719
2025-12-15 14:37:07 -08:00
Henrik G. Olsson
ba7b9b0d6b Revert "Sema: Prefer the submodule import for access-levels diagnostics"
This reverts commit ca8792ca37.

Revert "[ImportResolution] Gracefully handle importing broken clang module"

This reverts commit edb48dff8c.

Revert "[ImportResolution] Don't deduplicate scoped imports"

This reverts commit da96079eb0.

Revert "[ImportResolution] Deduplicate top-level clang modules from import list"

This reverts commit 0ea5677aa1.

Reverting due to namelookup errors.

rdar://164588082
2025-11-19 23:10:14 -08:00
Henrik G. Olsson
c541666b21 Merge pull request #85023 from hnrklssn/swiftify-bridging-header
[ClangImporter] add implicit import of `Swift` for `__ObjC` module
2025-10-31 18:08:47 -07:00
John Hui
be3e118f8d [c-interop] Add test for SWIFT_RETURNS_RETAINED annotations in C interop mode
rdar://144976203
2025-10-22 14:53:11 -07:00
Henrik G. Olsson
314d3d520b add required feature 2025-10-21 13:50:06 -07:00
Henrik G. Olsson
c9a62660f3 [ClangImporter] add implicit import of Swift for __ObjC module
Any safe wrapper expansion originating in a bridging header would fail
typechecking because the `__ObjC` module doesn't import the standard
implicit imports. This is because the main module is not available to
inherit implicit imports from when the `__ObjC` module is created. We
don't need all of the implicit modules for safe wrappers, so import
`Swift` specifically.

rdar://163078116
2025-10-20 18:02:28 -07:00
Henrik G. Olsson
634084bc37 [MacrosOnImports] Don't import !swift modules
Inheriting a clang import marked `requires: !swift` will always result
in an error. This skips such imports, which *may* result in name lookup
errors instead, but also may not, depending on the module.

rdar://161795145
2025-10-15 14:25:06 -07:00
Henrik G. Olsson
3bc17bdd2f Merge pull request #84722 from hnrklssn/conditional-span-module-map
Move `span` to conditional header in libstdc++ module map
2025-10-06 22:09:07 -07:00
Henrik G. Olsson
5519be8b7c Move span to conditional header in libstdc++ module map
`span` is not available in all versions of libstd++, so make it a
conditional header. Also adds other missing c++20 headers.

Fixing this triggered an assert when importing a constant initialized
`wchar_t` variable, so that is also fixed. The reason is that `wchar_t`
is mapped to `Unicode.Scalar`, which cannot be directly initialized by
integer literals in Swift, triggering an assert when looking up the
protocol conformance for `_ExpressibleByBuiltinIntegerLiteral`.

rdar://162074714
2025-10-06 16:02:35 -07:00
Hamish Knight
99f6f60e8f [test] Fix availability in import-as-instance-method.swift
This test can run with non-macOS targets, update the availability
condition to be platform agnostic.
2025-10-06 11:47:16 +01:00
Henrik G. Olsson
ed4f058c01 Merge pull request #84507 from hnrklssn/swiftify-import-as-method
[Swiftify] Add support for free functions imported as instance methods
2025-10-04 00:40:00 -07:00
Henrik G. Olsson
0c3db50e3d fix -verify-additional-file path on windows 2025-10-03 15:25:06 -07:00
Mishal Shah
03a599c5be Merge pull request #84606 from swiftlang/rebranch
Merge clang 21.x rebranch into main
2025-10-02 20:17:05 -07:00
Henrik G. Olsson
bfe96dd84b [Swiftify] Reorder RUN lines (NFC)
Since the compiler invokation performing the macro expansion dump
redirects its stderr output, any errors are not displayed by default.
This is extra problematic for test failures in CI. By performing the
compiler invokation with -verify first, errors are shown.
2025-10-02 16:37:44 -07:00
Henrik G. Olsson
439b9e437b use swift/bridging in test 2025-10-02 16:37:43 -07:00
Henrik G. Olsson
748ef20c8c fix tests in CI 2025-10-02 16:37:42 -07:00
Henrik G. Olsson
87642d499a [Swiftify] Add support for free functions imported as instance methods
This adds support for attaching safe interop wrappers to functions
explicitly imported as instance methods using swift_name.

rdar://156288883
2025-10-02 16:37:40 -07:00
susmonteiro
f114a7bda0 [cxx-interop] Re-merge tests failing on Windows 2025-09-30 16:17:56 +01:00
swift-ci
2b9632fde3 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-30 07:55:22 -07:00
susmonteiro
7e14a8ea40 [cxx-interop] SWIFT_NONCOPYABLE overlooked in some cases 2025-09-30 09:28:58 +01:00
Henrik G. Olsson
472644e335 [Interop] Fix tests relying on transitive module imports (NFC) 2025-09-22 14:58:47 -07:00
swift-ci
ce0f17aeac Merge remote-tracking branch 'origin/main' into rebranch 2025-09-19 21:35:40 -07:00
Henrik G. Olsson
33634becd8 [ImportResolution] Remove redundant "Swift" module import
Import resolution now adds the Swift module to the list of imports, so
we no longer need to add it manually.
2025-09-16 21:10:06 -07:00
Henrik G. Olsson
0ea5677aa1 [ImportResolution] Deduplicate top-level clang modules from import list
Importing clang submodules results in an implicit import of the
top-level module as well. This can result in the same TLM being imported
many different times, if multiple submodules are imported from the same
module. This deduplicates these imports.

Other imports are not expected to be duplicated, so care is taken to
only deduplicate clang TLM imports.
2025-09-16 21:10:05 -07:00
Henrik G. Olsson
369fc18c01 [ClangImporter] Only import explicit submodules to the current module
Non-explicit submodules don't need to be explicitly added to the list of
imports to be visible, since their decls are implicitly exported. Skip
these modules even when present in the list of imports. Explicit
submodules are imported *regardless* of whether another module
imports them however.
2025-09-16 21:10:04 -07:00
Henrik G. Olsson
928cc6c83e [ClangImporter] Deduplicate imports copied from submodule to TLM
The imported top-level module inherits the imports of all its
(transitive) submodules. Since multiple submodules can import the same
modules these need to be deduplicated to avoid redundant work.
2025-09-16 21:10:03 -07:00