Commit Graph

6605 Commits

Author SHA1 Message Date
Alex Hoppen
23e2f345b5 Merge pull request #66441 from ahoppen/ahoppen/deadlock
[SourceKit] Jump to a background queue before executing `SKDUIDFromUIdent`
2023-06-08 08:55:55 -07:00
Alex Hoppen
f0ad2587d1 [SourceKit] Jump to a background queue before executing SKDUIDFromUIdent
`requestIsEnableBarriers` and `requestIsBarrier` call `SKDUIDFromUIdent`. What I didn’t know, was that `SKDUIDFromUIdent` can send XPC requests to the client to translate UIDs via `sourcekitd_set_uid_handlers`.

Since we were calling `requestIsEnableBarriers` directly from the XPC server’s main queue, and the UID handler sends an XPC request synchronously, we could get into a deadlock situation.

Immediately jump onto a serial background queue (`msgHandlingQueue`) in `sourcekitdServer_peer_event_handler` so that the main queue is free to execute the UID handler. This more closely matches the behavior before I introduced barriers as well, where we were always immediately jumping onto a concurrrent `msgHandlingQueue`.
2023-06-07 16:33:23 -07:00
Rintaro Ishizaki
c3d1304345 [SourceKit] Add request to expand macros syntactically
Expand macros in the specified source file syntactically (without any
module imports, nor typechecking).

Request would look like:
```
{
  key.compilerargs: [...]
  key.sourcefile: <file name>
  key.sourcetext: <source text> (optional)
  key.expansions: [<expansion specifier>...]
}
```
`key.compilerargs` are used for getting plugins search paths. If
`key.sourcetext` is not specified, it's loaded from the file system.
Each `<expansion sepecifier>` is
```
{
  key.offset: <offset>
  key.modulename: <plugin module name>
  key.typename: <macro typename>
  key.macro_roles: [<macro role UID>...]
}
```
Clients have to provide the module and type names because that's
semantic.

Response is a `CategorizedEdits` just like (semantic) "ExpandMacro"
refactoring. But without `key.buffer_name`. Nested expnasions are not
supported at this point.
2023-06-07 14:26:40 -07:00
Alex Hoppen
65e37f7c3a Merge pull request #66013 from ahoppen/ahoppen/sourcekitd-barriers
[sourcekitd] Allow client to enable use of dispatch barriers for open/edit/close on the message handling queue
2023-06-07 12:47:52 -07:00
Holly Borla
684ef9c482 [AST] Add a new accessor kind for init accessors. 2023-06-06 18:57:31 -07:00
Alex Hoppen
d4ffe402d2 Use dispatch barriers for open/edit/close on the message handling queue 2023-05-31 18:03:17 -07:00
Doug Gregor
3ca13588a4 [SourceKit] Fix paths when including the new Swift compiler 2023-05-28 23:27:15 -07:00
Eric Miotto
ccae4228fe Merge pull request #64103 from finagolfin/rpath
[CMake] Don't add an extraneous rpath to the swift-frontend
2023-05-24 07:55:20 -07:00
Artem Chikin
4920e4af84 Merge pull request #66031 from artemcm/BreakOutOverlayDeps
[Dependency Scanning] Break out Swift Overlay dependencies into separate output category
2023-05-23 08:22:33 -07:00
Alastair Houghton
f0595afa90 Merge pull request #66049 from al45tair/eng/PR-109649226
[Tools] Fix macro demangling.
2023-05-23 08:01:35 +01:00
Hamish Knight
4ce49bd4d2 [Parse] Sink registerParseRequestFunctions call into ParserUnit 2023-05-22 14:55:18 +01:00
Alastair Houghton
5e282eef91 [Tools] Fix macro demangling.
The code in swift-demangle to cope with macro demangling was slightly
wrong.  Fix it.

rdar://109649226
2023-05-22 11:06:55 +01:00
Artem Chikin
5ca91786ec [Dependency Scanning] Break out Swift overlay dependencies into separate output category
Instead of being a part of 'directDependencies' on a module dependency info, make them a separate array of dependency IDs for Swift Source and Textual modules.

This will allow clients to still distinguish direct module dependencies imported from a given module, versus dependencies added because direct/transitive Clang module dependencies have Swift overlays.

