Commit Graph

11880 Commits

Author SHA1 Message Date
Brent Royal-Gordon
e248f82773 Add support for loading cross-import files 2020-02-18 11:06:12 -08:00
Rintaro Ishizaki
20f8436aa5 Merge pull request #29832 from rintaro/ast-funcparam-nonull
[AST] Ensure AnyFunctionType::Param.Ty is non-null
2020-02-18 09:33:34 -08:00
Slava Pestov
abc84e7789 Merge pull request #29897 from slavapestov/start-removing-clear-lookup-cache
Sema: Remove a couple of calls to clearLookupCache()
2020-02-18 09:03:01 -05:00
Owen Voorhees
d8bc35bc0a Merge pull request #29895 from mdiep/remove-backticks-in-diagnostics
Use single quotes instead of backticks in diagnostics
2020-02-17 19:32:13 -08:00
Slava Pestov
0555de5469 Sema: Remove a couple of calls to clearLookupCache()
Tests seem to pass without these.

Two calls still remain, in ModuleDecl::addFiles() and removeFiles().
It will take a bit more refactoring to eliminate those.
2020-02-17 21:49:02 -05:00
Matt Diephouse
a3486409c4 Use single quotes instead of backticks in diagnostics 2020-02-17 20:04:33 -05:00
Ashley Garland
be77d57121 SymbolGraph: Serialize decl and raw comment locations
- Add DocRangesLayout to the `.swiftsourceinfo`.
  This is a blob containing an array of `SingleRawComment`
  source locations.

- Add DocLocWriter for serializing `SingleRawComment` locs into the
  `DocLocsLayout` buffer.
  Serialize start line, start column, and length of `SingleRawComment`
  pieces in `.swiftsourceinfo`

- Read doc locs when loading basic declaration locs from a ModuleFile.
  - Load `DOC_LOCS` blob into ModuleFile::DocLocsData
  - Reconstitute RawComment ranges when available from .swiftsourceinfo

- Allow requesting serialized raw comment if available

rdar://problem/58339492
2020-02-17 16:20:59 -08:00
Pavel Yaskevich
ca91a1bee0 [ConstraintSystem] Detect and diagnose OoO arguments in call to binary functions/operators
Identify problems like:

```swift
func foo(_ x: Int, _ y: String) {}

func bar(a: Int, b: String) {
  foo(b, a) // Instead of `foo(a, b)`
}
```

Where arguments are out-of-order and repair it by using OoO fix on the
parent locator.
2020-02-17 16:09:11 -08:00
nate-chandler
de660ceea4 Merge pull request #29885 from nate-chandler/generic-metadata-prespecialization-components/stdlib-on
[metadata prespecialization] Always on for stdlib.
2020-02-17 15:04:59 -08:00
Nate Chandler
4475f43ba0 [metadata prespecialization] Always on for stdlib.
Regardless of any flags, the stdlib will have its generic metadata
prespecialized.

