Commit Graph

2092 Commits

Author SHA1 Message Date
Allan Shortlidge
e0eba4ed5e AST: Add printing support for #available and #_hasSymbol conditions.
Teach `ASTPrinter` to print `if #available` and `if #_hasSymbol` statements.
2025-09-05 18:34:31 -07:00
Allan Shortlidge
b047396246 AST: Use availability to control decl visibility in public swiftinterfaces.
Declarations that are unavailable at runtime because of an `@available`
attribute referencing a custom domain that was imported `@_spiOnly` should be
hidden from public swiftinterface files in `-library-level=api` modules. For
remaining declarations that do get printed in the public swiftinterface, skip
printing any `@available` attribute that refers to the domains from those
`@_spiOnly` dependencies. This allows API developers to control declaration
visibility using availability defined by another module.

Resolves rdar://156512028.
2025-09-04 12:32:19 -07:00
Hamish Knight
ff200137a8 [AST] Add ErrorType originator for PlaceholderType 2025-08-30 16:05:01 +01:00
Allan Shortlidge
441132426f ModuleInterface: Only print API-level property wrappers in swiftinterfaces.
When a function parameter has attached property wrappers (SE-0293) those
property wrappers are either considered "implementation" or "API" level.
Property wrappers that are implementation-level don't affect how the function
is called and therefore shouldn't be included in swiftinterfaces unless the
function's body is also printed.

Resolves rdar://156711817.
2025-08-27 21:35:20 -07:00
Erik Eckstein
833560f08f SIL: fix printing of dependent existential archetypes
We were missing parentheses:
```
  $@opened("...", any P2) Self.A
```
->
```
  $(@opened("...", any P2) Self).A
```
2025-08-25 19:38:26 +02:00
Egor Zhdan
f96a5e5b2b Merge pull request #83589 from egorzhdan/egorzhdan/reland-extern-namespace
Revert "Revert "[cxx-interop] Import decls in extern blocks within namespaces""
2025-08-15 18:30:51 +01:00
Egor Zhdan
a5b4975204 Revert "Revert "[cxx-interop] Import decls in extern blocks within namespaces""
This reverts commit 8f60840551.
2025-08-07 15:03:08 +01:00
Allan Shortlidge
8f60840551 Revert "[cxx-interop] Import decls in extern blocks within namespaces"
This reverts commit 844787fddb.
2025-08-06 21:50:55 -07:00
Pavel Yaskevich
53ef38e31b [AST] NFC: Rename function type isolation NonisolatedCaller to NonisolatedNonsending
This reduces the number of ways we refer to caller isolated async
functions and matches the name to the attribute spelling.
2025-08-05 17:22:10 -07:00
Egor Zhdan
844787fddb [cxx-interop] Import decls in extern blocks within namespaces
This teaches ClangImporter to import C++ decls that are declared within `extern "C" { ... }`/`extern "C++" { ... }` blocks which are nested in namespaces.

rdar://139067788
2025-08-04 19:42:43 +01:00
Allan Shortlidge
2b8ab7fbab AST: Re-baseline SendingArgsAndResults feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
a37ce9a543 AST: Re-baseline IsolatedDeinit feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
dd28a3e4b5 AST: Re-baseline IsolatedAny feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
491a43a66b AST: Re-baseline MemorySafetyAttributes feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
49dcbb7ad4 AST: Re-baseline BitwiseCopyable2 feature. 2025-07-31 10:21:55 -07:00
Anthony Latsis
fec049e5e4 Address llvm::PointerUnion::{is,get} deprecations
These were deprecated in
https://github.com/llvm/llvm-project/pull/122623.
2025-07-29 18:37:48 +01:00
Allan Shortlidge
910989c2c2 AST: Store parsed version in OriginallyDefinedInAttr instead of canonical.
Canonicalize the version on-demand instead.

