Commit Graph

109 Commits

Author SHA1 Message Date
Doug Gregor
020b69d4b6 [SE-0497] Implement @export attribute syntax
Implement the @export(implementation) and @export(interface) attributes
to replace @_alwaysEmitIntoClient and @_neverEmitIntoClient. Provide a
warning + Fix-It to start staging out the very-new
@_neverEmitIntoClient. We'll hold off on pushing folks toward
@_alwaysEmitIntoClient for a little longer.
2025-11-07 22:00:40 -08:00
Hamish Knight
a1e1656ed5 [AST] Remove respectOriginallyDefinedIn parameter from mangleAnyDecl
This was always set to `true` except for USR mangling, where we already
have it set to `false` for IDE USRs. The other clients were:

- AutoDiff, which is just using the resulting string as a dictionary
key, so don't seem to have any preference.
- The ClangImporter, which always overrides `@_originallyDefinedIn`
anyway.
2025-10-23 09:11:17 +01:00
Allan Shortlidge
4e9a883824 AST: Rename SwiftLanguage availability domain kind to SwiftLanguageMode. 2025-10-08 15:46:34 -07:00
Anthony Latsis
e101d0aa58 APIDigester: Sort conformances when dumping sdk
See https://github.com/swiftlang/swift/pull/84193 for context.
2025-09-12 14:28:34 +01:00
Anthony Latsis
26de61d826 [cmake] APIDigester, IDE: Specify Clang link dependencies
This way, CMake will propagate the interface compile definitions of the
Clang dependencies, which is important on Windows because Clang
visibility macro expansions, controlled by compile definitions, must
match between the Swift and Clang library.

See https://github.com/llvm/llvm-project/pull/108276/files#diff-4dd645a8b76bb3886a505258a8c2e598aeddea770e7b0a2b51689124a5ea6e9a.
2025-08-12 18:13:22 +01:00
Anthony Latsis
1ceeb7089b Merge pull request #82338 from AnthonyLatsis/jepa
ASTBridging: Bridge more enums directly
2025-06-20 23:13:50 +01:00
Anthony Latsis
3e9923f0c0 ASTBridging: Bridge swift::AccessorKind directly 2025-06-19 04:26:52 +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
Doug Gregor
731f58443c Address review feedback on AbstractConformance in ProtocolConformanceRef 2025-03-23 20:54:39 -07:00
Rintaro Ishizaki
002d7d7cdf [Parse/AST] Remove PoundDiagnosticDecl
There is no reson to make a AST node for '#error' and '#warning'
directives. Parser knows the diagnostics should be emitted or not.
2025-03-07 21:48:01 -08:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Xi Ge
87877bd95f ABI checker: avoid diagnosing missing availability info for decls that are only explicitly available on visionOS
Resolves: rdar://145061506
2025-02-18 09:56:42 -08:00
Allan Shortlidge
ba822d1e23 AST: Eliminate remaining direct access to AvailableAttr's fields.
Most of the compiler should use SemanticAvailableAttr instead. In contexts like
ASTDumper where a semantic attribute is unavailable use accessors on
AvailableAttr.

NFC.
2025-01-21 22:56:07 -08:00
Allan Shortlidge
ab9bbcc707 swift-api-digester: Adopt SemanticAvailableAttr. 2025-01-08 08:17:27 -08:00
Allan Shortlidge
0288eaa3b7 AST: Introduce Decl::getSemanticAvailableAttrs().
This new attribute iterator returned from the query makes it simpler to
implement algorithms that need access to both the `AvailableAttr *` and its
corresponding `AvailabilityDomain`. This is also work towards making it
possible to return an optional `AvailabilityDomain` from
`Decl::getDomainForAvailableAttr()`.
2024-12-19 08:40:00 -08:00
Kuba (Brecka) Mracek
8792efedf0 Merge pull request #77115 from kubamracek/embedded-mangling-prefix
[Mangling] [NFC] Prepare for a new mangling prefix for Embedded Swift: $e
2024-12-03 08:10:49 -08:00
Kuba Mracek
6f4ae28520 [ASTMangler] Pass ASTContext to all instantiations of ASTMangler 2024-12-02 15:01:04 -08:00
Allan Shortlidge
c5398e17d3 AST: Introduce Decl::getDeprecatedAttr().
It replaces `DeclAttr::getDeprecated()` as the designated way to query for the
attribute that makes a decl deprecated.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
1dc7aa5b7b AST: Introduce Decl::isUnavailable().
Replace calls to `AvailableAttr::isUnavailable()` with `Decl::isUnavailable()`.
2024-12-02 07:35:58 -08:00
Allan Shortlidge
36230cd9c6 AST: Use an accessor to get the PlatformKind from an AvailableAttr. 2024-11-21 09:10:36 -08:00
Slava Pestov
47156e006b AST: Introduce ProtocolConformanceRef::forAbstract() 2024-11-16 16:16:06 -05:00
Rintaro Ishizaki
d4db99ce9d [Parse] Remove unnecessary dependencies to Parser.h
C++ swift::Parser is going to be replaced with SwiftParser+ASTGen.
Direct dependencies to it should be removed. Before that, remove
unnecessary '#include "swift/Parse/Parser.h"' to clarify what actually
depends on 'swift::Parser'.

