Commit Graph

91 Commits

Author SHA1 Message Date
Nathan Hawes
388052b6ab [SymbolGraph][CursorInfo] Add option to SourceKit's CursorInfo request to include the SymbolGraph JSON
Adds a new 'key.retrieve_symbol_graph' option to the request. When set to 1 it
includes the JSON for a SymbolGraph containing a single node for the symbol at
the requested position.

This also extends the SymbolGraph library with a new entry point to get a graph
for a single symbol, and to additionally support type substitution to match the
existing CursorInfo behavior (e.g. so that when invoked on `first` in
`Array<Int>().first`, the type is given as `Int?` rather than `Element?`).

Resolves rdar://problem/70551509
2020-12-12 14:38:41 +10:00
Ben Barham
b07c06e839 [Serialization] Fix crashes when allowing compiler errors in modules 2020-11-18 12:35:21 +10:00
Ben Barham
241559dc88 [Serialization] Add an option to output modules regardless of errors
Adds a new frontend option
"-experimental-allow-module-with-compiler-errors". If any compilation
errors occur while generating the .swiftmodule, this mode will skip SIL
entirely and only serialize the (likey invalid) AST.

This existence of this option during generation is serialized into the
resulting .swiftmodule. Errors found in deserialization are only allowed
if it is set.

Primarily intended for IDE requests (eg. indexing and code completion)
to ensure robust cross-module results, despite possible errors.

Resolves rdar://69815975
2020-11-10 14:47:22 +10:00
Mishal Shah
92ca9fc924 [Apple Silicon] Generalize tests for other macOS architectures
Most of the changes fall into a few categories:
* Replace explicit "x86_64" with %target-cpu in lit tests
* Cope with architecture differences in IR/asm/etc. macOS-specific tests
2020-07-02 16:27:46 -07:00
Rintaro Ishizaki
8307c6a95c [SourceKit] Report 'key.reusingastcontext' in completion like requests
'TypeContextInfo' and 'ConformingMethodList'
2020-06-29 10:21:32 -07:00
Nathan Hawes
50dc7d85dd [Driver/SourceKit] Handle filelist driver args in getSingleFrontendInvocationFromDriverArguments
getSingleFrontendInvocationFromDriverArguments is set up to never produce file
lists in the output frontend arguments, but since the driver accepts file lists
as input arguments, this should too.
2020-06-10 10:50:56 -07:00
Ben Langmuir
ffc990f999 [driver/sourcekit] Avoid creating temporary output files in TMPDIR
When producing frontend arguments for sourcekitd, force the output mode
to -typecheck so that we do not create any temporary output files in the
driver. Previously, any sourcekitd operation that created a compiler
invocation would create 0-sized .o file inside $TMPDIR that would never
be cleaned up.

The new swift-driver project handles temporaries much better as
VirtualPath, and should not need this approach.

rdar://62366123
2020-05-18 16:52:41 -07:00
Rintaro Ishizaki
aee280ad65 [SourceKit/Testing] Add %diff as an alias for 'diff --strip-trailing-cr' 2020-04-08 11:23:48 -07:00
Ted Kremenek
39c34c89ee Bump Swift version to 5.3 2020-03-17 13:54:32 -07:00
najacque
32bc769c59 Merge pull request #28603 from najacque/master
bumping swift version number to 5.2
2019-12-06 15:47:10 -08:00
najacque
fe35d4af78 fixing version in test/SourceKit/Misc/compiler_version.swift 2019-12-06 13:51:04 -08:00
Nathan Hawes
b9d5672ca1 [SourceKit] Add a global-configuration request to control SourceKit's behavior around .swiftsourceinfo files
SwiftSourceInfo files provide source location information for decls coming from
loaded modules. For most IDE use cases it either has an undesirable impact on
performance with no benefit (code completion), results in stale locations being
used instead of more up-to-date indexer locations (cursor info), or has no
observable effect (live diagnostics, which are filtered to just those with a
location in the primary file).

