Commit Graph

2340 Commits

Author SHA1 Message Date
Ben Barham
59afba5bf9 Manually merge branch 'main' into rebranch 2023-03-01 14:13:50 -08:00
Doug Gregor
bd35cdb865 Merge pull request #63985 from DougGregor/expression-macros-effects 2023-03-01 06:52:43 -08:00
Doug Gregor
8f42a5d111 [SourceKit] Don't report DocInfo requests from other buffers 2023-02-28 20:30:51 -08:00
Doug Gregor
7a1c558899 Add more missing ASTWalker macro behavior entries 2023-02-28 19:13:02 -08:00
Joe Groff
6c192018db Merge pull request #63073 from jckarter/se-0377-finalize
Changes to implement the final approved SE-0377 behavior
2023-02-28 18:38:33 -08:00
Doug Gregor
200f2340d9 [Macros] Be deliberate about walking macro arguments vs. expansions
Provide ASTWalker with a customization point to specify whether to
check macro arguments (which are type checked but never emitted), the
macro expansion (which is the result of applying the macro and is
actually emitted into the source), or both. Provide answers for the
~115 different ASTWalker visitors throughout the code base.

Fixes rdar://104042945, which concerns checking of effects in
macro arguments---which we shouldn't do.
2023-02-28 17:48:23 -08:00
QuietMisdreavus
164e93e0a7 Merge pull request #63726 from apple/QuietMisdreavus/skip-proto-impls
[SymbolGraphGen] add new flag to skip "protocol implementation" symbols

rdar://59899968
2023-02-28 10:50:01 -07:00
Joe Groff
1311df6544 AST: Combine various ownership TypeReprs into one OwnershipTypeRepr.
This lets us consolidate code paths that mostly run in parallel over the
existing InOutTypeRepr/SharedTypeRepr/OwnedTypeRepr family of types. This
patch by itself is NFC but makes it easier to introduce new spellings,
particularly the newly-official `borrowing` and `consuming` modifiers
that were approved in SE-0377.
2023-02-28 09:15:43 -08:00
swift-ci
77fa67c3c9 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-23 14:13:27 -08:00
Rintaro Ishizaki
4190cb7978 Merge pull request #63793 from rintaro/macro-plugin-executable
[Macros] Add executable plugin support
2023-02-23 14:02:33 -08:00
swift-ci
c03170213e Merge remote-tracking branch 'origin/main' into rebranch 2023-02-23 09:33:39 -08:00
Ben Barham
f7aaf02065 [SourceKit] Add an optional path and name to refactoring edits
Add two new fields to refactoring edits:
  - A file path if the edit corresponds to a buffer other than the
    original file
  - A buffer name when the edit is actually source of generated buffer

Macro expansions allow the former as a macro could expand to member
attributes, which may eg. add accessors to each member. The attribute
itself is inside the expansion, but the edit is to the member in the
original source.

The latter will later allow clients to send requests with these names to
allow semantic functionality inside synthesized buffers.
2023-02-22 16:24:02 -08:00
Rintaro Ishizaki
0e31393024 [Macros] Add executable plugin support
Executable compiler plugins are programs invoked by the host compiler
and communicate with the host with IPC via standard IO (stdin/stdout.)
Each message is serialized in JSON, prefixed with a header which is a
64bit little-endian integer indicating the size of the message.

* Basic/ExecuteWithPipe: External program invocation. Lik
  llvm::sys::ExecuteNoWait() but establishing pipes to the child's
  stdin/stdout
* Basic/Sandbox: Sandboxed execution helper. Create command line
  arguments to be executed in sandbox environment (similar to SwiftPM's
  pluging sandbox)
* AST/PluginRepository: ASTContext independent plugin manager
* ASTGen/PluginHost: Communication with the plugin. Messages are
  serialized by ASTGen/LLVMJSON

rdar://101508815
2023-02-22 10:22:14 -08:00
Victoria Mitchell
7ed30c92af refactor: stop populating SymbolGraphOptions at creation 2023-02-17 11:19:38 -07:00
swift-ci
5b31313bf3 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-17 10:19:17 -08:00
Ben Barham
0c3f538822 [AST] Allow ignoring macro expansions
Various requests expect to be walking over the current source file.
While we could add checks to all these to skip decls outside of the
current buffer, it's a little nicer to handle this during the walk
instead.