NFC, part of rdar://155558161.
2025-07-14 16:04:04 -07:00
Slava Pestov
aa87afd2cb AST: Fix printing of BuiltinFixedArrayType 2025-07-09 22:16:14 -04:00
Pavel Yaskevich
0444d297b6 [AST/Sema] SE-0487: Remove @preEnumExtensibility attribute 2025-07-04 11:06:44 -07:00
Pavel Yaskevich
fe1ae75711 [AST/Sema] SE-0487: Rename @extensible into @nonexhaustive
This is an accepted spelling for the attribute. This commit
also renames the feature flag from `ExtensibleAttribute` to
`NonexhaustiveAttribute` to match the spelling of the attribute.
2025-07-03 17:50:05 -07:00
Egor Zhdan
cc9c51deea [cxx-interop] Fix printing of namespaces declared in bridging headers
If a C++ namespace has redeclarations in a bridging header, printing AST for the namespace would crash the compiler. This is because such a redeclaration would not have an owning Clang module, and the AST printer did not account for that.

This change fixes the crash.

rdar://151715540
2025-06-23 16:25:48 +01:00
John McCall
5c20b19296 Introduce non-recursive print options and use them to handle IUO
printing more elegantly.

NFC intended.
2025-06-18 11:47:36 +09:00
Meghana Gupta
dcf072f9d0 Introduce a new suppressible experimental feature to guard @_lifetime 2025-06-07 12:49:07 -07:00
John McCall
237e617fab Merge pull request #82008 from rjmccall/dont-copy-print-options
Prevent PrintOptions from being implicitly copied
2025-06-06 17:06:02 -04:00
Slava Pestov
0b3fd9eede ASTPrinter: Fix printing of let properties inside @objc @implementation extensions
A `let` here is really just a `var` with a `{ get }`.

Fixes rdar://problem/127120469.
2025-06-05 23:07:04 -04:00
John McCall
b3493bfa23 Prevent PrintOptions from being implicitly copied.
NFC *except* that I noticed a bug by inspection where we suppress
`@escaping` when print enum element types. Since this affects
recursive positions, we end up suppressing `@escaping` in places
we shouldn't. This is unlikely to affect much real code, but should
still obviously be fixed.

The new design is a little sketchy in that we're using `const` to
prevent direct use (and allow initialization of `const &` parameters)
but still relying on modification of the actual object.  Essentially,
we are treating the `const`-ness of the reference as a promise to leave
the original value in the object after computation rather than a
guarantee of not modifying the object. This is okay --- a temporary
bound to a `const` reference is still a non-`const` object formally
and can be modified without invoking UB --- but makes me a little
uncomfortable.
2025-06-05 12:52:01 -04:00
Pavel Yaskevich
e1e9f04398 Merge pull request #81863 from xedin/using-for-default-isolation-in-file-context
[AST/Sema] SE-0478:  Implement `using` declaration under an experimental flag
2025-06-02 09:56:29 -07:00
Pavel Yaskevich
ad71e07cae [AST] Don't print using declarations in swift interfaces
These declarations are effectively `fileprivate` at the moment
and should appear in swift interfaces.
2025-05-31 10:49:50 -07:00
Hamish Knight
5d1f219acb Change InlineArray sugar separator x -> of 2025-05-30 13:50:22 +01:00
Pavel Yaskevich
aabfebec03 [AST] Add new declaration - using
Initially this declaration is going to be used to determine
per-file default actor isolation i.e. `using @MainActor` and
`using nonisolated` but it could be extended to support other
file-global settings in the future.
2025-05-30 00:39:06 -07:00
Arnold Schwaighofer
13ff5abdb8 Introduce @specialized attribute
Implements SE-0460 -- the non-underscored version of @specialized.

It allows to specify "internal" (not abi affecting) specializations.

rdar://150033316
2025-05-23 13:12:47 -07:00
Ben Barham
6667471b3d Merge pull request #81115 from beccadax/abi-let-you-graduate
Finish implementing `@abi` (SE-0476)
2025-05-08 12:52:00 -07:00
Michael Gottesman
b34e2d72fb Merge pull request #81306 from gottesmm/pr-b6ba1a771d90007a5ee6da3e4dc657bfef32b320
[swift-settings] Now that we aren't using it immediately, remove it from tree.
2025-05-06 08:21:23 -07:00
Becca Royal-Gordon
01431b87b2 Make @abi non-experimental
This includes changing the feature name so that compilers with the experimental feature don’t accidentally pick up content that only works in the final version.

