Commit Graph

2134 Commits

Author SHA1 Message Date
Alexander Cyon
bda8314044 Update test/SourceKit/CodeComplete/complete_typerelation.swift.convertible.response
Co-authored-by: Ben Barham <b.n.barham@gmail.com>
2024-07-08 20:32:48 +02:00
Alexander Cyon
10447c32d2 [test/SourceKit] Fix typos 2024-07-06 13:28:59 +02:00
Hamish Knight
f26d1e7bd3 [Index] Mark accessors as implicit in modules
These won't have bodies in generated interfaces,
and generally aren't useful things to jump to. The
property ought to be used instead.

rdar://130775560
2024-07-05 16:28:33 +01:00
Hamish Knight
9da87d1b1c [CursorInfo] Resolve solver-based in VarDecls
Previously we would skip resolving any solver-based
cursor info in a VarDecl accessor as the VarDecl
source range does not encompass the AccessorDecl.
Avoid looking at the VarDecl source range in this
case.

rdar://131135631
2024-07-04 22:49:46 +01:00
Erik Eckstein
9360c76cd8 Fix a SourceKitCrash in the VTableSpecializer pass
Replace the assert-check if a vtable is available with a regular error message.
This cannot occur in regular builds - only if built with embedded swift and without wmo.
The command line compiler prevents this combination, but it  can happen in SourceKit.

rdar://130167087
2024-07-03 17:13:53 +02:00
Hamish Knight
eeced060fa [Parse] Handle #if in brace skipping logic
Previously we would strictly match `{` + `}`, but
that ignored the fact that when parsing we consider
`#if` + `#endif` to be a stronger delimiter than
`{` + `}`, so can ignore a stray `}` in a `#if`.
Update the logic to also track opening and closing
`#if` decls, ignoring any braces that happen within
them.

rdar://129195380
2024-06-19 21:39:40 +01:00
Hamish Knight
fe8289c516 Merge pull request #74479 from hamishknight/no-completion-usr-for-local
[Completion] Don’t generate USRs for local decls
2024-06-18 01:26:10 +01:00
Hamish Knight
ddd1bde60e [Completion] Don’t generate USRs for local decls
Doing so can cause issues since we cannot guarantee
that e.g any parent closures have been type-checked.

rdar://128294522
2024-06-17 22:20:57 +01:00
Hamish Knight
5ec4d1cc98 [CS] Fill in ErrorTypes for expressions that fail to type-check
Ensure we always produce typed AST, even if we
fail to apply a solution. This fixes a cursor info
issue where we'd to type-check a closure twice
due to it not having a type set.

rdar://129417672
2024-06-17 17:58:52 +01:00
Slava Pestov
b14563f8e8 Merge pull request #74201 from slavapestov/macro-expansion-mangling
Change macro expansion mangling to avoid request cycles
2024-06-14 01:41:45 -04:00
Slava Pestov
9793f77daa AST: New mangling for expansion locations to avoid request cycles
Fixes rdar://127078338.
2024-06-13 17:45:30 -04:00
Alex Hoppen
f5d15f4f60 Merge pull request #74241 from ahoppen/enum-case-rename
Fix renaming enum case parameters with unnamed associated arguments
2024-06-12 14:46:46 -07:00
Alex Hoppen
155773c38e Fix renaming enum case parameters with unnamed associated arguments
We treated enum case parameters the same way as function parameters and weren’t considering that they can be unlabeled. That caused us to insert eg. `_ ` in front of the case’s type, producing `case myCase(_ String)`, which is invalid. When we are inside an enum case parameter and the parameter label is empty, treat it the same as a function call, which will leave the label untouched if it isn’t modified and insert a label including a colon if a new label is introduced.

https://github.com/apple/sourcekit-lsp/issues/1228
2024-06-11 19:18:59 -07:00
Hamish Knight
d98cb9e2b3 [Mangler] Mangle function type for invalid enum element
Previously we would mangle a single ErrorType as
the type for the element, but that would fail to
demangle since we expect a function type. Use the
same logic as AbstractFunctionDecl, mangling a
function type of ErrorType. While here, also
handle SubscriptDecls and check for error types
rather than `isInvalid()`.

rdar://129065620
2024-06-11 21:24:11 +01:00
Alex Hoppen
2e3d42ee0a Merge pull request #74080 from ahoppen/dynamic-cursor-info-on-decl
[SourceKit] Mark overridable declarations as dynamic
2024-06-03 09:37:45 -07:00
Alex Hoppen
a38e7cce49 [SourceKit] Mark overridable declarations as dynamic
We only set `isDynamic` to `true` if we were inside an expression. Also set `isDynamic` when we are performing cursor info at an overridable declaration. This allows jump-to-definition to jump to declarations that override the one that we performed cursor info on.

