Commit Graph

2062 Commits

Author SHA1 Message Date
Allan Shortlidge
8dad141136 AST: Promote Extern feature to baseline. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
c8a6a5041a AST: Remove unused functions in FeatureSet.cpp. 2024-07-09 14:28:29 -07:00
Allan Shortlidge
6b9b7bcd83 AST: Promote PrimaryAssociatedTypes2 feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
b5acc6b07d AST: Promote AsyncSequenceFailure feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
6f972fc275 AST: Promote AssociatedTypeAvailability feature to the baseline. 2024-07-09 14:28:28 -07:00
Allan Shortlidge
9e5a9b963f AST: Remove NoncopyableGenerics feature suppression.
It is no longer necessary to produce `.swiftinterface` files the support older
compilers that lack support for the NoncopyableGenerics feature. Cleaning this
up makes the stdlib `.swiftinterface` far more readable.
2024-07-08 17:44:24 -07:00
Michael Gottesman
fdd435a782 [sending] Replace sending with consuming when suppressing sending from arguments in swiftinterface files.
Previously we would just not print sending. This causes problems since sending
implies a +1 parameter and by removing it we convert the parameter to a +0
parameter, breaking ABI. In this commit, I make it so that when we suppress
sending from argument parameters, we just replace it with consuming so that we
preserve ABI even for callers who do not support sending.