Resolves rdar://150065196.
2025-05-05 13:50:51 -07:00
Ben Barham
0bf1c1f3e1 Merge pull request #80958 from bnbarham/merge-modules
Merge exported modules with the same public name in generated interface
2025-05-05 13:49:12 -07:00
Michael Gottesman
9d59dbed17 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
2025-05-05 13:39:03 -07:00
Ben Barham
ddddc667c8 Merge exported modules with the same public name in generated interface
If a module has the same `public-module-name` as the module being
generated and its import is exported, merge it into the same generated
interface.

Fix various always-imported modules from being printed while here and
update all the tests that checked for them.

Resolves rdar://137887712.
2025-05-02 10:59:15 -07:00
Pavel Yaskevich
498430afaf [AST/Sema] Add @preEnumExtensibility attribute to downgrade warnings for extensible enums
Just like `@preconcurrency` for concurrency, this attribute is going
to allow exhaustiveness error downgrades for enums that were retroactively
marked as `@extensible`.
2025-05-02 09:07:22 -07:00
Slava Pestov
6ffa8fd489 AST: Change signature of LookupConformanceFn
Instead of passing in the substituted type, we pass in the
InFlightSubstitution. This allows the substituted type to be
recovered if needed, but we can now skip computing it for
the common case of LookUpConformanceInSubstitutionMap.
2025-04-30 13:42:20 -04:00
Slava Pestov
ba0ec53f8c AST: Tweak a DynamicSelfType hack in the ASTPrinter
Let's use transformRec() instead of subst() here since we want to
leave DependentMemberTypes unchanged. This avoids an assertion
failure with the upcoming change to InFlightSubstitution::lookupConformance().
2025-04-28 13:48:11 -04:00
Pavel Yaskevich
30a72ab5c9 Merge pull request #81073 from xedin/extensible-enums-flag
[Frontend] Add `ExtensibleAttribute` to guard use of `@extensible` at…
2025-04-25 10:06:55 -07:00
Pavel Yaskevich
6d89bca765 [Frontend] Add ExtensibleAttribute to guard use of @extensible attribute
Guard against condfails when older compilers get a swift interface
that uses `@extensible` attribute. The attribute itself doesn't
have any effect in swift interfaces yet since all of the public
enums are already resilient in that mode.
2025-04-24 12:09:17 -07:00
Hamish Knight
247dda9639 [ASTPrinter] Add missing null check in isNonSendableExtension
The extended nominal may not be present for an invalid extension.

rdar://149032713
2025-04-23 15:26:10 +01:00
Pavel Yaskevich
4fd4c00bc9 [AST] ASTPrinter: Always print attributes after parameter specifiers 2025-04-15 16:29:20 -07:00
Pavel Yaskevich
e302d73c87 [AST] ASTPrinter: Make sure that attributes are printed as attributes and specifiers as keywords 2025-04-15 16:29:20 -07:00
Pavel Yaskevich
ee38182ae2 [AST] ASTPrinter: Don't print '@escaping' on 'inout' parameters
All of the `inout` types are implicitly `@escaping`.
2025-04-15 16:29:13 -07:00
Pavel Yaskevich
6662a48533 [AST] ASTPrinter: Always print nonisolated(nonsending) parameter specifier first
This avoids any possible positioning issues between specifiers
and attributes.
2025-04-15 14:54:00 -07:00
Pavel Yaskevich
f1b3c7b604 [AST] Remove ExecutionAttribute experimental feature
SE-0461 has been accepted and `@concurrent` and `nonisolated(nonsending)`
can be make generally available now.
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
07ff063ae3 [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-11 15:59:25 -07:00
Becca Royal-Gordon
1445b819d0 Merge pull request #80476 from beccadax/implement-this
Stub fix-its for missing objcImpl requirements
2025-04-10 16:55:19 -07:00