rdar://128300752
2024-06-01 22:59:38 -07:00
Alex Hoppen
ccdd62038a [SourceKit] Don’t set DisableModulesValidateSystemDependencies to true
It appears that a6ebd3083d changed the behavior of `-fno-modules-validate-system-headers` (aka. `DisableModulesValidateSystemDependencies`) in conjunction with `-fmodules-validate-once-per-build-session`: Before that change, `-fno-modules-validate-system-headers` needed to be passed for `-fmodules-validate-once-per-build-session` to have any effect (we were always validating system dependencies if `-fno-modules-validate-once-per-build-session` was not set). After the change, `-fno-modules-validate-once-per-build-session` causes system dependencies to never be validated, independent of the build session timestamp.

This change should have no effect on Xcode because it adds `-fmodules-validate-system-headers` to the compiler arguments for Swift files, which overrides `SearchPathOpts.DisableModulesValidateSystemDependencies = true;`
2024-05-31 16:00:26 -07:00
Doug Gregor
2388acdfd3 [SE-0415] Enable function body macros by default
Preamble macros are *not* part of the revised SE-0415, so leave them
experimental.

Tracked by rdar://119687390.
2024-05-20 22:08:33 -07:00
Pavel Yaskevich
b3ea46a955 Merge pull request #73314 from saehejkang/update-c-style-for-stmt-removed-string
[Diagnostics-Qol]: Update c_style_for_stmt_removed error string
2024-05-16 23:57:33 -07:00
Alex Hoppen
39886be6a3 Merge pull request #73468 from ahoppen/related-idents-of-invalid-decls-with-same-base-name
[RelatedIdents] Fix an assertion failure if two invalid declarations have the same base name
2024-05-08 15:25:25 -07:00
Alex Hoppen
743d29ced3 Merge pull request #73473 from ahoppen/import-extern-c-from-bridging-header
[ClangImporter] Import `extern "C"` declarations from the bridging header
2024-05-08 15:06:30 -07:00
Alex Hoppen
9fdbb86cbd [ClangImporter] Import extern "C" declarations from the bridging header
We do iterate into extern C declarations when building the Swift lookup table during PCH generation.

0fad799f51/lib/ClangImporter/SwiftLookupTable.cpp (L2140-L2146)

However, we don’t import `extern "C"` declarations while parsing the bridging header (eg. when no `-pch-output-dir` is specified during code completion). This caused us to miss functions annotated as `extern "C"` in code completion.

rdar://127512985
2024-05-08 11:01:21 -07:00
Alex Hoppen
1a67c61d19 [RelatedIdents] Fix an assertion failure if two invalid declarations have the same base name
For example, the following declarations have the same USR with a single ERROR_TYPE parameter despite being distinct declarations.

```swift
func bar(body: Invalid) {}
func bar(ignoreCase: Bool, body: Invalid) {}
```

We originally intended to check the USR so that local rename behaves more like global rename, which also looks symbols up by USR. But the above example proves that assumption wrong.

rdar://126803702
2024-05-07 18:17:11 -07:00
Alex Hoppen
cae8298408 Merge pull request #73467 from ahoppen/assertion-failure-completing-in-single-quote-string-literal
[Lexer] Fix an assertion failure when invoking code completion inside a single-quoted string literal
2024-05-07 07:15:01 -07:00
Alex Hoppen
0c24f3f71c [Lexer] Fix an assertion failure when invoking code completion inside a single-quoted string literal
rdar://126924962
2024-05-06 15:25:00 -07:00
Rintaro Ishizaki
6264792d19 [SourceKit] Don't use SourceEntitityWalker for placeholder expansion
Placeholder expansion should be a syntactic operation, but
`SourceEntityWalker` can invoke type checking operations, which causes
unexpected bahaviors including crashes.

rdar://121360941`
2024-05-02 11:52:13 -07:00
saehejkang
28353765f3 [Diagnostics-Qol]: update c_style_for_stmt_removed error string 2024-04-27 22:35:54 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
fummicc1
4dda7efc0f [AST] Improve diagnostics message for swift users.
Use `initializer` instead of `constructor` because it is more official word to express its meaning.
2024-03-27 12:32:25 +09:00
Rintaro Ishizaki
7b3738d1d0 [SourceKit] Adjust newlines between decls
Previously, Clang modules didn't have empty lines between top-level
decls. This was inconsistent with Swift module.
2024-03-25 22:07:50 +09:00
Rintaro Ishizaki
b019fd0c1b Merge pull request #72420 from rintaro/sourcekit-clang-printer-rdar93731287
[SourceKit] Stop printing normal comments in clang generated interface
2024-03-25 17:29:45 +09:00
Alex Hoppen
5ae1834e59 Merge pull request #72370 from ahoppen/ahoppen/decl-cursor-info-from-solution
[SourceKit] Allow generation of cursor info for declarations from solutions that haven’t aren’t applied to the AST
2024-03-22 08:24:58 +01:00
Rintaro Ishizaki
c9785d955d [SourceKit] Stop printing normal comments in clang generated interface
Generated interfaces for Clang modules used to try printing normal
comments between decls extracted from the header text. That was because
doc-comment was not common in C/ObjC headers. But mainly because of
"import as member feature" Clang decls aren't printed in the order as
they appear in the header file, the logic determinig which comment
belongs to which decl was not working property. We've decided to remove
that feature and only print the proper doc-comments as it has been
getting common.