Split 'swift::parseDeclName()' et al. into the dedicated files.
2024-11-02 01:23:59 -07:00
Hamish Knight
2d7500eda6 [AST] Remove ParenType
Today ParenType is used:

1. As the type of ParenExpr
2. As the payload type of an unlabeled single
   associated value enum case (and the type of
   ParenPattern).
3. As the type for an `(X)` TypeRepr

For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.

3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
2024-10-31 11:32:40 +00:00
Hamish Knight
289092b9ec [api-digester] Avoid modeling ParenType
This isn't a useful node to record.
2024-10-24 15:13:06 +01:00
Doug Gregor
5b2520e379 Remove IfConfigDecl from the AST
The swift-syntax tree retains information about the parsed #if
regions. Drop it from the semantic AST.
2024-09-18 20:51:54 -07:00
Hamish Knight
1cb0f8fdd5 [AST] Rename isPrivateStdlibDecl -> isPrivateSystemDecl
This better reflects what we're actually checking
here.
2024-08-28 18:31:51 +01:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Holly Borla
5da7ac6cbd [NFC] Use DeclAttributes::isDeprecated in a few more places. 2024-06-10 07:16:44 -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
Slava Pestov
082246094b AST: Pass SubstFlags::PreservePackExpansionLevel in a few more places 2024-04-04 19:36:25 -04: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
Kavon Farvardin
3b02f306ee APIDigester: Stringify inverses in GenericSigs
The presence of Copyable/Escapable conformances doesn't affect ABI. Only
their absence in terms of suppressed requirements like `~Copyable` need
to be output for diffing by the APIDigester.
2024-03-14 23:10:44 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Slava Pestov
52239f5ef5 APIDigester: Use getAllInheritedProtocols() 2024-02-24 07:25:59 -05:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Hamish Knight
16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00
Rintaro Ishizaki
92e70ef80a [AST] Remove DeclAttrKind::Count
Introduce NumDeclAttrKinds for number of enum values. Use optional for
invalid attribute kind. This align with `TypeAttrKind`.
2024-02-02 09:36:49 -08:00
Rintaro Ishizaki
8fdc4cc225 [AST] Split Attr.def to DeclAttr.def and TypeAttr.def 2024-02-02 09:36:49 -08:00
Rintaro Ishizaki
b839718351 [AST] Use scoped enum for attribute kinds
Align with other kind enum e.g. DeclKind.
2024-02-02 09:36:48 -08:00
Rintaro Ishizaki
07bb0380a1 [AST] Use class names for type attribute kind enum
Align with DeclAttrKind.
2024-02-02 09:36:47 -08:00
John McCall
41cdfb04ad Introduce a proper TypeAttribute class hierarchy.
The old TypeAttributes reprsentation wasn't too bad for a small number of
simple attributes.  Unfortunately, the number of attributes has grown over
the years by quite a bit, which makes TypeAttributes fairly bulky even at
just a single SourceLoc per attribute.  The bigger problem is that we want
to carry more information than that on some of these attributes, which is
all super ad hoc and awkward.  And given that we want to do some things
for each attribute we see, like diagnosing unapplied attributes, the linear
data structure does require a fair amount of extra work.

I switched around the checking logic quite a bit in order to try to fit in
with the new representation better.  The most significant change here is the
change to how we handle implicit noescape, where now we're passing the
escaping attribute's presence down in the context instead of resetting the
context anytime we see any attributes at all.  This should be cleaner overall.

The source range changes around some of the @escaping checking is really a
sort of bugfix --- the existing code was really jumping from the @ sign
all the way past the autoclosure keyword in a way that I'm not sure always
works and is definitely a little unintentional-feeling.

I tried to make the parser logic more consistent around recognizing these
parameter specifiers; it seems better now, at least.
2024-01-28 22:30:26 -05:00
Meghana Gupta
fd588ab509 Remove SelfAccessKind::ResultDependsOnSelf 2023-11-29 12:11:57 -08:00
Meghana Gupta
5658deae27 Add initial support for _resultDependsOnSelf
This is used to establish lifetime dependence between self and the result.

Add under NonEscapableTypes experimental feature
2023-11-08 01:48:59 -08:00
Xi Ge
49eefc0b67 ABIChecker: add an API to document that SDKNodeRoot contains single module name. NFC 2023-09-18 10:37:55 -07:00
Xi Ge
95d73171ae ABIChecker: include module name explicitly in generated ABI baseline. NFC 2023-09-15 13:16:46 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00