Commit Graph

6605 Commits

Author SHA1 Message Date
Ben Barham
f3a6ce144c Merge pull request #63906 from bnbarham/add-nested-expansion
[Refactor] Allow expanding nested macros
2023-03-02 20:43:35 -08:00
Mishal Shah
e256b56545 Merge branch 'main' into rebranch 2023-03-02 18:25:09 -08:00
Ben Barham
bb7760b9e0 [Refactor] Allow expanding nested macros
This adds a new `primary_file` key, which defaults to `sourcefile`. For
nested expansions, `primary_file` should be set to the containing file
and `sourcefile` to the name of the macro expansion buffer.
2023-03-02 14:04:46 -08:00
Ellie Shin
7d23db3646 Create PackageUnit class, and Package entries to DeclContext / ASTHierarchy
Previously enum AccessLimitKind was
added to distinguish access scopes b/t package and public while keeping
DeclContext null but it proved to be too limiting. This PR creates package specific entries for DeclContext and
ASTHierarchy. It create a new class PackageUnit that can be set as the parent DeclContext of ModuleDecl. This PR
contains addition of such entries but not the use of them; the actual use of them will be in the upcoming PRs.

Resolves rdar://106155600
2023-03-02 13:20:51 -08:00
Andrew Trick
bffe0e7736 Merge pull request #64022 from atrick/ossa-complete-util
[NFC] Add SILGenCleanup::completeOSSLifetimes
2023-03-02 08:53:44 -08:00
Louis D'hauwe
40573adfce Merge pull request #63816 from apple/louisd/sourcekit-inactive-ranges-request
[SourceKit] Add "Active Regions" request
2023-03-02 08:07:45 -08:00
Andrew Trick
2743b83b8e Added option: -enable-ossa-complete-lifetimes
Disabled by default during initial testing.
2023-03-01 21:41:46 -08:00
Louis D'hauwe
876682fb12 [SourceKit] Add "Active Regions" request
`source.request.activeregions` is a new request that reports all
`#if`, `#else` and `#elseif` decls in the response with an `is_active` flag.
This is mainly useful for a client to know which branches are active,
but for completeness sake, the active decls are also reported.

Note: it only reports the positions of the decls, not the entire ranges.
It's up to clients to map this to the syntactic structure of a tree.
Reporting the ranges of the decls could be confusing in the case
of nested `#if`s, where the ranges can overlap.
2023-03-01 14:13:58 -08:00
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
622d0b2aa2 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-28 07:14:26 -08:00
Alex Hoppen
04114bbedd Merge pull request #63711 from ahoppen/ahoppen/completion-token-extract
[swift-ide-test] Use same code completion extraction logic for batch code completion and single code completion
2023-02-28 16:03:27 +01:00
Alex Hoppen
10edbb78f9 [swift-ide-test] Use same code completion extraction logic for batch code completion and single code completion
If the test case hase a code completion token of the form `#^TOKEN?check=CHECK^#` from batch code completion, this allows us to run `swift-ide-test` with `--code-completion-token TOKEN` instead of `--code-completion-token 'TOKEN?check=CHECK'`, which is more convenient.
2023-02-28 10:58:56 +01:00
swift-ci
d44d972171 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-27 15:33:32 -08:00
Rintaro Ishizaki
e490466e62 Merge pull request #63927 from rintaro/macros-mockplugin-lib
[Macros] Add a library to make simple executable plugins for testing
2023-02-27 14:39:00 -08:00
Arnold Schwaighofer
1dfc30eb1f Merge remote-tracking branch 'origin/main' into rebranch 2023-02-27 09:18:56 -08:00
Rintaro Ishizaki
761cbb0ade [Macros] Add a library to make simple executable plugins for testing
Add `_swiftMockPlugin` library.
Usage:
  #include "swift/swift-c/MockPlugin/MockPlugin.h"

  MOCK_PLUGIN([
    {"expect": {...},
     "response: {...}}
  ])
2023-02-26 12:17:24 -08:00
Saleem Abdulrasool
bb8ca27254 sil-opt: introduce -vfsoverlay to support Windows
Add an option to `sil-opt` to pass along VFS overlay files to the clang
importer.  This is required to make the tests pass with the upcoming
work to avoid modifying the Visual Studio installation and instead to
prefer to inject the content via VFS overlays.
2023-02-23 21:11:16 -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
9e40280bda Merge pull request #63738 from bnbarham/macros-everywhere
[AST] Allow ignoring macro expansions
2023-02-17 10:18:56 -08:00
swift-ci
19b4935fd6 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-17 09:14:24 -08:00
Daniel Rodríguez Troitiño
89fec217fb Fix calls to add_custom_target_command (#63740)
`add_custom_target_command` has a note in its documentation that ask for
all the `COMMAND` arguments to immediately follow the first argument, or
the function will misbehave.

In the two cases below, the `COMMAND` arguments were after the `OUTPUT`
multivalue, and ended by mistake inside the `OUTPUT` parameter. This
kinda works because CMake will interpolate those back, but causes
problems for dependency resolution, marking many targets as dirty. When
one of those targets is dependent by the compiler, this can create
a huge cascade rebuild.

Fix the two cases I found where `add_custom_target_command` was used
incorrectly. This removes cascade rebuilds in my working directory, and
hope it applies to everybody.
2023-02-17 09:09:58 -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
abf199ccc0 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-15 17:14:41 -08:00
Ben Barham
959e5bba7e Merge pull request #63666 from bnbarham/fix-new-assert
Fix a couple references to nullptr
2023-02-15 16:59:24 -08:00
swift-ci
5e4d8c4b0c Merge remote-tracking branch 'origin/main' into rebranch 2023-02-15 13:54:12 -08:00
Ben Barham
fd4f51a677 [Test] Only print completion diagnostics when an ASTContext is available
swift-ide-test was creating a `CompilerInstance` and then passing its
`ASTContext` along for printing diagnostics. But `CompilerInstance` only
has an `ASTContext` if it has been initialized, which it hasn't.

Change the print to only print diagnostics when an `ASTContext` is
actually available.
2023-02-15 10:13:59 -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