Commit Graph

188 Commits

Author SHA1 Message Date
Joe Groff
7d54810b92 Revert "[SourceKit] Fail requests when an error occurs" 2019-05-22 15:18:28 -07:00
Argyrios Kyrtzidis
729a9558e8 Merge pull request #24124 from DavidGoldman/master
[SourceKit] Fail requests when an error occurs
2019-05-22 10:49:42 -07:00
David Goldman
1c819820fa Comment and sourcekitd-test fixes 2019-05-21 10:40:22 -04:00
Rintaro Ishizaki
d3d30ee246 [Serialization] Support Swift only system module
Previously 'isSystemModule()' returns true only if the module is:
- Standard library
- Clang module and that is `IsSystem`
- Swift overlay for clang `IsSystem` module

Now:
- Clang module and that is `IsSystem`; or
- Swift overlay for clang `IsSystem` module
- Swift module found in either of these directories:
  - Runtime library directoris (including stdlib)
  - Frameworks in `-Fsystem` directories
  - Frameworks in `$SDKROOT/System/Library/Frameworks/` (Darwin)
  - Frameworks in `$SDKROOT/Library/Frameworks/` (Darwin)

rdar://problem/50516314
2019-05-08 17:03:06 -07:00
David Goldman
a3a4d2d22b Add InternalDiagnostic to CursorInfoData and NameTranslatingInfo 2019-05-03 11:01:22 -04:00
David Goldman
10ecea6269 [SourceKit] Fail requests when an error occurs
Previously, requests would fail silently by returning an empty struct
in the response.

With this change, responses will properly report fail with the internal
error.
2019-05-03 11:01:21 -04:00
Gwen Mittertreiner
7da91d5aeb Fix SourceKit/CursorInfo Tests on Windows 2019-04-22 15:55:55 -07:00
Ben Langmuir
40df0c4c5a Remove unnecessary check from cursor info keypath member lookup test
This test baked in an incorrect USR from a bug that has since been
fixed. But we don't really need to check this anyway, so remove it.
2019-04-17 09:36:40 -07:00
Ben Langmuir
effab8c522 Handle dynamic member lookup in annotation and cursor info
Ensure the various entity walkers handle the implicit subscript
reference correctly (usually by ignoring it) and fall through to the
underlying declarations.

rdar://49028895
2019-04-16 15:37:32 -07:00
Michael Gottesman
7b0d8455ca [ast][silgen] Wire up the case body var decls and use them in SILGenPattern emission to fix the evil fallthrough bug.
rdar://47467128
2019-04-03 23:51:06 -07:00
Slava Pestov
75673f1d90 AST: Fix mangling of entities in subscript context
For now, this means USRs of ParamDecls. Soon, default argument generators
for subscripts will need this too.

Fixes <https://bugs.swift.org/browse/SR-8660>, <rdar://problem/44435221>.
2019-04-02 19:51:41 -04:00
Nathan Hawes
20733bad08 Merge pull request #23144 from nathawes/cursorinfo-parseable-interface-tests
[sourcekitd][test] Test CursorInfo works correctly with modules loaded via a parseable interface
2019-03-22 18:29:48 -07:00
Nathan Hawes
6150fbea67 [sourcekitd][test] Test CursorInfo works correctly with modules loaded via a parseable interface 2019-03-22 11:02:17 -07:00
Nathan Hawes
e568d97e72 [sourcekitd][CursorInfo] Make sure we handle the implict VarDelcs being introduced in CastStmt bodies
When CursorInfo finds a reference to a VarDecl that's implicit but has a parent
VarDecl (according to VarDecl::getParentVarDecl), act as if we found the parent
instead.
2019-03-20 14:38:08 -07:00
Xi Ge
1625bcfbba ASTPrinter: skip underscored keyword when printing for quick helps.
rdar://47777848
2019-03-13 17:53:51 -07:00
Slava Pestov
3dc5ae36a6 SourceKit: Use Demangle::getTypeDeclForUSR() to implement 'CursorInfo for USR' request
Fixes <rdar://problem/47819208>.
2019-02-22 16:13:03 -05:00
Xi Ge
2cc3a2704b [test] Add -target %target-triple to sourcekitd-test invocation 2019-02-15 12:28:16 -08:00
Xi Ge
b4c224966b Re-apply "sourcekitd/test: add an interface grouping test for user module." 2019-02-15 11:20:01 -08:00
Ben Langmuir
f1803c87a9 Revert "sourcekitd/test: add an interface grouping test for user module." 2019-02-15 08:26:41 -08:00
Xi Ge
38691236aa sourcekitd/test: add test for cursor-info returning group name for user modules 2019-02-14 14:03:57 -08:00
Slava Pestov
d0c7b1547e ASTMangler: Mangle sugared types for the debugger
Fixes <rdar://problem/48004306>.
2019-02-13 19:17:25 -05:00
Nathan Hawes
c3723fd4d7 [sourcekitd][AST] Fix CursorInfo crash on method with unresolved default value
When printing its annotated decl, we would would assume the param's default
value is present if the default value kind was "Normal". The type checker
explicitly sets the default value to nullptr if it doesn't type check though, so
we were crashing for that case. Added the check.