rdar://93731287
2024-03-21 11:52:32 +09:00
Alex Hoppen
ef3e1c1d4f [SourceKit] Allow generation of cursor info for declarations from solutions that haven’t aren’t applied to the AST ye
This has two benefits:
1. We can now report ambiguous variable types
2. We are more robust in the generation of results for declarations inside closures. If the closure has an error, we won’t apply the solution to the AST and thus any cursor info that tried to get types out of the AST would fail.

rdar://123845208
2024-03-20 14:52:39 +01:00
Ben Barham
9188fbb745 [Test] Disable flakey test
This seems to be failing more regularly now and is often blocking CI.
Disable for now while we investigate.
2024-03-19 10:50:46 -07:00
Karoy Lorentey
4b1477cc2c [test] Update tests for new stdlib 2024-03-18 11:08:32 -07:00
Rintaro Ishizaki
2abddcb260 [SourceKit] Use recored #if regions in "active regions" request
* Record each IfConfig clause location info in SourceFile
* Update SILProfiler to handle them
* Update SwiftLangSupport::findActiveRegionsInFile() to use the recorded
  regions instead of walking into AST to find #if regions

rdar://118082146
2024-03-14 08:52:57 +09:00
cui fliter
127077b3aa chore: fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 17:23:22 +08:00
Holly Borla
683f681514 Merge pull request #72037 from hborla/global-actor-cursor-info
[Concurrency] Never skip global actor attributes in the ASTPrinter.
2024-03-02 10:21:34 -08:00
Holly Borla
ba76c3c11b [Concurrency] Never skip global actor attributes in the ASTPrinter.
Custom attributes like global actors carry crucial semantic information
and should never be suppressed in the ASTPrinter. In particular,
`printQuickHelpDeclaration()` sets `PrintImplicitAttrs` to false,
but it's important for quick help / cursor info to include global
actors.
2024-03-01 22:23:51 -08:00
Slava Pestov
78df826169 Merge pull request #72020 from slavapestov/ncgenerics-fixes-7
Non-copyable generics fixes
2024-03-01 20:48:17 -05:00
Alex Hoppen
0250603131 Merge pull request #71877 from ahoppen/ahoppen/better-formatting
[SourceKit] Test adjustments for improved formatting in BasicFormat
2024-03-01 14:04:49 -08:00
Hamish Knight
1f115adef5 Merge pull request #72009 from hamishknight/another-attr-fix
[Parse] Fix a couple more attribute SourceRanges
2024-03-01 17:37:14 +00:00
Slava Pestov
a535948e3b AST/SourceKit: Fix printing of inheritance clauses (sort of)
This still needs a lot more cleanup.
2024-03-01 12:19:15 -05:00
Alex Hoppen
c18c7a610c Merge pull request #72003 from ahoppen/ahoppen/print-compilerargs-last
[SourceKit] Print compilerargs and sourcetext keys last
2024-03-01 06:54:14 -08:00
Hamish Knight
5d39788331 [Parse] Fix a couple more attribute SourceRanges 2024-03-01 12:23:49 +00:00
Alex Hoppen
b11ab28295 Merge pull request #71966 from ahoppen/ahoppen/dont-rename-textual-code-results
[SourceKit] Only report textual results inside comments and strings from syntactic rename ranges
2024-02-29 20:58:39 -08:00
Alex Hoppen
7ce41252e7 [SourceKit] Print compilerargs and sourcetext keys last
That way, when the request gets truncated by os_log in sourcekit-lsp, we see most of the request. Most likely the sourcetext and the compiler args wouldn't have made it into the log message completely anyway.

rdar://121322828
2024-02-29 20:45:55 -08:00
Alex Hoppen
63aeedecbd [SourceKit] Only report textual results inside comments and strings from syntactic rename ranges 2024-02-29 15:37:29 -08:00
Hamish Knight
cbcfb37f96 [Parse] Fix a couple of SourceRanges
These should point to the last token of the
attribute, not the token that follows.

rdar://123405070
2024-02-28 22:21:43 +00:00