Commit Graph

6603 Commits

Author SHA1 Message Date
Hamish Knight
7522a3ea5b [SourceKit] Handle CustomAttrs arguments for placeholder expansion
Introduce a new ASTWalker option for walking CustomAttrs and use it
for the placeholder scanner to ensure we can expand placeholders in
attribute arguments.
2025-05-21 18:06:54 +01:00
Hamish Knight
60952784fc [SourceKit] Handle macro arguments in placeholder expansion
Allow macro argument placeholders to expand into trailing closures.

rdar://150550747
2025-05-21 18:06:54 +01:00
Ben Barham
381684a389 [SourceKit] Remove diagnostics path calculation
The diagnostic group documentation now point to the swift.org URL rather
than the toolchain path, so it no longer needs to be passed all the way
through sourcekitd.

Resolves rdar://151500502.
2025-05-16 17:58:16 -07:00
Mike Ash
0ed232aff0 Merge pull request #81457 from mikeash/swift-inspect-corpse-leak
[swift-inspect] Fix corpse leaks when target doesn't have libswiftCore loaded.
2025-05-16 18:29:12 -04:00
Alex Hoppen
9d30958066 [SourceKit] Allow passing cancel_on_subsequent_request: 0 for all requests that use a OncePerASTToken
We need this option for `collectVariableType` (aka inlay type hints) but since I’m at it, I’m adding an option to disable the implicit request cancellation for all requests that have it since we don’t want it in LSP at all.

Prerequisite to fixing https://github.com/swiftlang/sourcekit-lsp/issues/2021 / rdar://145871554, need to adopt this option in SourceKit-LSP.
2025-05-14 18:42:19 +02:00
Mike Ash
9671d6b37c [swift-inspect] Fix corpse leaks when target doesn't have libswiftCore loaded.
In DarwinRemoteProcess's early return when libswiftCore.dylib isn't loaded in the process, we hadn't initialized all stored properties yet, which means our deinit didn't run. This leaked the task. This is especially bad when forking a corpse, as the system has a very limited number of corpses available.

Add a Cleanup helper to manage resources that need explicit cleanup. This is a noncopyable struct which takes a cleanup function and calls it whenever a new value is set or when the struct is destroyed. Use this for the DarwinRemoteProcess properties that need explicit cleanup. This allows us to remove DarwinRemoteProcess's deinit and always run these cleanups regardless of how we exit the initializer.

While we're here, fix the truncations of buffer in getAllProcesses.

rdar://151170155
2025-05-13 13:53:14 -04:00
Mike Ash
cf48debc73 Merge pull request #81186 from jabrylg/add-json-summary-to-swift-inspect-dump-raw-metadata
[swift-inspect] Add json and summary options to DumpRawMetadata
2025-05-09 11:22:50 -04: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
Jabryl Guy
b9fa070c63 [swift-inspect] Add json and summary options to DumpRawMetadata 2025-04-29 16:03:20 -07:00
Saleem Abdulrasool
0b953adb44 SwiftInspectLinux: re-order initialization
It seems that a recent change to the compiler will now optimize the
initializer and then the SIL verifier will fail due to the unintialized
member when the initializer is throwing and will never return without
initializing the member unless the initialization fails.
2025-04-22 11:15:14 -07:00
Michael Gottesman
3ff9463957 Make Feature a struct enum so we can put methods on it.
Just noticed this as I was looking at making other changes.
2025-04-05 10:08:29 +01:00
Allan Shortlidge
8f2d5a759e Merge pull request #80321 from tshortli/warnings 2025-03-30 16:14:21 -07:00
Doug Gregor
e88f8995e1 [Diagnostics] Eliminate educational notes in favor of diagnostic groups
We've been converging the implementations of educational notes and
diagnostic groups, where both provide category information in
diagnostics (e.g., `[#StrictMemorySafety]`) and corresponding
short-form documentation files. The diagnostic group model is more
useful in a few ways:

* It provides warnings-as-errors control for warnings in the group
* It is easier to associate a diagnostic with a group with
GROUPED_ERROR/GROUPED_WARNING than it is to have a separate diagnostic
ID -> mapping.
* It is easier to see our progress on diagnostic-group coverage
* It provides an easy name to use for diagnostic purposes.