This change does *not* remove overlay dependencies from 'directDependencies' yet, just adds them as a separate field on the module details info. A followup change will remove overlay and bridging header dependencies from 'directDependencies' once the clients have had a chance to adopt to this change.
2023-05-19 14:47:43 -07:00
Rintaro Ishizaki
5fe2ead4e2 [Madros] Update for SwiftSyntaxMacroExpansion module
Share the same expansion logic between ASTGen and
SwiftCompilerMessageHandling
2023-05-11 19:45:14 -07:00
Adrian Prantl
fd06d27d43 Merge pull request #65725 from adrian-prantl/107869141
[Serialization] Teach ASTSectionImporter to filter by triple.
2023-05-08 13:03:12 -07:00
Adrian Prantl
a3a43d46c5 [Serialization] Teach ASTSectionImporter to filter by triple.
On macOS it is possible for one application to contain Swift modules compiled
for different triples that are incompatible as far as the Swift compiler is
concerned. Examples include an iOS simulator application hunning on a macOS
host, or a macCatalyst application running on macOS. A debugger might see
.swift_ast sections for all triples at the same time. This patch adds an
interface to let the client provide a triple to filter Swift modules in an
ASTSection.

rdar://107869141
2023-05-08 08:32:00 -07:00
Ben Barham
01086bc8b5 Merge pull request #65688 from bnbarham/swap-cursor-info-order
[CursorInfo] Prefer AST based results over solver based
2023-05-05 16:54:25 -07:00
Ben Barham
5beeca7cf1 [CursorInfo] Prefer AST based results over solver based
Solver based results are fast within a function, where the `ASTContext`
can be re-used. But it is significantly slower than the AST based
results when outside of a function. Instead of using solver based as the
primary results, only use them as a fallback for when AST based fails.

Resolves rdar://108930110.
2023-05-04 20:53:38 -07:00
Hamish Knight
2338b4cce3 Merge pull request #65472 from hamishknight/buffering 2023-05-03 10:00:50 +01:00
Alexis Laferrière
421042ec7c Merge pull request #65370 from xymus/serial-macro-paths
[Macros] Serialize plugin search paths for LLDB use
2023-05-02 09:20:16 -07:00
Hamish Knight
62b021030f [SourceKit] Include generated macro buffers in diagnostic responses
Introduce a new key `generated_buffers`, which
stores an array of generated buffers. These
include the buffer text, as well as its original
location and any parent buffers.

While here, also fix rdar://107281079 such that
only apply the filename fallback logic to the
pretty-printed Decl case. We ought to remove this
fallback once the editor can handle it though.

rdar://107281079
rdar://107952288
2023-05-02 16:21:44 +01:00
Hamish Knight
c35d1198c3 [SourceKit] Introduce RawCharSourceRange
Use this to simplify the writing of ranges into
SourceKit responses.
2023-05-02 16:21:44 +01:00
Hamish Knight
f0d5456b33 NFC: Move some code around 2023-05-02 16:21:44 +01:00
Rintaro Ishizaki
3ef6087d32 [Macros] Serialize plugin search paths for LLDB use
rdar://107030743
2023-05-01 14:04:39 -07:00
Ben Barham
3368e710a2 Merge pull request #65515 from bnbarham/add-attached-type-relation
[Completion] Add convertible type relation for attached macros
2023-05-01 09:52:04 -07:00
Ben Barham
f7d1cc8426 [Completion] Add convertible type relation for attached macros
Resolves rdar://108678938.
2023-04-28 16:15:51 -07:00
Hamish Knight
a55ae621b0 Merge pull request #65265 from hamishknight/whats-up-doc 2023-04-26 21:18:07 +01:00
Artem Chikin
aae2fe2a7d Merge pull request #65372 from artemcm/DepScanNowWithRegex
[Dependency Scanning] Build libSwiftScan with Swift Modules required for parsing regex
2023-04-26 08:23:24 -07:00
Hamish Knight
b8ae0666ad Rename getBriefComment -> getSemanticBriefComment
Make it clear that we will walk the comment providing
decls if needed.
2023-04-26 12:38:38 +01:00
Rintaro Ishizaki
a551c01d6a [Macros] Track plugin dependencies
* Factor out ASTContext plugin loading to newly introduced 'PluginLoader'
* Insert 'DependencyTracker' to 'PluginLoader'
* Add dependencies right before loading the plugins