For non-IDE clients of SourceKit though, cursor info providing declaration
locations for symbols from other modules is useful, so add a global
configuration option (and a new request to set it) to control whether
.swiftsourceinfo files are loaded or not based on use case (they are loaded by
default).
2019-12-03 13:15:20 -08:00
Mishal Shah
e74c34c6a1 Bumping Swift version number to 5.1.2 2019-11-30 18:39:05 -08:00
Mishal Shah
fff1a39364 [Version] Bump the Swift version to 5.1.1 2019-10-03 14:35:57 -07:00
Brent Royal-Gordon
82928fd821 Merge pull request #24464 from brentdax/charmed-interpolations
[Parse][Sema] Improve interpolation parsing and construction
2019-05-14 17:49:46 -07:00
Ted Kremenek
4beb673b8e Bump compiler version to Swift 5.1 (#24671)
* Bump version to Swift 5.1

* Update tests with compiler version bump

* Undo flatMap and math obsolescences
2019-05-13 07:32:39 -07:00
Brent Royal-Gordon
a4e5bcea6a Move strange interpolation fix to PreCheckExpression
This defers diagnosis until a stage where #if conditions have definitely been evaluated, at the cost of a slightly more complex implementation. We’ll gain some of that complexity back in a subsequent refactoring. Fixes SR-9937.
2019-05-09 15:29:21 -07:00
Jordan Rose
43feb9cbe1 On Apple platforms, use swiftmodule directories for the stdlib (#21797)
This changes the Swift resource directory from looking like

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          x86_64/
            Swift.swiftmodule
            Swift.swiftdoc
            Darwin.swiftmodule
            Darwin.swiftdoc

to

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          Swift.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc
          Darwin.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc

matching the layout we use for multi-architecture swiftmodules
everywhere else (particularly frameworks).

There's no change in this commit to how Linux swiftmodules are
packaged. There's been past interest in going the /opposite/ direction
for Linux, since there's not standard support for fat
(multi-architecture) .so libraries. Moving the .so search path /down/
to an architecture-specific directory on Linux would allow the same
resource directory to be used for both host-compiling and
cross-compiling.

rdar://problem/43545560
2019-02-19 14:47:21 -08:00
Marcelo Fabri
f61751bdcf [SR-9630][SourceKit] Add request to get compiler version 2019-01-20 10:39:25 -08:00
Argyrios Kyrtzidis
4d7ee807da [sourcekitd] Make sure to put '-resource-dir' argument in front to allow overriding it by the passed in arguments
Otherwise, passing a custom '-resource-dir' option will be ignored.
rdar://45764554
2018-11-03 21:55:50 -07:00
Ben Langmuir
4c59e0f40c test/SourceKit/Misc/stats.swift: remove checks that will not be reliable
We already disabled one of these because it failed (extremely) rarely in
CI, but the assumption was that there was a bug. In reality, the
behaviour was correct, so remove the unreliable checks for good and
document why in the test.

rdar://36408114
2018-10-11 11:25:39 -07:00
Rintaro Ishizaki
399fece7f5 [SourceKit] Dedicated error message for 'offset' + 'length' out of range 2018-08-02 09:29:28 +09:00
Rintaro Ishizaki
930d4342cd [SourceKit] Defensive guard for invalid offset and length in edit request
Otherwise, hits assertion, or crashes in no-assertion build.

Added 'EditableTextBuffer::getSize()' for getting size after previous updates
without actually applying them.

rdar://problem/34206143
2018-08-01 20:02:15 +09:00
Ben Langmuir
3fa2df68e3 [sourcekit test] Split -sanitizer= test out and add REQUIRES
This test requires the sanitizer runtime libraries, so split it out and
add the requisite REQUIRES lines.
2018-05-18 17:48:31 -07:00
Ben Langmuir
e9d6a4ddfc [sourcekit] Pass -resource-dir when parsing driver arguments
... instead of overriding it after the driver is done. This improves
the fidelity of anything that looks at the resource directory inside the
driver or frontend argument parsing.  In particular, it fixes an issue
where sourcekit requests would fail if they included the -sanitize=
option because the driver would fail to find the runtime libraries.

Even though this should be *more correct* for all uses, in the
interests of understanding all possible immediate effects of this
change, I manually audited all the code that looks at the resource
directory in between when it is parsed as and argument and when
createCompilerInvocation returns. I claim that the only changes are:
1. The sanitizer library check that we wanted to change
2. The DWARFDebugFlags, which are for IRGen so don't affect SourceKit
3. The Migrator data paths, which also don't affect SourceKit

For now, I put the -resource-dir option at the end of the arguments so
that it overrides any existing option, which mimics how it behaved
before.  We might want to move it to the beginning so that we honour a
user-provided resource directory, but that should be a separate change.

rdar://40147839
2018-05-11 10:28:01 -07:00
Ben Langmuir
b78daf5959 [sourcekitd-test] Add options to repeat a request and ignore its output
This provides a very rudimentary way to check the end-to-end performance
of simple sourcekitd requests. A sample invocation might be

```
sourcekitd-test -time-request -repeat-request=10 -dont-print-response -req= ...
```
2018-04-19 10:46:07 -07:00
Ben Langmuir
94140763da [sourcekitd-test] Add a flag -time-request
Allows simple timing of request. Includes only the time to make the
request and receive the reply, but not any additional deserialization
etc.
2018-04-19 10:43:46 -07:00
Nathan Hawes
0a4204e99f [Driver] Add -driver-filelist-threshold to set the number of inputs beyond which filelists are used
When generating a compiler invocation in driver::createCompilerInvocation()
we end up using filelists if the number of inputs is > 128 (to work around
command line arg limits). We never actually write them out though, and so
fail when parsing the frontend arguments that reference them.

As this function is called frequently by SourceKit and command line limits
aren't a concern here, this patch makes the 128 threshold value configurable
via a new -driver-filelist-threshold option. This is set to its maximum value
in driver::createCompilerInvocation() to ensure filelists aren't used. This
new option makes the existing -driver-use-filelists (that forces filelists to
be used) redundant as it's now equivalent to -driver-filelist-threshold=0.

Resolves rdar://problem/38231888
2018-04-12 05:24:03 -07:00
Saleem Abdulrasool
b67d5f0cf7 test: convert rm -rf && mkdir -p into %empty-directory
This converts the instances of the pattern for which we have a proper
substitution in lit.  This will make it easier to replace it
appropriately with Windows equivalents.
2018-03-06 14:30:54 -08:00
Ben Langmuir
72bde687e4 [sourcekit] Use the driver to parse command line arguments
Stop parsing frontend arguments directly and use the driver instead. The
most intersting part of this change is that it forces us to consider
whether our compiler invocation will have inputs or not.  We have
several kinds of requests that need to create a compiler instance, but
not parse any inputs (interface-generation, doc-info, and indexing when
operating on a module instead of source files).

Incidentally, add an error when trying to do doc-info on multiple source
files. This was already very broken (assertion failures and bogus source
locations), so add an error for it.

rdar://problem/17897287
2018-02-05 15:49:17 -08:00
Ben Langmuir
6311f07b49 [test] Disable part of a test that is failing non-deterministically
Very rarely this test fails with 1 instead of 0 AST-cache hits.
Disabling until it can be investigated and fixed.
2018-01-10 09:42:38 -08:00
Ben Langmuir
d4ae8f611f [sourcekitd] Filter out -v flag
We really need to use the driver for this and stop doing ad-hoc
filtering (rdar://17897287), for for now keep limping along...

rdar://35424741
2017-11-09 11:33:09 -08:00
Ben Langmuir
9c7d9235de [sourcekitd] Add a request to get statistics from the service
... and add a few basic statistics about the number of requests, ASTs
built, etc.  The Statistic type is loosely based on the one from LLVM,
but suitable for using without DEBUG macros and using SourceKit UIdents
to identify the statistic.  The easiest way to add a new statistic is to
add it to SwiftStatistics.def in the SwiftLangSupport.
2017-10-05 12:34:49 -07:00
Argyrios Kyrtzidis
231add1c2e [SourceKit] Ignore the index-store-path flag for the sourcekitd requests
It was active for clang PCH/module creation coming from sourcekitd which was unnecessary index-store data creation.
2017-07-06 11:04:19 -07:00
Félix
042fccb510 Added -help option so sourcekitd-test
Added "-help" option to Options.td
Added also:
* Added "OPT_HELP" case in the main TestOptions.cpp switch. It uses the llvm options help functionality to provide up-to-date help
* Additional "Use -help for assistance" at the end of the error message that appears when calling an unknown option
Added their following tests, respectively::
* usage.swift, and
* wrong_arguments.swift

Extra: FIXME: in TestOptions::printHelp, suggesting a possible expansion for the printHelp option (details in file)
2017-04-22 15:06:48 -03:00
Graydon Hoare
7137bab0c7 [Bridging PCH] Teach SourceKit to ignore the bridging-pch driver options. 2017-02-02 17:07:10 -08:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Argyrios Kyrtzidis
99f691c2cd [test] Add a SourceKit test about the protocol version request. 2016-02-16 10:03:41 -08:00
Argyrios Kyrtzidis
95ee932e0c [SourceKit] For sourcekitd_variant_json_description_copy, make sure to not escape the unicode characters in a string.
Otherwise it will be invalid json.
rdar://24617070
2016-02-15 10:37:56 -08:00
Argyrios Kyrtzidis
943c20dffa [sourcekit] Introduce 'sourcekitd_variant_json_description_copy' for getting a json format out of a variant object.
rdar://24280139
2016-01-22 13:29:32 -08:00