Commit Graph

156 Commits

Author SHA1 Message Date
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
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
Argyrios Kyrtzidis
5f45e03f13 Merge pull request #13828 from akyrtzi/fix-cursor-interpolation-in-stmts
[sourcekitd] Fix cursor resolving when pointing inside string interpolations of return statements
2018-01-09 12:46:46 -08:00
Argyrios Kyrtzidis
14116f84a1 [sourcekitd] Fix cursor resolving when pointing inside string interpolations of return statements
rdar://36336648
2018-01-09 11:46:15 -08:00
Michael Ilseman
e45fba760c Merge pull request #12793 from johnfairh/nested-param-attrs
[ASTPrinter] Print parameter type attributes more often
2018-01-09 11:16:12 -08:00
Erik Eckstein
cd3d50a5d9 ABI: Change the mangling prefix from _T0 to $S 2018-01-06 13:55:59 -08:00
Pavel Yaskevich
533171debf [Mangling/ABI] NFC: Fix SourceKit tests to reflect label mangling changes 2017-12-18 15:45:50 -08:00
John Fairhurst
87015e46d8 Print out param type attributes in more places 2017-11-20 19:36:50 +00:00
Huon Wilson
44045e24da [test] Update SIL printing/parsing tests for 'witness_method: <protocol>'. 2017-11-01 11:33:27 -07:00
Doug Gregor
15386fa0bf [AST] Track overriding relationship among associated types.
When an associated type declaration “overrides” (restates) an associated
type from a protocol it inherits, note that it overrides that declaration.
SourceKit now reports overrides of associated types.
2017-10-07 21:52:40 -07:00
Ben Langmuir
17cc785c56 Merge pull request #11896 from benlangmuir/dump-output-cursor-test
[test] Attempt to gather more information if cursor_no_cancel crashes
2017-10-03 11:12:01 -07:00
Marcelo Fabri
09ede06f80 [ASTPrinter] Add trailing space after operator declaration (SR-3891) 2017-09-17 16:09:48 -03:00
Ben Langmuir
9271368b46 [test] Attempt to gather more information if cursor_no_cancel crashes
We saw this test crash once, but the stack trace was eaten by FileCheck
because we are consuming stderr. Now if the test fails it should dump
the full output, which should include the stack trace.
2017-09-13 10:18:02 -07:00
Alex Hoppen
1c7e289b96 [Mangling] Adjust subscript mangling to not include "subscript"
Change the mangling of accessors to have a variable or subscript node
as their only child node, while subscript nodes no longer contain a decl
name.
2017-09-10 19:44:07 +02:00
Doug Gregor
f74dbab453 [AST printer] Print "inheritance" clauses based on the requirement signature.
As we do with "where" clauses, print the "inheritance" clauses of
protocols and associated type declarations using the requirement
signature of the protocol rather than the "inherited" list.
2017-09-08 17:07:09 -07:00
Slava Pestov
7a04fc9ef2 ASTPrinter: Don't print redundant 'where Self : AnyObject' 2017-09-04 18:11:13 -05:00
Slava Pestov
50e7c066f7 Parse: Simpler handling of 'class' in protocol inheritance list
Instead of treating this as its own thing, just parse it as if
the user wrote 'AnyObject'.
2017-09-04 17:52:34 -05:00
Argyrios Kyrtzidis
60a91bb736 [refactoring] Upstreaming the implementation for Swift local refactoring (#11568)
[refactoring] Upstreaming the implementation for Swift local refactoring
2017-08-22 16:50:16 -07:00
Argyrios Kyrtzidis
0cfc56ec04 [SourceKit] If diagnostics are 'stale' for a particular snapshot then ignore them and only return the syntactic parser diagnostics (#10388)
This makes sure that diagnostics returned for a particular state of source buffer are consistent and accurate.
rdar://32769873
2017-06-20 12:26:32 -07:00
Robert Widmann
6509f78f13 tests: replace remaining 'mkdir -p' calls with %empty-directory(...)'
These changes were made manually.
2017-06-04 11:08:39 -07:00
Dmitri Gribenko
984210aa53 tests: replace '// RUN: rm -rf' '// RUN: mkdir' pairs with '%empty-directory(...)'
These changes were made using a script.
2017-06-04 11:08:39 -07:00
Slava Pestov
d63bf4ee41 Sema: Fix for bogus ParenType showing up in deduced associated types
When matching inputs of a function type, be sure to
strip off ParenType sugar so that we don't end up
with ParenTypes in associated type witnesses.

This fixes various issues with SE-0110.

Fixes <rdar://problem/32214649>.
2017-05-17 00:39:46 -07:00
Ben Cohen
ea2f64cad2 [stdlib] Add Sequence.Element, change ExpressibleByArrayLiteral.Element to ArrayLiteralElement (#8990)
* Give Sequence a top-level Element, constrain Iterator to match

* Remove many instances of Iterator.

* Fixed various hard-coded tests

* XFAIL a few tests that need further investigation

* Change assoc type for arrayLiteralConvertible

* Mop up remaining "better expressed as a where clause" warnings

* Fix UnicodeDecoders prototype test

* Fix UIntBuffer

* Fix hard-coded Element identifier in CSDiag

* Fix up more tests

* Account for flatMap changes
2017-05-14 06:33:25 -07:00
Ben Langmuir
773434416f Merge pull request #9395 from benlangmuir/no-cancel-cursor
[cursor-info] Add a way to opt out of automatic request cancellation
2017-05-08 13:28:55 -07:00
Ben Langmuir
d13b1c719f [cursor-info] Add a way to opt out of automatic request cancellation
The OncePerASTToken machinery lets us automatically cancel "stale"
requests after a new one comes in.  This avoid wasting time processing
requests that have been superceded, which is common for cursor-info, but
sometimes you really want to get results even later, so this commit adds
a way to opt out of the cancellation.

Incidentally, disable cancellation of name translation, which doesn't
really make sense and no one should be relying on that.

rdar://problem/31905379
2017-05-08 12:01:33 -07:00
Xi Ge
a14953809a [SourceKit] When cursor points to an external argument name in a function-like decl, we should return the information about the function-like decl instead of being empty. rdar://32018814 (#9356) 2017-05-05 17:12:34 -07:00
Ben Langmuir
651bb4c506 [cursor-info] Tweak check to not report parent_loc on locals in body
We were checking only for the specific loc of the declaration of the
param, but that didn't handle references to a local parameter inside the
body.

rdar://problem/32019195
2017-05-05 10:51:30 -07:00
Xi Ge
e9f014a446 [SourceKit] Avoid reporting parent locations for internal only parameter names. rdar://30702790 2017-05-04 12:57:14 -07:00
Robert Widmann
39494b2ba2 Rearrange test code for exhaustiveness 2017-04-28 02:06:39 -04:00
Norio Nomura
3da7926a5e Revert "Revert "Enable SourceKit tests if building SourceKit""
This reverts commit a383adf9df.
2017-04-26 21:16:36 +09:00
Argyrios Kyrtzidis
9b9c84a708 Merge pull request #8972 from akyrtzi/index-external-symbol-namespacing
[index] Use a #pragma to apply module namespacing for exported ObjC header and match Swift namespaced USRs with the clang side
2017-04-24 21:13:12 -07:00
Arnold Schwaighofer
a383adf9df Revert "Enable SourceKit tests if building SourceKit" 2017-04-24 17:59:03 -07:00
Argyrios Kyrtzidis
28b15852d8 Fix tests due to clang namespacing USR changes 2017-04-24 17:42:36 -07:00
Nathan Hawes
6b58cd7d00 [test] Add regression test for cursor-info crasher in rdar://problem/31758709 2017-04-24 17:03:34 -07:00