rdar://104938481
2023-04-25 10:50:32 -07:00
Artem Chikin
6c71d8000b [Dependency Scanning] Build libSwiftScan with Swift Modules required for parsing regex
Otherwise scanning actions which encounter regex literals will fail.

Resolves rdar://108321860
2023-04-25 10:17:49 -07:00
Steven Wu
86927ef39c Merge pull request #65288 from cachemeifyoucan/eng/PR-swift-cache-backend
[CAS] Teach swift compiler to compute cache key and store outputs into CAS
2023-04-25 09:23:15 -07:00
Steven Wu
c153210505 [CAS] Add test case for cache key computation
Add tool swift-cache-tool for caching related testing and inspection.
2023-04-24 13:56:33 -07:00
Erik Eckstein
e7af73e2de Replace the swift-llvm-opt binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:53:12 +02:00
Erik Eckstein
2b2bc45e08 Replace the swift-dependency-tool binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:51:04 +02:00
Erik Eckstein
8ce6038a42 Replace the sil-passpipeline-dumper binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:49:33 +02:00
Erik Eckstein
e3a174b85e Replace the sil-llvm-gen binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:48:23 +02:00
Erik Eckstein
bc7b632d3e Replace the sil-nm binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:47:13 +02:00
Erik Eckstein
b6132d10e5 Replace the sil-func-extractor binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:45:22 +02:00
Erik Eckstein
2e9c241034 Replace the sil-opt binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:44:04 +02:00
Alex Hoppen
aef35b917e [SourceKit] Expand editor placeholder to trailing closures inside a TryExpr
rdar://108391690
2023-04-21 17:21:50 -07:00
Alexis Laferrière
1ddc7939cd Merge pull request #65168 from xymus/display-public-only
[IDE] Inject Sendable conformance on public types only in `getTopLevelDeclsForDisplay`
2023-04-17 17:36:28 -07:00
Alexis Laferrière
7f32a9e8c4 [IDE] Inject Sendable conformance on public types only
When getTopLevelDeclsForDisplay is called on an imported module, it may
lists non-public decls. If we they try to inject the conformance on
Sendable on internal types, the compiler may crash on failing to
deserialize internal details. As a fix, let's only inject the
conformance on public or package types.

rdar://95430471
2023-04-14 13:40:02 -07:00
Rintaro Ishizaki
5e5c233e94 Merge pull request #65068 from rintaro/sourcekit-pluginpath-rdar107849796
[SourceKit] Pass 'swiftc' path to Driver when creating frontend args
2023-04-13 14:22:54 -07:00
Rintaro Ishizaki
fe1eb469e4 [ASTGen] Avoid including C standard libary headers in brigdging headers
C stdlib headers are part of "Darwin"/"Glibc" clang module.
If a Swift file imports a bridging headers and that has '#include'
C stdlib headers, Swift compiler implicitly imports "Darwin"/"Glibc"
overlay modules. That violates dependency layering. I.e. Compiler
depends on Darwin overlay, Darwin overlay is created by the compiler.

rdar://107957117
2023-04-12 17:22:32 -07:00
Rintaro Ishizaki
3517db4c3b [SourceKit] Pass 'swiftc' path to Driver when creating frontend args
Driver uses its path to derive the plugin paths (i.e.
'lib/swift/host/plugins' et al.) Previously it was a constant string
'swiftc' that caused SourceKit failed to find dylib plugins in the
toolchain. Since 'SwiftLangSupport' knows the swift-frontend path,
use it, but replacing the filename with 'swiftc', to derive the plugin
paths.

rdar://107849796
2023-04-12 09:53:43 -07:00
Rintaro Ishizaki
96ff0e2c3b [swift-ide-test] Add plugin related options 2023-04-11 17:35:52 -07:00
Alex
3264428b2a Merge pull request #65025 from bulbazord/swift-demangle-use-argument
[Demangling][NFC] Actually use first argument of demangle
2023-04-10 13:39:03 -07:00
Ben Barham
e5dbe300e4 Merge pull request #64986 from bnbarham/macro-completion
[Completion] Only provide macro completions when they are valid
2023-04-08 11:08:42 -07:00
Alex Langford
7f33efac58 [Demangling][NFC] Actually use first argument of demangle 2023-04-07 21:32:03 -07:00