Allow ignoring nodes that are from macro expansions and add that flag to
the various walks that expect it.

Also add a new `getOriginalAttrs` that filters out attributes in
generated source.
2023-02-16 18:04:56 -08:00
swift-ci
5e4d8c4b0c Merge remote-tracking branch 'origin/main' into rebranch 2023-02-15 13:54:12 -08:00
Alex Hoppen
ee26b4b299 [SourceKit] Pass ResolvedCursorInfo as shared pointer instead of by value
This allows us to model the `ResolvedCursorInfo` types as a proper type hierarchy instead of having to store all values in the base `ResolvedCursorInfo` type.

rdar://102853071
2023-02-14 22:40:45 +01:00
swift-ci
aeb1872cb6 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-13 13:13:20 -08:00
Doug Gregor
d8e5cd91b4 Merge pull request #63625 from DougGregor/sourcekit-related-id-checker
Teach the related-id checker to ignore things from other buffers
2023-02-13 12:57:05 -08:00
Doug Gregor
a712c37c05 Teach the related-id checker to ignore things from other buffers 2023-02-13 10:13:39 -08:00
swift-ci
bf95105191 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-13 00:14:19 -08:00
swift-ci
e80f571e71 Merge pull request #63608 from DougGregor/sourcekit-no-crash-macro-locations
Don't annotate entities not in the primary buffer
2023-02-13 00:07:40 -08:00
Doug Gregor
b87dfdf2ae Don't annotatae entities not in the primary buffer 2023-02-12 21:42:36 -08:00
swift-ci
24664a80d2 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-12 04:13:12 -08:00
swift-ci
f5488c5351 Merge pull request #63601 from DougGregor/sourcekit-macro-buffer-loc
[SourceKit] Disable optimization that's now incorrect with macros.
2023-02-12 04:04:31 -08:00
swift-ci
0f633ce557 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-11 22:54:15 -08:00
Ben Barham
e15ea7ae4d Merge pull request #63403 from bnbarham/so-much-re-index
[Index] Prevent re-indexing system modules repeatedly
2023-02-11 22:40:47 -08:00
Doug Gregor
642d0e9d36 [SourceKit] Disable optimization that's now incorrect with macros.
No test case at the moment, but it's pretty crashy here in practice :)
2023-02-11 19:56:07 -08:00
swift-ci
8c038a1802 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-11 15:34:18 -08:00
Doug Gregor
7ea0e3f096 Switch GeneratedSourceInfo ranges over to CharSourceRange.
Macro expansion buffers, along with other generated source buffers,
need more precise "original source ranges" that can be had with the
token-based `SourceRange`. Switch over to `CharSourceRange` and provide
more thoughtfully-determined original source ranges.
2023-02-11 11:23:26 -08:00
swift-ci
ff3132c75c Merge remote-tracking branch 'origin/main' into rebranch 2023-02-10 07:55:59 -08:00
Ben Barham
6269643b4d [Index] Prevent re-indexing system modules repeatedly
If a module was first read using the adjacent swiftmodule and then
reloaded using the swiftinterface, we would do an up to date check on
the adjacent module but write out the unit using the swiftinterface.
This would cause the same modules to be indexed repeatedly for the first
invocation using a new SDK. On the next run we would instead raad the
swiftmodule from the cache and thus the out of date check would match
up.

The impact of this varies depending on the size of the module graph in
the initial compilation and the number of jobs started at the same time.
Each SDK dependency is re-indexed *and* reloaded, which is a drain on
both CPU and memory. Thus, if many jobs are initially started and
they're all going down this path, it can cause the system to run out of
memory very quickly.

Resolves rdar://103119964.
2023-02-09 11:49:13 -08:00
Alex Hoppen
fcc5d98f1c [CursorInfo] Deliver results from solver-based cursor info
Running the SourceKit stress tester with verification of solver-based cursor info returned quite a few differences but in all of them, the old AST-based implementation was actually incorrect. So, instead of verifying  the results, deliver the results from solver-baesd cursor info and only fall back to AST-based cursor info if the solver-based implementation returned no results.

