Commit Graph

1617 Commits

Author SHA1 Message Date
Paul Passeron 425cd0ebd7 [experimental] Infrastructure for derived conformances via macros (#89419)
**Overview**:
This PR introduces the basic infrastructure needed to eventually migrate
derived macros generation from hand-crafted AST nodes to macros. No
conformance have been migrated yet.

**Motivation**:
Derived conformances (e.g. `Equatable`, `Hashable`, `Codable`, ...) are
currently implemented as a special case in the compiler, producing
synthetic AST nodes directly. Migrating this to macros will hopefully
unify the code path with the existing macro expansion infrastructure,
make conformance synthesis easier to extend and test as well as reducing
the amount of special cases in the compiler.

**Changes**:
- New experimental feature flag `DeriveConformancesViaMacros`:
Introduces the flag that will eventually gate the new derived
conformance code paths. It does not control any behaviour for the moment
as none have been migrated yet but this enables future changes to be
built incrementally.
- New GeneratedSourceInfo and SourceFile kinds `SyntheticMacro`:
Introduces new GSI and SourceFile kinds named `SyntheticMacro` to
represent macros synthesized by the compiler. Since macros need a real
buffer to expand, this is the kind of source file and GSI associated
with those buffers.
- Conformance derivation via macros API:
Introduces the `deriveRequirementViaMacro` function that produces the
required witness via macro expansion.

See https://github.com/swiftlang/llvm-project/pull/13124 for
llvm-related changes.

**Next steps**:
- Macros do not contain any semantic information, especially regarding
types. Therefore it is necessary to provide them with type information
as an argument so they can eventually derive the conformances. A
separate PR is being created to generate this type information as
strings containing swift-parsable code for easy parsing on the macro
end.
- Implement derived conformance synthesis for individual protocols using
the new infrastructure, like `Equatable` or `Hashable` for starters.
- Wire the experimental flag to gate the new path once an implementation
exists

---------

Co-authored-by: Hamish Knight <hamish_knight@apple.com>
2026-06-08 14:23:58 +01:00
Anthony Latsis ddf4976e2a SourceKit: Remove CloseClangModuleFiles
Comment says to remove this thing when the radar is resolved, which was
a long time ago. Try to rip it out to avoid a rebranch-specific change.
2026-05-19 16:35:55 +01:00
Alexis Laferrière 1af6d6d28e Merge pull request #87353 from xymus/polyglot-ast-gen
ClangImporter: Services to parse Objective-C code and generate a `@objc @implementation` stub
2026-03-27 12:18:56 -07:00
Alexis Laferrière 31906d8bba IDE: Intro request to parse an ObjC implementation file and return AST
The new request in SourceKit allows to query this JSON format via the
usual SourceKit APIs. We use it here for testing but it can be
integrated in a client as needed.
2026-03-25 11:36:15 -07:00
Artem Chikin e3f07a58f5 [Diagnostics] Display full diagnostic group parent chains
When a diagnostic belongs to a group that has a parent group (`GROUP_LINK` in `DiagnosticGroups.def`), display the full inheritance chain in the diagnostic output, including documentation hyperlinks and footnotes for each.

For example, a diagnostic in `ExistentialType` (child of `PerformanceHints`) now renders as:
```
warning: ... [#PerformanceHints::ExistentialType]
```
Groups without parents continue to display as before (`[#DeprecatedDeclaration]`).

Resolves rdar://170805800
2026-03-16 10:04:10 +00:00
Hamish Knight 451f7df952 [Sema] Fix type-checker assertion for SourceKit
We ought to properly fix this, but for now let's avoid asserting for
SourceKit.
2026-03-08 00:19:10 +00:00
Hamish Knight eb45f2396d Replace vfs::getRealFileSystem -> vfs::createPhysicalFileSystem
Calling `setCurrentWorkingDirectory` on `getRealFileSystem` sets the
working directory for the process itself. This is unsafe for clients
such as SourceKit which can process multiple concurrent requests,
and may be used as an in-process library in e.g sourcekit-lsp. Switch
to `createPhysicalFileSystem` instead, where setting the working
directory is done locally on the FileSystem itself.
2026-02-09 09:46:34 +00:00
Hamish Knight bb9b5bf8c9 [IDE] Remove some redundant checks
`getRealFileSystem` returns a new FileSystem object each time so this
check is effectively `if (true)`.
2026-02-09 09:46:34 +00:00
Tim Kientzle 8eabeeb8ca [SE-0474] Read2/Modify2 => YieldingBorrow/YieldingMutate
This updates a large number of internal symbols, function names,
and types to match the final approved terminology.  Matching the
surface language terminology and the compiler internals should
make the code easier for people to understand into the future.
2026-01-03 16:05:12 -08:00
Hamish Knight f0d4572a92 [SourceKit] Always check buffer in SemanticAnnotator
Make sure we don't ever try to record semantic tokens for a different
buffer. This works around an ASTWalker issue where it will walk macro
expanded bodies even in non-macro-expansion mode.

rdar://165420658
2025-12-10 17:41:00 +00:00
Slava Pestov 819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Anthony Latsis bda6edb85c AST: Rename GenericContext::isGeneric to hasGenericParamList
`isGeneric` is a misleading name because this method checks for the
existence of a `GenericParamList`, which is not implied by genericity.
2025-11-11 15:55:16 +00:00
Alex Hoppen 893340d4f6 Merge pull request #85175 from ahoppen/swift-access-level
[Index] Record the access level of declarations in the index
2025-11-04 16:38:38 +01:00
Alex Hoppen aa9c295ad5 [Index] Record the access level of declarations in the index
rdar://163256878
2025-10-30 14:36:29 +01:00
Becca Royal-Gordon 393965090e Merge pull request #34556 from beccadax/mod-squad-2
[SE-0491] Implement lookup and diagnostics for module selectors (MyMod::someName)
2025-10-28 16:00:26 -07:00
Allan Shortlidge 92227ad1cf AST: Introduce the Swift, anyAppleOS, and DriverKit platform kinds.
This change just stages in a few new platform kinds, without fully adding
support for them yet.

- The `Swift` platform represents availability of the Swift runtime across all
  platforms that support an ABI stable Swift runtime (see the pitch at
  https://forums.swift.org/t/pitch-swift-runtime-availability/82742).
- The `anyAppleOS` platform is an experimental platform that represents all of
  Apple's operating systems. This is intended to simplify writing availability
  for Apple's platforms by taking advantage of the new unified OS versioning
  system announced at WWDC 2025.
- The `DriverKit` platform corresponds to Apple DriverKit which is already
  supported by LLVM.
2025-10-27 19:15:04 -07:00
Becca Royal-Gordon ffaa35810c Handle lookup into Builtin with module selector
Lookups like Builtin::Int64 were failing because BuiltinUnit rejected all unqualified lookups. Make it allow unqualified lookups with a module selector.
2025-10-24 16:23:48 -07:00
Hamish Knight 6f1417135b [SourceKit] Fix handling of @abi in AnnotatingPrinter
Make sure we avoid adding these to the entity stack entirely, which
avoids hitting the assertion that a top-level entity isn't encountered
with a non-empty stack.
2025-10-23 09:11:17 +01:00
Mads Odgaard c92e5b47f3 Merge pull request #84574 from madsodgaard/android-availability 2025-10-20 10:40:37 +09:00
Egor Zhdan 62d388a09f Merge pull request #84435 from egorzhdan/egorzhdan/do-not-generate-interface-twice
[cxx-interop] Avoid trying to generate module interfaces twice
2025-10-07 17:50:11 +01:00
swift-ci 499f4ff714 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-29 06:15:20 -07:00
Egor Zhdan a610bcd752 [cxx-interop] Avoid trying to generate module interfaces twice
This reverts most of 72050c5385, which led to decreased performance of jump-to-definition.

Instead of re-attempting to generate a module interface with C++ interop enabled, Swift should rely on the IDE to pass the correct `-cxx-interoperability-mode=` value to SourceKit.

rdar://149061322
2025-09-22 18:48:20 +01:00
Ahmed Mahmoud 2f6064675e [IDE] Move signature help formatting to IDE instead of SourceKit 2025-09-19 18:24:57 +03:00
swift-ci 0d2c4ca9be Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 10:29:21 -07:00
Meghana Gupta c764244df0 Merge pull request #84180 from meg-gupta/borrowandmutatepr
Add preliminary support for borrow accessors
2025-09-15 10:01:15 -07:00
swift-ci 4c7c8c2e22 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-15 06:58:07 -07:00
Ahmed Mahmoud 7dcc341a82 [IDE] Add internal parameter names in signature help 2025-09-13 15:26:33 +03:00
Meghana Gupta 9fe489ce22 Introduce borrow and mutate as new accessor kinds
And handle them in various covered switches
2025-09-09 14:30:26 -07:00
Anthony Latsis e1450e011e Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
*	utils/build_swift/build_swift/defaults.py
2025-09-04 14:07:50 +01:00
Ahmed Elrefaey 9d1436c1c8 [IDE] [Signature Help] Add basic signature help request to SourceKit (#83378) 2025-09-04 10:09:02 +01:00
Ahmed Elrefaey 1bc96857a8 Merge pull request #82464 from a7medev/feat/full-documentation-in-code-completion
[IDE] Add full documentation to code completion result
2025-09-04 10:06:21 +01:00
swift-ci 8309156358 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-31 09:55:24 -07:00
Owen Voorhees 57062d85ae Merge pull request #84031 from owenv/owenv/sourcekit-remarks 2025-08-31 09:47:02 -07:00
Owen Voorhees 593346ab0d Include remarks in SourceKit diagnostics responses 2025-08-30 22:17:00 -07:00
swift-ci 5ed4b2a070 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-28 13:06:19 -07:00
Hamish Knight a3edf17b24 [SourceKit] Fix assertion failure in sortTopN
With the unqualified fallback we start to hit this assertion for
`return nil` in failable intializers. We ought to be able to just
skip over literal buckets though.
2025-08-25 11:13:40 +01:00
swift-ci 5c840b6e1a Merge remote-tracking branch 'origin/main' into rebranch 2025-08-07 18:54:54 -07:00
Alex Hoppen 2d2adfb017 Merge pull request #82947 from ahoppen/compress-index
[Index] Add an option to compress the record and unit files
2025-08-07 21:12:39 +02:00
swift-ci 3998a187f9 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-30 09:36:41 -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
swift-ci 367f0082fc Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 22:17:45 -07:00
Anthony Latsis 2920ea84d1 Address llvm::(Mutable)ArrayRef ctor deprecations
See:
- https://github.com/llvm/llvm-project/pull/146113
- https://github.com/llvm/llvm-project/pull/146011
2025-07-21 12:36:53 +01:00
Alex Hoppen ed3b64af2c [Index] Add an option to compress the record and unit files
Companion of https://github.com/swiftlang/llvm-project/pull/10977.
2025-07-10 15:23:51 +02:00
swift-ci 922f9bf099 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-26 04:35:23 -07:00
Hamish Knight 55ef1bcaf0 [SourceKit] Print backticks if needed in printDisplayName
Ensure we print raw identifier names with backticks for e.g the
document structure request.

rdar://152524780
2025-06-25 15:15:17 +01:00
swift-ci 789bd8bd9c Merge remote-tracking branch 'origin/main' into rebranch 2025-06-19 02:17:51 -07:00
John Hui a0d3ad7bd0 Merge pull request #82006 from j-hui/jump-to-def-for-macro-expanded-clang-imports
[SourceKit] Support location info for macro-expanded Clang imports
2025-06-19 02:01:40 -07:00
swift-ci a626a79577 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-18 20:55:46 -07:00
John Hui 6b36996081 [NFC] Refactor setLocationInfo to return LocationInfo instead 2025-06-18 02:26:15 -07:00
(null) d6811260a9 Merge commit '665515c781999a81094bbe4f8302a7cb1a6a6b39' into mchiu/freebsd 2025-06-17 15:12:23 -04:00