Commit Graph

2171 Commits

Author SHA1 Message Date
Hamish Knight
c7e9809480 [IDE] Mangle USRs using API decls rather than ABI decls
For semantic functionality the API decl is the more useful thing to
mangle, and redeclaration checking ensures we can't end up with
conflicts. This ensures we're able to perform a name lookup for the
decl based on its USR without having to maintain a separate lookup 
table for ABI names.
2025-10-23 09:11:17 +01: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
Henrik G. Olsson
3266b5f4a6 Merge pull request #84774 from hnrklssn/fix-std-span-linux
Fix std::span tests on linux
2025-10-20 16:06:35 -07:00
Henrik G. Olsson
c844d483ff [cxx-interop] Add llvm-lit feature 'std_span'
This adds a check in lit.local.cfg for whether the current C++ stdlib
contains the 'span' header. If so, the llvm-lit feature 'std_span' is
set. Also adds 'REQUIRES: std_span' to interop tests that include
'span'. This means we no longer have to choose between blanket disabling
`std::span` tests on all Linux distributions, or listing every Linux
distro with a libstdc++ version without `std::span` support as
unsupported.

I couldn't find any existing path to the MSVC stdlib in lit, and we
don't test versions of MSVC old enought to not support std::span
anyways, so 'std_span' is unconditionally enabled when targeting
windows-msvc.

rdar://161999160
rdar://161999174
rdar://162106580
rdar://162106619
rdar://162106643
rdar://162106653
rdar://162106722
rdar://162106747
2025-10-17 15:41:26 -07:00
Henrik G. Olsson
9e2a18d401 fix tests with TMP_DIR 2025-10-12 16:01:30 -07: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
Hamish Knight
a7dd04ed6f Merge pull request #84403 from a7medev/refactor/signature-help-to-ide
[IDE] Move signature help formatting to IDE instead of SourceKit
2025-09-29 14:05:02 +01: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
Hamish Knight
0bfbe987b4 [AST] Print ErrorType as _
In preparation for removing UnresolvedType in favor of ErrorType,
start printing ErrorType as `_` unless we've enabled debug printing.
`<<error type>>` should never be presented to the user, instead `_`
now just consistently means "unknown type".
2025-09-21 23:19:06 +01:00
Henrik G. Olsson
7fcc72f108 Merge pull request #81859 from swiftlang/swiftify-inherit-imports
[MacrosOnImports][Swiftify] Copy module imports from clang node's module to its Swift macro SourceFile
2025-09-19 21:21:09 -07:00
Ahmed Mahmoud
979ccd1f50 [Test] Use swift-ide-test for signature help tests 2025-09-19 21:03:05 +03:00
Henrik G. Olsson
0276febf41 handle libc++ v17-19
libc++ v17-19 was split into multiple top-level modules, while versions
earlier and later had one TLM with submodules.
2025-09-16 21:10:09 -07:00
Ahmed Mahmoud
7dcc341a82 [IDE] Add internal parameter names in signature help 2025-09-13 15:26:33 +03: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
Mishal Shah
c75932b89f Merge pull request #83748 from swiftlang/bump-version-6.3
Bump the Swift version to 6.3
2025-09-03 21:18:05 -07:00
Hamish Knight
0c3be92c10 Merge pull request #83652 from a7medev/feat/generalize-erase-archetypes
[IDE] Erase archetypes without declaration generic signature
2025-09-01 11:01:54 +01: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
Ahmed Mahmoud
491b3a0fbc [IDE] Erase archetypes with no declaration generic signature
This generalization enables curried functions with generic parameters coming from the initial declaration to be printed with the archetype's upperbound rather than '_' unresolved type.

As an added benefit, T.self and T.Type for generic parameters now get shown as the upperbound of the generic parameter provided
2025-08-29 13:39:58 +03:00
Hamish Knight
44ba366759 Merge pull request #83662 from hamishknight/unqualified-fallback
[Completion] Fall back to unqualified lookup on solver failure
2025-08-28 20:39:11 +01:00
Hamish Knight
7e22297b71 [AST] Walk ErrorExpr's original expr in ASTWalker
We set an original expression on ErrorExpr for cases where we have
something semantically invalid that doesn't fit into the AST, but is
still something that the user has explicitly written. For example
this is how we represent unresolved dots without member names (`x.`).
We still want to type-check the underlying expression though since
it can provide useful diagnostics and allows semantic functionality
such as completion and cursor info to work correctly.

rdar://130771574
2025-08-27 15:27:06 +01: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
Mishal Shah
63ef5a0cc7 Bump the Swift version to 6.3 2025-08-14 23:06:49 -07:00
Hamish Knight
e1e0f72288 [IDE] Avoid redundant worklist visitor
This is unnecessary since the local conformances for a protocol
can only contain self-conformances, which we don't want to visit
anyway. This can just be a straightforward loop over the local
conformances.
2025-08-13 21:19:07 +01:00
Erik Eckstein
e28125b106 stdlib: specialize OptionSet.insert for FixedWidthInteger raw-values
This lets the generated code boil down to a single or-instruction.

rdar://157958188
2025-08-12 08:05:49 +02:00
Hamish Knight
87f9820c85 [AST] Visit TypeValueExpr's TypeRepr in ASTWalker
Ensure that we walk the TypeRepr to ensure that both cursor info and
indexing pick up on the reference to the generic parameter.

rdar://145509737
2025-07-16 21:19:15 +01:00
Rintaro Ishizaki
dfacf99526 [Test] Fix test failure caused by invalid iOS version for availability
'20.0' is not a valid version number for iOS