Temporarily reintroduced the flag to enable the feature flag while
preserving the flag to disable it and changed the default back to off
for the moment.
2020-02-17 11:53:27 -08:00
David Ungar
709c58ae8e Merge pull request #29869 from davidungar/unit-test-users-v4
[Incremental] Reorganization of SourceFileDepGraph building and mocking.
2020-02-16 22:26:53 -07:00
David Ungar
ad71b8f9a6 hash templates for linux 2020-02-16 14:42:13 -07:00
David Ungar
f4dc8884f0 Further reorganization. 2020-02-16 11:51:36 -07:00
David Ungar
314d1e12c3 Reorganization of SourceFileDepGraph building and mocking. 2020-02-14 21:53:45 -07:00
Holly Borla
c0d936ec8d [Sema] Implement type checking for the typeEraser attribute. 2020-02-14 17:47:23 -08:00
Hamish Knight
13217b600c [SILOptimizer] Add pipeline execution request
Add ExecuteSILPipelineRequest which executes a
pipeline plan on a given SIL (and possibly IRGen)
module. This serves as a top-level request for
the SILOptimizer that we'll be able to hang
dependencies off.
2020-02-14 09:58:32 -08:00
Hamish Knight
13bfac1820 Register IRGen SIL passes with the ASTContext
Rather than registering individual IRGen passes
when we want to execute them, store function
pointers to all the pass constructors on the
ASTContext. This will make it easier to requestify
the execution of pass pipelines.
2020-02-14 09:57:27 -08:00
Hamish Knight
586e586af2 Add top-level request for TBDGen
Introduce `GenerateTBDRequest` which outputs the
interface file along with a set of public symbols.
2020-02-13 21:52:45 -08:00
Hamish Knight
2e40295640 NFC: Extract simple_display for FileUnit 2020-02-13 20:44:38 -08:00
Robert Widmann
1f867edfd4 Merge pull request #29833 from CodaFi/do-the-cupid-shuffle
[Sema] Warn About Tuple Shuffles
2020-02-13 19:33:55 -08:00
Varun Gandhi
d58bf546be [Diagnostics] Improve diagnostics for implicit (un)tupling. (#28076)
Fixes rdar://problem/56436226.
2020-02-13 17:38:21 -08:00
Robert Widmann
a9e871a0b1 [Sema] Warn About Tuple Shuffles
Emit a warning that tuple shuffling is deprecated across the board. In
the future, we should try to unshuffle these expressions where we can,
but that's a diagnostic improvement for another day.

See also https://forums.swift.org/t/deprecating-tuple-shuffles-round-2/16884/30
2020-02-13 17:29:03 -08:00
Rintaro Ishizaki
9bdf3ff112 [AST] Ensure AnyFunctionType::Param.Ty is non-null
Just add an assertion.
2020-02-13 17:13:11 -08:00
Dan Zheng
a49428ca7c [AutoDiff upstream] Add differentiability_witness_function instruction. (#29765)
The `differentiability_witness_function` instruction looks up a
differentiability witness function (JVP, VJP, or transpose) for a referenced
function via SIL differentiability witnesses.

Add round-trip parsing/serialization and IRGen tests.

Notes:
- Differentiability witnesses for linear functions require more support.
  `differentiability_witness_function [transpose]` instructions do not yet
  have IRGen.
- Nothing currently generates `differentiability_witness_function` instructions.
  The differentiation transform does, but it hasn't been upstreamed yet.

Resolves TF-1141.
2020-02-13 16:55:46 -08:00
Rintaro Ishizaki
63772d04a8 Merge pull request #29789 from rintaro/ide-completion-rdar58851121
[CodeCompletion] Enable fast-completion at the top of implicit getter
2020-02-13 10:34:57 -08:00
Pavel Yaskevich
355148dbe8 Merge pull request #29746 from hborla/ambiguity-with-fixes
[Diagnostics] Refactor diagnoseAmbiguityWithFixes.
2020-02-13 02:42:43 -08:00
Luciano Almeida
968a37d221 [Diagnostics] Tailored diagnostic message for conditional downcast involving literals that can be statically coerced 2020-02-13 01:04:15 -03:00
Slava Pestov
e37dba1925 Merge pull request #29659 from slavapestov/nlml-cleanup
Small cleanup for named lazy member loading
2020-02-12 22:01:48 -05:00
Pavel Yaskevich
5437622d2d [Diagnostics] Diagnose ambiguity with conflicting arguments to generic parameters
It's done by first retrieving all generic parameters from each solution,
filtering boundings into distrinct set and diagnosing any differences.

For example:

```swift
func foo<T>(_: T, _: T) {}
func bar(x: Int, y: Float) {
  foo(x, y)
}
```
2020-02-12 17:53:31 -08:00
Slava Pestov
0b502d8c84 AST: loadNamedMembers() never fails
This allows us to simplify lookupDirect() a fair bit as well.
2020-02-12 18:32:46 -05:00
Xi Ge
e013f1fb81 TBDGen: add a flag for embedding external symbols in emitted tbd file
Static-linked libraries could add symbols to the final tbd file. We need
this flag to specify additional module names to collect symbols from.

rdar://59399684
2020-02-12 13:47:59 -08:00
Rintaro Ishizaki
acbc913aec [AST] Add convenient AccessorDecl::isImplicitGetter() 2020-02-12 10:05:12 -08:00
Holly Borla
24826e01bd Merge pull request #29775 from hborla/parse-type-eraser-attribute
[Parse] Add an attribute for typeEraser.
2020-02-12 09:58:14 -08:00
Holly Borla
ffba71b889 [Parse] Add an attribute for typeEraser.
This will be used for compiler-driven type erasure for dynamic
replacement of functions with an opaque return type. For now, just
parse the attribute and ignore it.
2020-02-11 17:30:21 -08:00
Holly Borla
ab59032ebb [CSDiag] Remove obsolete ambiguity code. 2020-02-11 14:53:27 -08:00
Holly Borla
d1f6b3e2ef [Diagnostics] When diagnosing an ambiguous overload, don't mention "call"
if the expression is not a function application.
2020-02-11 14:53:27 -08:00
Holly Borla
1a628f3107 [Diagnostics] Simplify logic in diagnoseAmbiguityWithFixes for emitting
the ambiguity diagnostic by combining a few special errors into one.
2020-02-11 14:53:27 -08:00
Dan Zheng
c2ac96f09f [AutoDiff upstream] Add SIL transpose function type calculation. (#29755)
Add `SILFunctionType::getAutoDiffTransposeFunctionType`.

It computes the transpose `SILFucntionType` for an original `SILFunctionType`,
given:

- Linearity parameter indices
- Transpose function generic signature (optional)
- Other auxiliary parameters

Add doc comments explaining typing rules, preconditions, and other details.
Add `isTranspose` flag to `autodiff::getConstrainedDerivativeGenericSignature`.

Partially resolves TF-1125.
Unblocks TF-1141: upstream `differentiability_witness_function` instruction.
2020-02-11 04:08:25 -08:00
Suyash Srijan
211394099f [CSDiagnostics] Offer a fix-it to insert a return type placeholder when returning from a void function (#29747)
* [CSDiagnostics] Offer a fix-it to insert a return type when returning from a void function

* [CSDiagnostics] Make sure the function name is not empty

The function name will be empty in some cases, for example for property setters. In cases where the function name is empty, skip the note and fix-it.

* [Test] Update existing diagnostics
2020-02-11 10:25:16 +00:00
swift-ci
27b12d5d10 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-09 08:44:24 -08:00
David Ungar
3ac5cebd8f Small fixes and debugging improvements for SwiftDriverTests 2020-02-08 22:45:30 -08:00
swift-ci
e7e6d27ac9 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-08 10:24:29 -08:00
Ravi Kandhadai
ec9844b2d9 [SIL Optimization] Add a new mandatory pass for unrolling forEach
calls over arrays created from array literals. This enables optimizing
further the output of the OSLogOptimization pass, and results in
highly-compact and optimized IR for calls to the new os log API.

<rdar://58928427>
2020-02-07 20:06:29 -08:00
swift-ci
f41f41487e Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-07 15:04:31 -08:00
Michael Gottesman
94cd804eed Merge pull request #29680 from gottesmm/pr-5cabc7ee4a3e006145b5d4716d59ba51ba0c547b
[builtin] Add a new SIL builtin convertStrongToUnsafeUnowned()
2020-02-07 14:52:55 -08:00
swift-ci
fda8e977e1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-07 14:24:32 -08:00
Dan Zheng
a174243159 [AutoDiff upstream] Add SIL differentiability witness IRGen. (#29704)
SIL differentiability witnesses are a new top-level SIL construct mapping
an "original" SIL function and derivative configuration to derivative SIL
functions.

This patch adds `SILDifferentiabilityWitness` IRGen.

`SILDifferentiabilityWitness` has a fixed `{ i8*, i8* }` layout:
JVP and VJP derivative function pointers.

Resolves TF-1146.
2020-02-07 14:10:34 -08:00
Michael Gottesman
f7f98887d4 [builtin] Add a new SIL builtin convertUnownedUnsafeToGuaranteed()
(BaseT, @inout @unowned(unsafe) T) -> @guaranteed T

The reason for the weird signature is that currently the Builtin infrastructure
does not handle results well. Also, note that we are not actually performing a
call here. We are SILGening directly so we can create a guaranteed result.

The intended semantics is that one passes in a base value that guarantees the
lifetime of the unowned(unsafe) value. The builtin then:

1. Borrows the base.
2. Loads the trivial unowned (unsafe), converts that value to a guaranteed ref
   after unsafely unwrapping the optional.
3. Uses mark dependence to tie the lifetimes of the guaranteed base to the
   guaranteed ref.

I also updated my small UnsafeValue.swift test to make sure we get the codegen
we expect.
2020-02-07 13:08:34 -08:00
Michael Gottesman
1137c00196 [builtin] Add a new SIL builtin convertStrongToUnownedUnsafe()
The signature is:

(T, @inout @unowned(unsafe) Optional<T>) -> ()

The reason for the weird signature is that currently the Builtin infrastructure
does not handle results well.

The semantics of this builtin is that it enables one to store the first argument
into an unowned unsafe address without any reference counting operations. It
does this just by SILGening the relevant code. The optimizer chews through this
code well, so we get the expected behavior.

I also included a small proof of concept to validate that this builtin works as
expected.
2020-02-07 13:07:05 -08:00
Michael Gottesman
8841d6d703 [gardening] Add a comment to BUILTIN_MISC_OPERATION_WITH_SILGEN that explains how to use it/contrasts with BUILTIN_SIL_OPERATION. 2020-02-07 12:58:15 -08:00