Commit Graph

2392 Commits

Author SHA1 Message Date
swift-ci
161f6727b7 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-05 04:53:29 -07:00
Alex Hoppen
021cdd4416 Merge pull request #81975 from ahoppen/sema-annotate-source-range 2025-06-05 13:49:54 +02:00
Alex Hoppen
c6c40de73d [IDE] Pass a SourceRange instead of a CharSourceRange in SemaAnnotator::passReference
Most `SemaAnnotator`s don’t actually care about the char source range. Instead, they only care about the start location of the reference, which is also included in `SourceRange`. Computing a `CharSourceRange` from a `SourceRange` is kind of expensive because it needs to start a new lexer.

To avoid this overhead, pass `SourceRange` to `SemaAnnotator::passReference` and related functions and let the clients compute the `CharSourceRange` when needed.

This reduces the overhead of index-while-building by about 10%.
2025-06-04 18:01:47 +02:00
Michael Chiu
7bbafc599d Merge branch 'main' into mchiu/freebsd 2025-06-02 13:33:18 -04:00
swift-ci
f6526c0013 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-02 10:00:43 -07:00
Pavel Yaskevich
816ea9fda6 [CodeCompletion] Implement completions in using declaration's specifier position 2025-05-30 00:39:06 -07:00
swift-ci
82545aecbb Merge remote-tracking branch 'origin/main' into rebranch 2025-05-29 12:37:25 -07:00
michael-yuji
8738e722bd Merge branch 'main' into mchiu/freebsd 2025-05-28 14:44:11 -07:00
Hamish Knight
f6c73cd178 [SourceKit] Properly handle cursor info range for macro expansions
Make `getOriginalLocation` work with source ranges, and adjust the
cursor info logic to map the range into the original buffer. This
fixes the case where we were using bogus range lengths for macro
expansion decls.

rdar://151411756
2025-05-28 18:51:40 +01:00
swift-ci
f9bf2d1715 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-22 12:35:19 -07:00
michael-yuji
9a948a9c3b Merge branch 'main' into mchiu/freebsd 2025-05-21 16:29:16 -07:00
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
swift-ci
a1a25f83a4 Merge remote-tracking branch 'origin/main' into rebranch 2025-05-20 11:39:00 -07: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
swift-ci
33ad7cd97b Merge remote-tracking branch 'origin/main' into rebranch 2025-05-15 05:54:06 -07: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
Anthony Latsis
0c536923c9 Manually merge branch 'main' into rebranch 2025-05-07 14:05:43 +01: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
Anthony Latsis
da47b58586 Refactor llvm::opt::GenericOptTable subclasses after changes to LLVM Option library
Per dd647e3e608ed0b2bac7c588d5859b80ef4a5976 (llvm-project).
2025-04-24 01:52:46 +01:00
Anthony Latsis
b71e689138 Adjust includes of moved Clang headers
Per 0d150db214e2aa13a825b563c7238e1243d61db1 (llvm-project).
2025-04-24 01:52:46 +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
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
Michael Chiu
7f0f2ac4dd Merge swiftlang#38335 2025-03-14 02:15:15 -04:00
Hamish Knight
b60fe39dc2 [SourceKit] Change bundle ID from com.apple to org.swift
rdar://146840864
2025-03-12 10:29:28 +00: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
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
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
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
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
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
Alex Hoppen
e2235e201c Merge pull request #78421 from ahoppen/add-sourcekit-plugin
[SourceKit] Add mechanism to load plugins for request handling into SourceKit
2025-01-15 12:42:10 -08:00
Doug Gregor
8bb5bbedbc Implement an unsafe expression to cover uses of unsafe constructs
Introduce an `unsafe` expression akin to `try` and `await` that notes
that there are unsafe constructs in the expression to the right-hand
side. Extend the effects checker to also check for unsafety along with
throwing and async operations. This will result in diagnostics like
the following:

    10 |   func sum() -> Int {
    11 |     withUnsafeBufferPointer { buffer in
    12 |       let value = buffer[0]
       |                   |     `- note: reference to unsafe subscript 'subscript(_:)'
       |                   |- warning: expression uses unsafe constructs but is not marked with 'unsafe'
       |                   `- note: reference to parameter 'buffer' involves unsafe type 'UnsafeBufferPointer<Int>'
    13 |       tryWithP(X())
    14 |       return fastAdd(buffer.baseAddress, buffer.count)

These will come with a Fix-It that inserts `unsafe` into the proper
place. There's also a warning that appears when `unsafe` doesn't cover
any unsafe code, making it easier to clean up extraneous `unsafe`.

This approach requires that `@unsafe` be present on any declaration
that involves unsafe constructs within its signature. Outside of the
signature, the `unsafe` expression is used to identify unsafe code.
2025-01-10 10:39:14 -08:00
Alex Hoppen
c0ad0b62b6 [SourceKit] Support Windows for the SourceKit plugin 2025-01-10 19:21:20 +01:00
Alex Hoppen
21b729f195 Fix test failures of SourceKit plugin on Linux 2025-01-07 12:25:48 -08:00
Allan Shortlidge
77141c5bc5 SourceKit: Adopt SemanticAvailableAttr in SwiftDocSupport.cpp. 2025-01-07 07:31:29 -08:00
Alex Hoppen
aeac681bae [SourceKit] Make the SourceKit plugin infrastructure buildable on Linux and Windows 2025-01-06 13:57:57 +01:00
Alex Hoppen
40b91aa97a Share logic to load dynamic libraries between SourceKit plugins and macro plugins 2025-01-03 16:23:16 +01:00
Alex Hoppen
6d0463ad82 [SourceKit] Apply clang-format to the SourceKit plugin sources 2025-01-03 15:24:52 +01:00
Alex Hoppen
b6c94aecc3 [SourceKit] Add mechanism to load plugins for request handling into SourceKit
This allows us to load plugins into the sourcekitd service to handle requests (currently only used for code completion). This allows us to implement parts of sourcekitd in Swift and outside of the compiler repository, making it easier to iterated on them because the compiler doesn’t need to be rebuilt.
2025-01-03 15:24:52 +01:00