Resolves rdar://problem/46694149
2018-12-21 18:13:53 -08:00
Ben Cohen
ae6f5dd604 [stdlib] Add consuming/owned annotations to Collection implementations (#19360)
* Add consuming/owned annotations to Collection implementations

* Update SILOptimizer tests

* Fix access_marker_verify test

* XFAIL reconstruct_type_from_mangled_name
2018-09-21 12:06:56 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Jordan Rose
63cd1258ea Stop using SourceManager::getBufferIdentifierForLoc to find buffer IDs
The right way is findBufferContainingLoc. getBufferIdentifierForLoc is
both slower and wrong in the presence of #sourceLocation.

I couldn't come up with a test for the change in IDE/Utils.cpp because
refactoring still seems to be broken around #sourceLocation. I'll file
bugs for that.
2018-08-29 11:46:41 -07:00
Rintaro Ishizaki
baa690306d [IDE] Fix a crasher in SynthesizedExtensionAnalyzer
Count inheritance by 'getInheritedForPrinting()' (align with ASTPrinter).

rdar://problem/41593893
2018-08-16 20:09:44 +09:00
Jordan Rose
0e10f89964 Preserve default argument text through serialization (#18579)
This allows us to dump it in the generated interface, though it's
still not syntax-highlighted. This is necessary for textual module
interfaces, but it's also just a longstanding request for Xcode's
"Generated Interface" / "Jump to Definition" feature.

rdar://problem/18675831
2018-08-09 11:06:22 -07:00
Rintaro Ishizaki
7ca7e4459d [IDE] Fix asstion failure when querying cursor info in defer statement body
If walking into body of defer statement returns nullptr, it indicates
*cutting-off* walking. Previously there was wrong assertion where it
must be unmodified, non-nullptr return.

rdar://problem/41100570
2018-07-25 08:33:46 +09:00
Doug Gregor
a3e03fae1b [Type checker] Make sure 'dynamic' gets set consistently.
'dynamic' is inherited and only applies to '@objc' entities.

The SourceKit test change is because we've changed our behavior
slightly: we won't infer @objc from an override unless the override is
correctly marked with 'override'. This is part of breaking up
dependencies, and should have little effect outside of tests.
2018-07-03 21:47:59 -07:00
John Fairhurst
32b04b8405 [ASTPrinter] Fix raw string enum cases with unicode scalars 2018-05-16 10:52:48 +01:00
Ben Langmuir
9496c63edc Merge pull request #15918 from johnfairh/typealias-where
[ASTPrinter] Print typealias generic requirements
2018-04-25 09:57:05 -07:00
Rintaro Ishizaki
7c7a7ab47c [ASTMangler] Allow to mangle any generic decl type
More specifically, generic `typealias` type.
For instance:

    typealias Pair<T, T> = (T, T)
    typealias PairAlias = Pair

Interface type of `PairAlias` is `Pair.Type`, not `(T, T).Type`
Fixes crash in sourcekit cursorinfo.

rdar://problem/34348776
2018-04-19 18:10:25 +09:00
John Fairhurst
6e38a636aa [ASTPrinter] Print typealias where clause 2018-04-14 12:04:29 +01:00
Robert Widmann
03580d2fe5 Add a parameter list to EnumElementDecl
This models, but does not plumb through, default arguments.
2018-03-28 00:05:56 -04:00
Nathan Hawes
17a6ef5c6e Clear any LLVMArgs when initializing the CompilerInvocation for SourceKit's ASTManager
SourceKit doesn't use them and if any unrecognised LLVM options are
passed to llvm::cl::ParseCommandLineOptions() it calls exit(), bringing
down SourceKit.

Also use fprintf instead of llvm::errs() in Logging.cpp as it uses a
global C++ object that had already been destructed when logging the
above failure.

Resolves rdar://problem/38314383
2018-03-09 18:56:57 -08:00
Nathan Hawes
743d3a5f44 Merge pull request #14980 from nathawes/rdar37905156-rename-init-gives-empty-categorised-edit-ranges
[refactoring] Avoid producing empty string/comment categorized edit ranges when renaming init. Also disallow renaming inits with no arguments.
2018-03-06 15:40:22 -08:00
Rintaro Ishizaki
18e0a5ce36 [SourceKit] Disable invalid_offset.swift on Linux (#15005)
This test seems occasionally fail on Linux.
Disable it while we investigate it.
2018-03-06 11:53:22 +09:00
Nathan Hawes
91ec9982a8 [refactoring] Avoid producing empty categorised edit ranges when renaming init. Also disallow renaming inits with no arguments. 2018-03-05 18:38:35 -08:00
Rintaro Ishizaki
3f232e753b [SourceKit] Add defensive guard for invalid offset
Invalid offset used to cause a inifinite loop in Lexer in some race
condition.

This is a quick fix until we fix underlying problem in SourceKit.
2018-02-27 18:14:52 +09:00
Ben Langmuir
c03533314d Merge pull request #14366 from benlangmuir/sourcekit-driver
[sourcekit] Use the driver to parse command line arguments
2018-02-06 10:16:28 -08:00
Arnold Schwaighofer
d981bb1d96 Mangling: noescape functions will be trivial and no longer compatible with escape function types.
Mangle escapeness as part of the type.

Part of:
SR-5441
rdar://36116691
2018-02-06 08:51:43 -08:00
Ben Langmuir
368e25ec05 [sourcekit] Fix tests that depend on accepting frontend arguments
These tests were relying on sourcekitd parsing as frontend instead of
using the driver.  Update them now to avoid churn when we fix command
line argument parsing in sourcekit.

The changes from clang-importer-sdk to clang-importer-sdk-nosource -I %t
are because clang-importer-sdk implies using -enable-source-import.
Rather than hack them up to use -Xfrontend, it is cleaner to just stop
using source import at all for these tests.  Incidentally, this improved
fidelity in a few places.  When using the generated swift modules we
also need to pass a target triple to sourcekit, which exposed some tests
that had mac-specific data.  This is a systemic issue for sourcekit
tests, but for now just make those few specific tests that we had
problems with run only on mac.
2018-02-05 10:09:03 -08:00
Mark Lacey
f08823757a IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>.
Stop creating ImplicitlyUnwrappedOptional<T> so that we can remove it
from the type system.

Enable the code that generates disjunctions for Optional<T> and
rewrites expressions based on the original declared type being 'T!'.

Most of the changes supporting this were previously merged to master,
but some things were difficult to merge to master without actually
removing IUOs from the type system:
- Dynamic member lookup and dynamic subscripting
- Changes to ensure the bridging peephole still works

Past commits have attempted to retain as much fidelity with how we
were printing things as possible. There are some cases where we still
are not printing things the same way:
- In diagnostics we will print '?' rather than '!'
- Some SourceKit and Code Completion output where we print a Type
  rather than Decl.

Things like module printing via swift-ide-test attempt to print '!'
any place that we now have Optional types that were declared as IUOs.

There are some diagnostics regressions related to the fact that we can
no longer "look through" IUOs. For the same reason some output and
functionality changes in Code Completion. I have an idea of how we can
restore these, and have opened a bug to investigate doing so.

There are some small source compatibility breaks that result from
this change:
- Results of dynamic lookup that are themselves declared IUO can in
  rare circumstances be inferred differently. This shows up in
  test/ClangImporter/objc_parse.swift, where we have
    var optStr = obj.nsstringProperty
  Rather than inferring optStr to be 'String!?', we now infer this to
  be 'String??', which is in line with the expectations of SE-0054.
  The fact that we were only inferring the outermost IUO to be an
  Optional in Swift 4 was a result of the incomplete implementation of
  SE-0054 as opposed to a particular design. This should rarely cause
  problems since in the common-case of actually using the property rather
  than just assigning it to a value with inferred type, we will behave
  the same way.
- Overloading functions with inout parameters strictly by a difference
  in optionality (i.e. Optional<T> vs. ImplicitlyUnwrappedOptional<T>)
  will result in an error rather than the diagnostic that was added
  in Swift 4.1.
- Any place where '!' was being used where it wasn't supposed to be
  allowed by SE-0054 will now treat the '!' as if it were '?'.
  Swift 4.1 generates warnings for these saying that putting '!'
  in that location is deprecated. These locations include for example
  typealiases or any place where '!' is nested in another type like
  `Int!?` or `[Int!]`.

This commit effectively means ImplicitlyUnwrappedOptional<T> is no
longer part of the type system, although I haven't actually removed
all of the code dealing with it yet.

ImplicitlyUnwrappedOptional<T> is is dead, long live implicitly
unwrapped Optional<T>!

Resolves rdar://problem/33272674.
2018-01-31 12:15:58 -08:00
Nathan Hawes
ef4624b11f Merge pull request #14171 from nathawes/rdar36871908-cursor-info-crash-on-ivar-of-generic-context-used-in-if-or-for
[CursorInfo] Fix crash on instance variables used directly in if or for when declared in a generic context
2018-01-26 11:18:03 -08:00
Nathan Hawes
80e10b188b [CursorInfo] Fix crash on instance variables used directly in if or for when declared in a generic context
For example:
class Foo<T> {
  let test: Bool = false
  let items: [Int] = []
  func foo() {
    if test {} // crashes on test
    for i in items {} // crashes on items
  }
}

We were picking up the incorrect containing type (Bool rather than Foo<T>).
Resolves rdar://problem/36871908.
2018-01-25 14:51:08 -08:00
Nathan Hawes
cbf07dae19 [CursorInfo] Fix crash on init call of inner NTD with generic outer NTD
Resolves rdar://problem/35819975
2018-01-25 13:24:51 -08:00
Nate Cook
5afeecb246 [stdlib] Remove MutableCollection.sorted methods (#14005)
* [stdlib] Remove MutableCollection.sorted methods

This removes the implementations of sorted() and sorted(by:) on Mutable-
Collection, which only changed some minor wording in the docs.

This also adds documentation to the partition(by:) implementations so that
they will appear downstream.

* [stdlib] De-gyb CollectionAlgorithms.swift

* Update tests for MutableCollection.sorted() changes
2018-01-23 14:17:32 -08:00
Nathan Hawes
d567d4356f Add regression test for rdar 36305791 (already fixed) 2018-01-22 15:30:58 -08:00
Nathan Hawes
ef7d6fc7d6 Add regression test for rdar 33334141 (already fixed) 2018-01-22 15:30:12 -08:00
Ben Langmuir
3384ea823b [test] Disable cursor_no_cancel test that crashes occassionaly in CI
Need to investigate this before reenabling.
2018-01-12 11:53:40 -08:00