Collapse the educational-notes infrastructure into diagnostic groups,
migrating all of the existing educational notes into new groups.
Simplify the code paths that dealt with multiple educational notes to
have a single, possibly-missing "category documentation URL", which is
how we're treating this.
2025-03-29 15:40:35 -07:00
Allan Shortlidge
8c54a354e3 SourceKit: Fix an unused variable warning in XPCService.cpp. 2025-03-28 12:33:40 -07:00
Dave Lee
115b2b7bcb [swift-inspect] Use decimal format for Task ID (#80309)
Use decimal to display Task IDs. This matches changes being done else where to use decimal consistently for Task IDs. For example https://github.com/swiftlang/swift/pull/80154 and https://github.com/swiftlang/llvm-project/pull/10308.
2025-03-27 12:39:19 -07:00
Becca Royal-Gordon
775bdacefc [NFC] Extract Decl::getExplicitObjCName()
Create a helper method which looks for an `@objc` attribute with an explicit name and returns it, and adopt it in various existing places.
2025-03-26 10:47:12 -07:00
Anthony Latsis
631a04e56c Merge pull request #80159 from AnthonyLatsis/danaus-plexippus-5
Sema: Extend adoption mode for `AsyncCallerExecution` to storage declarations
2025-03-26 04:40:58 +00:00
Dylan Sturgeon
2c8e337f25 Merge pull request #80074 from dylansturg/objc_enum_refs
The Error enum synthesized declarations, e.g. the struct and its static accessors, should generally appear to be identical to the underlying Clang definitions. There are some specific use cases where the synthesized declarations are necessary though.

I've added an option for USR generation to override the Clang node and emit the USR of the synthesized Swift declaration. This is used by SwiftDocSupport so that the USRs of the synthesized declarations are emitted.

Fixes 79912
2025-03-25 11:21:21 +00:00
Anthony Latsis
6512aa1f5a AST: Introduce and use ValueDecl::isAsync 2025-03-25 02:07:03 +00:00
Anthony Latsis
3d3b1ca50a [NFC] AST: Turn getParameterList into a method on ValueDecl 2025-03-19 18:49:15 +00:00
Hamish Knight
b60fe39dc2 [SourceKit] Change bundle ID from com.apple to org.swift
rdar://146840864
2025-03-12 10:29:28 +00:00
Evan Wilde
eeee0dfddd CMake: option to disable swift in swift
Adding `SWIFT_ENABLE_SWIFT_IN_SWIFT` option to enable or disable the
parts of Swift that require a Swift compiler to build. This is meant for
bootstrapping compilers on new platforms and is not guaranteed to result
in a compiler that will pass the test suite.

This option is on by default so that folks won't forget.
If the option is off, the resulting compiler does not include the Swift
optimizer sources in SwiftCompilerSources nor does the resulting
compiler have swift macro support.
2025-03-06 13:32:49 -08:00
Ben Barham
ce8458ee67 Merge pull request #79530 from bnbarham/load-service-from-file
[SourceKit] Do not hardcode the XPC service name
2025-03-04 09:33:36 -08:00
Konrad `ktoso` Malawski
92ead521b8 [Concurrency] Fix swift-inspect and remote mirror build (#79715) 2025-03-04 07:04:42 +09:00
Ben Barham
652da5555f [SourceKit] Do not hardcode the XPC service name
Write the service name into a resource file rather than have it
hardcoded, allowing it to be updated post-build if necessary.
2025-02-28 21:19:45 -08:00
Doug Gregor
aafd24bfed Prefer diagnostic group names for diagnostic categories over the ad hoc ones 2025-02-27 19:40:23 -08:00
Konrad `ktoso` Malawski
f55964df26 [Concurrency] Initial steps for startSynchronously for Task (#79608)
* [Concurrency] Initial steps for startSynchronously for Task

* [Concurrency] Rename to _startSynchronously while in development

* [Concurrency] StartSynchronously special executor to avoid switching

* startSynchronously bring back more info output

* [Concurrency] startSynchronously with more custom executor tests

* add missing ABI additions to test for x86

* [Concurrency] gyb generate _startSynchronously

* [Concurrency] %import dispatch for Linux startSynchronously test

* [Concurrency] Add TaskGroup.startTaskSynchronously funcs

* [Concurrency] DispatchSerialQueue does not exist on linux still
2025-02-27 02:34:33 -08:00
Mike Ash
b3a430d175 [swift-inspect] On Darwin, don't try to inspect processes that don't have Swift.
When we locate libswiftCore.dylib in the remote process, check for failure and give up immediately if we don't find one. If the process doesn't have Swift, there's no point in trying to inspect anything in it.

rdar://143978694
2025-02-24 14:37:43 -05:00
Steven Wu
c42268e7f1 Merge pull request #79301 from cachemeifyoucan/eng/PR-144623388
[BridgingHeader] Fix auto-chaining when only dependency has bridging header
2025-02-13 11:35:39 -08:00
Steven Wu
719edaf7e2 [BridgingHeader] Fix auto-chaining when only dependency has bridging header
When enable bridging header auto chaining, it is possible for the
compilation to have a PCH file input for the bridging header from a
binary swift module dependency. In this case, we should not report a
bridging header for current module as bridging header can be leaking out
through swiftinterface file.

To fully distinguish the PCH files passed in through different
situation, here are the situations:
* If no chaining is used, only `-import-objc-header` option is used and
  it can be used to pass either a header file or a PCH file depending if
  GeneratePCH job is requested or not.
* If chaining is enabled, `-import-objc-header` is only used to pass the
  header file and `-import-pch` is used to pass PCH file. Chaining mode
  requires PCH generation if bridging header is used.

rdar://144623388
2025-02-12 07:30:14 -08:00
Hamish Knight
d260bd8ddb [build-script] Remove Xcode generation support
This was quite brittle and has now been superseded
by swift-xcodegen. Remove the CMake/build-script
logic for it, leaving the option behind to inform
users to switch to using xcodegen instead.
2025-02-12 12:19:21 +00:00
Slava Pestov
17d8c820dc Merge pull request #79220 from slavapestov/fix-rdar143950572
AST: Source range of FuncDecl/ConstructorDecl should include the thrown type
2025-02-10 13:49:37 -05:00
Slava Pestov
a6a96da558 AST: Source range of FuncDecl/ConstructorDecl should include the thrown type
When a function declaration has a body, its source range ends at the
closing curly brace, so it includes the `throws(E)`. However, a
protocol requirement doesn't have a body, and due to an oversight,
getSourceRange() was never updated to include the extra tokens
that appear after `throws` when the function declares a thrown
error type. As a result, unqualified lookup would fail to find a
generic parameter type, if that happened to be the thrown type.

Fixes rdar://problem/143950572.
2025-02-10 09:17:40 -05:00
Steven Wu
9d59044bb1 [BrdigingHeader] Auto bridging header chaining
Add ability to automatically chaining the bridging headers discovered from all
dependencies module when doing swift caching build. This will eliminate all
implicit bridging header imports from the build and make the bridging header
importing behavior much more reliable, while keep the compatibility at maximum.

For example, if the current module A depends on module B and C, and both B and
C are binary modules that uses bridging header, when building module A,
dependency scanner will construct a new header that chains three bridging
headers together with the option to build a PCH from it. This will make all
importing errors more obvious while improving the performance.
2025-02-05 09:41:04 -08:00
eeckstein
71015c674b Merge pull request #78980 from eeckstein/fix-swift-demangle
swift-demangle: don't require the $-prefix for embedded symbols
2025-01-29 07:18:27 +01:00
Saleem Abdulrasool
18fa490721 Merge pull request #78827 from andrurogerz/swift-inspect-cmake
[swift-inspect] use CMake FetchContent to fetch ArgumentParser when not provided
2025-01-28 14:40:34 -08:00
Erik Eckstein
1f36fa5c0b swift-demangle: don't require the $-prefix for embedded symbols
Support demangling `swift-demangle e4main8MyStructV3fooyyFAA1XV_Tg5` (note the missing $-prefix)
2025-01-28 17:35:53 +01:00
Alastair Houghton
ab8e561583 Merge pull request #78516 from al45tair/eng/PR-124913332
[Backtracing] Implement API per SE-0419
2025-01-28 10:48:33 +00:00
Alex Hoppen
d5a6ff2d3a Merge pull request #78686 from ahoppen/explicit-enum-type
[SourceKit] Explicitly specify the type of enums in CodeCompletinSwiftInterop.h
2025-01-24 22:28:07 -08:00
Saleem Abdulrasool
bfd09996ad Merge pull request #78821 from compnerd/tradewars
SourceKit: correct the macro definitions to avoid warnings on Windows
2025-01-23 15:29:35 -08:00
Andrew Rogers
92dea69b7e [swift-inspect] build swift-argument-parser as shared lib when fetched remotely 2025-01-22 15:53:07 -08:00
Andrew Rogers
7b1c4dc461 [swift-inspect] clarify CMake use block() to scope ArgumentParser properties 2025-01-22 15:20:23 -08:00
Saleem Abdulrasool
c9019d6a9c swift-inspect: mark some conformances as retroactive
This silences a couple of warnings in the swift-inspect build.
2025-01-22 15:17:12 -08:00
Andrew Rogers
b0bae6355b [swift-inspect] clarify CMake properties set for ArgumentParser 2025-01-22 14:52:07 -08:00
Andrew Rogers
ba9be84a8a [swift-inspect] update CMake documentation 2025-01-22 14:50:40 -08:00
Andrew Rogers
9792a07b66 [swift-inspect] bump swift-argument-parser version to 1.5.0 2025-01-22 14:30:23 -08:00
Andrew Rogers
509a07767b [swift-inspect] use FetchContent to fetch ArgumentParser in CMake build 2025-01-22 14:29:50 -08:00
Saleem Abdulrasool
1d2eb3bc2c SourceKit: correct the macro definitions to avoid warnings on Windows
This silences a large number of warnings due to
`-Winconsistent-dllimport`. While it is possible to support the library
to be built statically, that is not currently supported by the build
system, so simply leave that unsupported for decoration.

An option here for ELF targets would be to use
`__attribute__((__visibility__("default")))` and enable hidden
visibility by default enabling a small bit of optimization.
2025-01-22 14:00:46 -08:00
Alastair Houghton
18496c5626 [Backtracing] Remove support for implicit import of _Backtracing.
We're going to rename the module to Runtime, and it isn't going to be an
implicit import, so we don't need any of this.

rdar://124913332
2025-01-17 10:09:36 +00:00
Alex Hoppen
3e3e33fc13 [SourceKit] Explicitly specify the type of enums in CodeCompletinSwiftInterop.h
To match the definition in SourceKit-LSP, which were needed because enums default to `int32_t` on Windows.
2025-01-16 11:31:28 -08:00