rdar://131066640
2024-07-08 12:34:18 -07:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
1901862afc AST: Remove LookUpConformanceInSignature 2024-07-06 12:05:46 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Akira Hatanaka
42bc49d3fe Add a new parameter convention @in_cxx for non-trivial C++ classes that are passed indirectly and destructed by the caller (#73019)
This corresponds to the parameter-passing convention of the Itanium C++
ABI, in which the argument is passed indirectly and possibly modified,
but not destroyed, by the callee.

@in_cxx is handled the same way as @in in callers and @in_guaranteed in
callees. OwnershipModelEliminator emits the call to destroy_addr that is
needed to destroy the argument in the caller.

rdar://122707697
2024-06-27 09:44:04 -07:00
Kavon Farvardin
545844ce8f ASTPrinter: fix nested signatures with inverses
A generic signature's `getInnermostGenericParams` will find the generic
parameters in the innermost scope. That's not quite right for printing
inverses, since we don't want to print an inverse for `T` when emitting
the generic signature of `f` below:

```swift
    struct S<T: ~Copyable, E> {
        func f() where E == Never {}
    }
```

Since `f` has its own generic signature, but doesn't define any generic
parameters, it shouldn't have an inverse emitted. The solution here is
to filter inverses by depth of the generic parameter.

We also want to print _all_ of the inverses in other situations, rather
than just the innermost ones. This aids in debugging and other
tools like the API digester.

resolves rdar://130179698
2024-06-25 12:06:23 -07:00
Kavon Farvardin
80c99973d7 NFC: introduce isAddingConformanceToInvertible
Removes duplicated code between Sema and the ASTPrinter.
2024-06-24 15:34:58 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Kavon Farvardin
9eba052ab2 Merge pull request #74322 from kavon/se427-noimplicit-for-invertible
SE-427: Make conditional conformances to Copyable more explicit.
2024-06-12 22:03:49 -07:00
Kavon Farvardin
a1e14ae0c7 Sema: ext's must add solo invertible conformances
This helps prevent confusion after not inferring requirements if the
extension adds a Copyable conformance.
2024-06-12 14:44:22 -07:00
Kavon Farvardin
ec4a125f3e NCGenerics: ext's might not infer invertible req's
If the extension adds conformance to an invertible protocol, it's
confusing for people to also infer conditional requirements on the
generic parameters for those invertible protocols. This came up in the
review of SE-427.
2024-06-12 14:44:22 -07:00
Artem Chikin
71ec06e656 Cache visible Clang modules for interface printing in 'ModuleDecl'
Instead of caching the collection of visible Clang modules in the 'TypePrinter', compute and cache them in the 'ModuleDecl'. When printing a textual interface, the compiler will instantiate many new instances of 'TypePrinter', which means caching them there is not useful.
2024-06-11 13:04:16 -07:00
Becca Royal-Gordon
91afad2fb0 Merge pull request #74135 from beccadax/objcimpl-the-final-countdown
Fix two objcImpl resyntaxing bugs
2024-06-06 13:42:28 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Meghana Gupta
470fa2f365 Remove resultDependsOn/resultDependsOnSelf 2024-06-05 11:36:16 -07:00
Becca Royal-Gordon
b3e7a23e70 Fix @objc use in module interfaces for objcImpl
objcImpl extensions with final public members need to be printed into module interfaces, but with the @implementation attribute suppressed. That worked fine…but when we switched to the new syntax, we should also have suppressed the @objc attribute, and we mistakenly did not. Correct this oversight.

Fixes rdar://129178360.
2024-06-04 17:47:05 -07:00
Michael Gottesman
f7bbbbeea2 [ast] Add an asserts only option that causes the AST printer to print out an increasing ID for all suppressed statements.
I am using this to better test out suppression statements. I am finding that
FileCheck runs into issues with some of the '#if' lines I am trying to match. I
am able to use this option with my asserts only test to uniquely identify a '#if
...' statement and thus have the pattern matching work. I needed this to get the
test in the next commit to pass testing.
2024-05-30 22:19:11 -07:00
Michael Gottesman
521a70f416 [ast] Always emit compiler(>= 5.3) when emitting guards for suppressable features to guard against parser errors.
The code here was assuming that if we already emitted a compiler guard for
non-Suppressable features, we could avoid doing it for suppressable
features. The problem with this is that compiler() does more than just check for
compiler versions... it also tells the compiler that parser errors in the if
block should be ignored when if evaluates to false.

rdar://129045783
2024-05-30 22:12:09 -07:00
Kavon Farvardin
6e25d8b0a5 Merge pull request #73770 from kavon/tilde-copyable-printing-interface-rdar126090425
ASTPrinter: handle inverses in compositions
2024-05-21 12:33:02 -07:00
Kavon Farvardin
210cfb2b55 ASTPrinter: handle inverses in compositions
The basic inheritance clause emission in ASTPrinter operates on
InheritedEntry's, but does not canonicalize types. It's been
designed to consider an entire composition unprintable because one
member is unprintable (e.g., the protocol is not public).

This rejection is what was causing `~Copyable` in some compositions to
be missing from interface files (rdar://126090425). Fixing that is the
purpose of this patch.

What happens, then, if you mix public and nonpublic protocols in a
composition? A second facility called the InheritedProtocolCollector
later does find the public protocols, and emits extensions at the end of
the interface file to declare the additional conformances the ininitial
declaration printer missed.

We can't generally emit `~Copyable` on an extension, so the fix can't
happening there. Refactoring things so there's one source of truth about
the protocols being printed is a sizable refactoring that I will defer
for another time.

resolves rdar://126090425
2024-05-20 17:10:44 -07:00
Michael Gottesman
b780ff6696 [sending] Begin parsing 'sending' while still accepting 'transferring'.
A few things:

1. Internally except for in the parser and the clang importer, we only represent
'sending'. This means that it will be easy to remove 'transferring' once enough
time has passed.

2. I included a warning that suggested to the user to change 'transferring' ->
'sending'.

3. I duplicated the parsing diagnostics for 'sending' so both will still get
different sets of diagnostics for parsing issues... but anywhere below parsing,
I have just changed 'transferring' to 'sending' since transferring isn't
represented at those lower levels.

4. Since SendingArgsAndResults is always enabled when TransferringArgsAndResults
is enabled (NOTE not vis-a-versa), we know that we can always parse sending. So
we import "transferring" as "sending". This means that even if one marks a
function with "transferring", the compiler will guard it behind a
SendingArgsAndResults -D flag and in the imported header print out sending.

rdar://128216574
2024-05-16 21:43:50 -07:00
Michael Gottesman
e3e78ad6bb [sending] Change the internals of sending to be based around 'sending' instead of 'transferring'.
We still only parse transferring... but this sets us up for adding the new
'sending' syntax by first validating that this internal change does not mess up
the current transferring impl since we want both to keep working for now.

rdar://128216574
2024-05-16 12:20:45 -07:00
Nate Chandler
2671652085 [BitwiseCopyable] Avoid a condfail.
The standard library defines
```
protocol BitwiseCopyable {}
typealias _BitwiseCopyable = BitwiseCopyable
```
For current compilers, `BitwiseCopyable` is a "known protocol".

For older compilers, it is not; instead `_BitwiseCopyable` is.  So
print the following into the swiftinterface for those older compilers:
```
protocol _BitwiseCopyable {}
typealias BitwiseCopyable = _BitwiseCopyable
```

rdar://127755503
2024-05-08 16:53:14 -07:00
Slava Pestov
fda93680df Merge pull request #73363 from slavapestov/pack-expansion-closures-part-2
Extract common code for building opened existential and element signatures
2024-05-01 19:44:05 -04:00
Slava Pestov
818f47918c AST: Use getNextDepth()/getMaxDepth() 2024-05-01 12:09:01 -04:00
Michael Gottesman
dc25857805 [transferring] Make transferring suppressible and validate that we do suppress transferring in swift interface files.
Importantly I added tests that validated this behavior.

rdar://126780823
2024-04-30 16:40:40 -07:00
Pavel Yaskevich
24db5e7515 NFC: Add @error_type while printing errors types in debug mode 2024-04-26 09:30:27 -07:00
nate-chandler
b00b5aad4f Merge pull request #72646 from nate-chandler/bitwise-copyable/20240327/1
[BitwiseCopyable] Allow suppression via ~.
2024-04-18 07:05:10 -07:00
Slava Pestov
37344ab150 AST: Use Requirement::getProtocolDecl() 2024-04-16 12:34:55 -04:00
Nate Chandler
ba467d2bd2 [Sema] Enable suppression of inferred conformances.
Add the machinery to support suppression of inference of conformance to
protocols that would otherwise be derived automatically.

This commit does not enable any conformances to be suppressed.
2024-04-15 16:46:22 -07:00
Doug Gregor
79b78acdf6 Use SuppressibleProtocolSet as InvertibleProtocolSet
Collapse the representations of "suppressible" and "invertible"
protocol sets. Only minor adjustments were required.
2024-03-29 11:31:48 -07:00
Allan Shortlidge
ee73ff7737 AST: Adjust declaration printing when NoncopyableGenerics2 is suppressed.
When printing declarations with `NoncopyableGenerics2` suppressed we must avoid
printing the `@_preInverseGenerics` attribute and any `borrowing` or
`consuming` parameter ownership modifiers.
2024-03-27 22:20:49 -07:00
Rintaro Ishizaki
7b3738d1d0 [SourceKit] Adjust newlines between decls
Previously, Clang modules didn't have empty lines between top-level
decls. This was inconsistent with Swift module.
2024-03-25 22:07:50 +09:00
Rintaro Ishizaki
b019fd0c1b Merge pull request #72420 from rintaro/sourcekit-clang-printer-rdar93731287
[SourceKit] Stop printing normal comments in clang generated interface
2024-03-25 17:29:45 +09:00
Meghana Gupta
b5ca933002 Update lifetime dependence syntax and inference as per changes in the pitch
Pitch - https://github.com/apple/swift-evolution/pull/2305

Changes highlights:

dependsOn(paramName) and dependsOn(scoped argName) syntax

dependsOn(paramName) -> copy lifetime dependence for all parameters/self except
                         when we have Escapable parameters/self, we assign scope
                         lifetime dependence.

Allow lifetime dependence on parameters without ownership modifier.

Always infer copy lifetime dependence except when we have
Escapable parameters/self, we infer scope lifetime dependence.

Allow lifetime dependence inference on parameters without ownership modifier.
2024-03-23 18:19:47 -07:00
Konrad `ktoso` Malawski
6132386371 [Distributed] Complete handling of protocol calls and witnesses using adjusted mangling scheme (#72416) 2024-03-23 23:54:23 +09:00
Slava Pestov
336750effd Merge pull request #72495 from slavapestov/fix-protocol-superclass
AST: Remove ProtocolDecl::getSuperclass()
2024-03-22 07:40:46 -04:00
Slava Pestov
c95d9a341b AST: Replace a ProtocolDecl::getSuperclass() call 2024-03-21 14:49:05 -04:00
Rintaro Ishizaki
c9785d955d [SourceKit] Stop printing normal comments in clang generated interface
Generated interfaces for Clang modules used to try printing normal
comments between decls extracted from the header text. That was because
doc-comment was not common in C/ObjC headers. But mainly because of
"import as member feature" Clang decls aren't printed in the order as
they appear in the header file, the logic determinig which comment
belongs to which decl was not working property. We've decided to remove
that feature and only print the proper doc-comments as it has been
getting common.

rdar://93731287
2024-03-21 11:52:32 +09:00
Meghana Gupta
992396bfd5 Merge pull request #72431 from meg-gupta/lifetimeinsil
Parse explicit lifetime dependence specifiers in SIL
2024-03-19 17:11:23 -07:00
Meghana Gupta
5ad0a8b064 Parse explicit lifetime dependence specifiers in SIL 2024-03-19 13:34:50 -07:00
Slava Pestov
a628b9c061 AST: Remove InverseMarking.h 2024-03-16 08:34:42 -04:00
Kavon Farvardin
76c6510519 Merge pull request #72276 from kavon/ncgenerics-xfails-3 2024-03-16 04:18:35 -07:00
Doug Gregor
164ae687ff Make NoncopyableGenerics a suppressible feature
Emit Swift interface files that are compatible with Swift compilers that
predate the introduction of noncopyable generics.
2024-03-15 14:50:40 -07:00