rdar://155463166
2025-07-14 10:13:14 -07:00
Hamish Knight
4064ad19e6 Merge pull request #82966 from hamishknight/len-check
[Refactoring] Handle argument count mismatches in `renameLabelsLenient`
2025-07-11 10:09:56 +01:00
Hamish Knight
6a63f307aa [Refactoring] Handle argument count mismatches in renameLabelsLenient
Make sure we bail if we don't have enough labels in the old name when
matching against a found reference.

rdar://155549979
2025-07-10 21:33:42 +01:00
Hamish Knight
9e16906c53 [test] Add test case for raw identifier semantic tokens
rdar://152273926
2025-07-10 15:43:08 +01:00
Doug Gregor
5900c8a9e3 Update tests for Span back-deployment 2025-07-07 22:57:44 -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
John Hui
44aba1382d [SourceKit] Support location info for macro-expanded Clang imports
Currently, when we jump-to-definition for decls that are macro-expanded
from Clang imported decls (e.g., safe overloads generated by
@_SwiftifyImport), setLocationInfo() emits a bongus location pointing to
a generated buffer, leading the IDE to try to jump to a file that does
not exist.

The root cause here is that setLocationInfo() calls getOriginalRange()
(earlier, getOriginalLocation()), which was not written to account for
such cases where a macro is generated from another generated buffer
whose kind is 'AttributeFromClang'.

This patch fixes setLocationInfo() with some refactoring:

-   getOriginalRange() is inlined into setLocationInfo(), so that the
    generated buffer-handling logic is localized to that function. This
    includes how it handles buffers generated for ReplacedFunctionBody.

-   getOriginalLocation() is used in a couple of other places that only
    care about macros expanded from the same buffer (so other generated
    buffers not not relevant). This "macro-chasing" logic is simplified
    and moved from ModuleDecl::getOriginalRange() to a free-standing
    function, getMacroUnexpandedRange() (there is no reason for it to be
    a method of ModuleDecl).

-   GeneratedSourceInfo now carries an extra ClangNode field, which is
    populated by getClangSwiftAttrSourceFile() when constructing
    a generated buffer for an 'AttributeFromClang'. This could probably
    be union'ed with one or more of the other fields in the future.

rdar://151020332
2025-06-12 18:22:06 -07:00
Anthony Latsis
d0b00504d8 Merge pull request #81426 from AnthonyLatsis/quercus-ilex
[test] Fix misspelled FileCheck directives
2025-05-30 17:54:28 +01:00
Anthony Latsis
0a1b8b0d50 [test] Fix misspelled FileCheck directives 2025-05-29 15:09:36 +01: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
Henrik G. Olsson
0f312adb92 [Swiftify] Always annotate overloads with @_disfavoredOverload (#81579)
Previously we would only add @_disfavoredOverload if the only type
changed was the return type, because in any other case it is unambiguous
which overload to call. However it is still ambiguous when storing the
function as a value rather than calling the function, unless explicit
type annotations are used.

To avoid breaking any existing code, this patch adds
@_disfavoredOverload to every overload generated by @_SwiftifyImport.

rdar://151206394
2025-05-23 21:21:49 -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
Ben Barham
7e63d08300 Merge pull request #81582 from bnbarham/remove-sk-diag-path
[SourceKit] Remove diagnostics path calculation
2025-05-20 11:17:01 -07:00
Henrik G. Olsson
6534b9b14f [Swiftify] Copy doc comment from clang node (#81584)
Swift nodes imported from clang don't have doc comments carried over,
but IDEs are clever enough to fetch the comments from the associated
clang node. The swift node in the macro expansion from _SwiftifyImport
doesn't have a clang node directly associated with it however.

This patch adds the same comment from the clang node to the
_SwiftifyImport macro invocation node. Since the macro has access to
this node, it can easily copy over its leading trivia.

For now the comment is not altered at all, meaning @param still remains
even if the parmeter is removed.

rdar://151346977
2025-05-20 08:06:20 -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
Hamish Knight
6eb76dfd15 [Driver] Avoid using response files for SourceKit
We only care about the frontend arguments here, creating a response
file is unnecessary.

rdar://98880399
2025-05-16 15:35:15 +01:00
Hamish Knight
b53c411655 [Frontend] Avoid storing StringRef values in ModuleAliasMap
Previously we would insert StringRefs that reference the keys in the
map, but that breaks if the invocation ever gets copied. Switch to
`std::string`.

rdar://148130166
2025-05-09 19:49:50 +01:00
Ben Barham
0bf1c1f3e1 Merge pull request #80958 from bnbarham/merge-modules
Merge exported modules with the same public name in generated interface
2025-05-05 13:49:12 -07:00
Erik Eckstein
08ce2f00f2 embedded: avoid false error "Deinit of non-copyable type not visible in the current module" in SourceKit
As SourceKit explicitly disables WMO, silence the diagnostic in this case (but leave it enabled for explicit non-WMO builds otherwise).

rdar://150596807
2025-05-05 09:19:08 +02: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
Hamish Knight
54e0607091 [Sema] Add missing null check for Type
`getType` here can return a null type if the queried expression isn't
part of the solution, which can currently happen for code completion.
I'm working on a more principled fix for this, but until then this is
a low-risk fix that will unblock the stress tester and can be
cherry-picked to 6.2.

rdar://149759542
2025-04-23 12:58:28 +01:00
Doug Gregor
851950562d Update test 2025-04-14 23:44:16 -07:00