rdar://103369449
2023-02-07 14:53:54 +01:00
Alex Hoppen
6ee695a395 [CursorInfo] Implement a few expression references as solver-based
This implements cursor info resolving for a few expression types using the constraint system. This allows us to detect ambiguous results – we cannot deliver them yet but that will be done in a follow-up PR.
2023-02-07 10:42:00 +01:00
swift-ci
1a8ead7280 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-06 05:53:34 -08:00
Alex Hoppen
a5f85ee10c [SourceKit] Make sure we reuse ASTContext in function bodies for solver-based cursor info
The main problem that prevented us from reusing the ASTContext was that we weren’t remapping the `LocToResolve` in the temporary buffer that only contains the re-parsed function back to the original buffer. Thus `NodeFinder` couldn’t find the node that we want to get cursor info for.

Getting AST reuse to work for top-level items is harder because it currently heavily relies on the `HasCodeCompletion` state being set on the parser result. I’ll try that in a follow-up PR.

rdar://103251263
2023-02-02 22:03:25 +01:00
Alex Hoppen
ac3f9f85a0 [sourcekitd-test] Don't cache memory buffers
If we cache the buffers between multiple requests we don’t pick up if the source file has changed on disk since we last read it.
2023-02-02 22:03:25 +01:00
Alex Hoppen
d87700d746 [sourcekitd-test] Flush stdout and stderr before executing a shell command
Otherwise the order of sourcekitd-test’s output and the shell command is undefined.
2023-02-02 22:03:25 +01:00
Alex Hoppen
04d44bfc04 [SourceKit] Sort ReferencedDecls when printing them
This assures stable sort order when comparing solver-based and AST-based results.
2023-02-02 22:03:25 +01:00
swift-ci
ca7768ea0a Merge remote-tracking branch 'origin/main' into rebranch 2023-02-01 23:53:39 -08:00
Alex Hoppen
7811519152 [SourceKit] Only verify the solver-based cursor info implementation if requested
This allows us to mark expected deviations between the AST-based and the solver-based implementation in the stress tester as XFails without breaking actual clients

We always verify if a cursor info request is issued through `sourcekitd-test`.
2023-01-31 21:25:51 +01:00
swift-ci
791d160814 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-26 10:34:25 -08:00
Ben Barham
3ec878d918 Update llvm::Optional API uses
Use the std-equivalent names as the LLVM ones are now deprecated
(eventually `llvm::Optional` will disappear):
  - `getValue` -> `value`
  - `getValueOr` -> `value_or`
  - `hasValue` -> `has_value`

Follow up from ab1b343dad and
7d8bf37e5e with some missing cases.
2023-01-25 16:28:10 -08:00
swift-ci
e0b16dbdf4 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-25 16:07:15 -08:00
Ben Barham
4cc7167b60 [Index] Handle shorthand if let/closure captures in local rename
Update rename to pull the outermost-declaration so that references are correctly found.

Rather than keeping suppressed locations in the current parent, keep
them for the whole index. Local rename starts the lookup from the
innermost context it can, which could be a closure. In that case there
is no parent decl on the stack and thus no where to store the locations
to suppress. We could have a specific store for this case, but there
shouldn't be that many of these and they're relatively cheap to store
anyway.

Resolves rdar://104568539.
2023-01-24 11:10:38 -08:00
swift-ci
2e477fd38b Merge remote-tracking branch 'origin/main' into rebranch 2023-01-20 14:13:44 -08:00
Ellie Shin
91f785441f Merge pull request #62652 from apple/es-pkg-acl
[NFC] Add 'package' access modifier to AccessLevel
2023-01-20 13:58:15 -08:00
swift-ci
9a179511d9 Merge remote-tracking branch 'origin/main' into rebranch 2023-01-20 09:42:15 -08:00
Ellie Shin
37af51dc4c Merge branch 'main' into es-pkg-acl 2023-01-19 16:18:17 -08:00