Commit Graph

11880 Commits

Author SHA1 Message Date
Varun Gandhi
d9a7a7d49e Revert "[Printer] Conditionally print Clang types in emitted SIL."
This reverts commit a27c5f0a16.
2020-01-22 09:04:52 -08:00
Erik Eckstein
bbfaccda4b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 08:25:23 +01:00
Devin Coughlin
e9df206b9d Merge pull request #29017 from devincoughlin/maccatalyst
Build system and availability support for macCatalyst
2020-01-21 22:52:48 -08:00
swift-ci
44ebe469a6 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 21:02:46 -08:00
Brent Royal-Gordon
7df141cdad Merge pull request #29341 from brentdax/path-dependence
[MiscDiagnostics] Warn if magic identifiers don’t match
2020-01-21 20:45:47 -08:00
Devin Coughlin
082421048a [AST/Sema] Add availability attributes for macCatalyst
Add a platform kind and availability attributes for macCatalyst. macCatalyst
uses iOS version numbers and inherits availability from iOS attributes unless
a macCatalyst attribute is explicitly provided.
2020-01-21 20:27:14 -08:00
Devin Coughlin
8c5c5ec802 [Parse] Support macCatalyst conditional compilation
Add support for conditional compilation under macCatalyst

Developers can now detect whether they are compiling for macCatalyst at
compile time with:

  #if targetEnvironment(macCatalyst)
    // Code only compiled under macCatalyst.
  #end
2020-01-21 18:28:17 -08:00
Devin Coughlin
655d89b146 [Driver/Frontend] Add Driver support for macCatalyst and library search paths
Add support in the driver and frontend for macCatalyst target
targets and library search paths.

The compiler now adds two library search paths for overlays when compiling
for macCatalyst: one for macCatalyst libraries and one for zippered macOS
libraries. The macCatalyst path must take priority over the normal macOS path
so that in the case of 'unzippered twins' the macCatalyst library is
found instead of the macOS library.

To support 'zippered' builds, also add support for a new -target-variant
flag. For zippered libraries, the driver invocation takes both a -target and a
-target-variant flag passes them along to the frontend. We support builds both
when the target is a macOS triple and the target variant is macCatalyst and
also the 'reverse zippered' configuration where the target is macCatalyst and the
target-variant is macOS.
2020-01-21 18:28:17 -08:00
Brent Royal-Gordon
c504eb1b0a Warn if magic identifiers don’t match
When wrapping a function which is supposed to capture the caller’s location, there’s always a risk that the wrapper won’t capture the information the wrapped function wants; for instance, you might pass `(…, line, column)` where the callee expected `(…, column, line)`.

This commit emits a warning when a call passes an explicit argument to something that has a default argument, and that explicit argument is itself a parameter with a default argument, and both parameters use magic identifiers, but they use *different* magic identifiers.  This is partially in support of concise #file, but applies to all magic identifiers.

Fixes rdar://problem/58588633.
2020-01-21 14:28:16 -08:00
Brent Royal-Gordon
b43b1ec1be [NFC] Allow getParameter{List,At} to be called on any ValueDecl
These now return nullptr for parameter-list-free types; previously those would have failed a cast.
2020-01-21 14:28:16 -08:00
Brent Royal-Gordon
6c99bdac1e [NFC] Extract helper for making magic identifier strings 2020-01-21 14:28:16 -08:00
Hamish Knight
a1c490220b Enable the use of find_as with ActiveRequest
This avoids having to allocate a full AnyRequest
for a hash lookup.
2020-01-21 13:07:33 -08:00
swift-ci
d4f35195fc Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 12:23:19 -08:00
Suyash Srijan
451074a426 [Typechecker] Remove 'NSObject.hashValue' warning now that it is an error (and because 'hashValue' is longer 'open') (#29328) 2020-01-21 20:16:54 +00:00
swift-ci
a48309f8b1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 12:03:41 -08:00
Doug Gregor
8283a67648 Revert "Revert "Reimplement function builders as statement transformations."" 2020-01-21 10:07:20 -08:00
swift-ci
e28c558c72 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 09:43:46 -08:00
Varun Gandhi
f6e0db5bdc Merge pull request #29239 from varungandhi-apple/vg-clang-types-in-sil
Propagate Clang types through SIL
2020-01-21 09:42:37 -08:00
swift-ci
677787741d Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 09:23:10 -08:00
Doug Gregor
423adbc089 Merge pull request #29292 from apple/revert-29133-generlize-function-builders
Revert "Reimplement function builders as statement transformations."
2020-01-21 09:10:20 -08:00
Hamish Knight
2b97bf8af4 [Evaluator] Stop canonicalizing requests
This is unnecessary given we now only create
AnyRequests when caching, or when building the
dependency graph.
2020-01-20 09:15:16 -08:00
Hamish Knight
4b698a5a31 [AST] Introduce ActiveRequest
This wrapper is used to type erase a reference to
a request on the stack, and can be converted into
an AnyRequest when persistent storage is required.

Switch the evaluator over to using ActiveRequest
for its stack of active requests, meaning it now
only needs to heap allocate requests when they
enter the cache, or if it's building the (disabled
by default) dependency graph.
2020-01-20 09:15:16 -08:00
swift-ci
44b7b6c0a9 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-19 12:23:32 -08:00
Dan Zheng
44d937d7c2 [AutoDiff upstream] Add @differentiable declaration attribute type-checking. (#29231)
The `@differentiable` attribute marks a function as differentiable.

Example:
```
@differentiable(wrt: x, jvp: derivativeFoo where T: Differentiable)
func id<T>(_ x: T) -> T { x }
```

The `@differentiable` attribute has an optional `wrt:` clause specifying the
parameters that are differentiated "with respect to", i.e. the differentiability
parameters. The differentiability parameters must conform to the
`Differentiable` protocol.

If the `wrt:` clause is unspecified, the differentiability parameters are
currently inferred to be all parameters that conform to `Differentiable`.

The `@differentiable` attribute also has optional `jvp:` and `vjp:` labels
for registering derivative functions. These labels are deprecated in favor of
the `@derivative` attribute and will be removed soon.

The `@differentiable` attribute also has an optional `where` clause, specifying
extra differentiability requirements for generic functions.

The `@differentiable` attribute is gated by the
`-enable-experimental-differentiable-programming` flag.

Code changes:
- Add `DifferentiableAttributeTypeCheckRequest`.
  - Currently, the request returns differentiability parameter indices, while
    also resolving `JVPFunction`, `VJPFunction`, and
    `DerivativeGenericSignature` and mutating them in-place in
    `DifferentiableAttr`. This was the simplest approach that worked without
    introducing request cycles.
- Add "is type-checked" bit to `DifferentiableAttr`.
  - Alternatively, I tried changing `DifferentiableAttributeTypeCheckRequest` to
    use `CacheKind::Cache` instead of `CacheKind::SeparatelyCached`, but it did
    not seem to work: `@differentiable` attributes in non-primary-files were
    left unchecked.

Type-checking rules (summary):
- `@differentiable` attribute must be declared on a function-like "original"
  declaration: `func`, `init`, `subscript`, `var` (computed properties only).
- Parsed differentiability parameters must be valid (if they exist).
- Parsed `where` clause must be valid (if it exists).
- Differentiability parameters must all conform to `Differentiable`.
- Original result must all conform to `Differentiable`.
- If JVP/VJP functions are specified, they must match the expected type.
  - `@differentiable(jvp:vjp:)` for derivative registration is deprecated in
    favor of `@derivative` attribute, and will be removed soon.
- Duplicate `@differentiable` attributes with the same differentiability
  parameters are invalid.
- For protocol requirements and class members with `@differentiable` attribute,
  conforming types and subclasses must have the same `@differentiable` attribute
  (or one with a superset of differentiability parameter indices) on
  implementing/overriding declarations.
2020-01-19 12:23:04 -08:00
swift-ci
29c5aad6e4 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-17 20:03:08 -08:00
Varun Gandhi
a27c5f0a16 [Printer] Conditionally print Clang types in emitted SIL.
Hopefully, this helps us debug Clang type mismatches better.
2020-01-17 16:22:39 -08:00
Varun Gandhi
5f45820755 [AST] Store Clang type in SILFunctionType for @convention(c) functions. 2020-01-17 16:22:39 -08:00
Varun Gandhi
bfa2f98d95 [AST] Add functionality for computing Clang types for SIL functions. 2020-01-17 16:22:39 -08:00
Varun Gandhi
f07ba79377 [NFC] Fix incorrect comment in ExtInfo's constructor. 2020-01-17 16:22:39 -08:00
Xi Ge
3ee9b1175c TBDGen: when previous install name map is specified, emit $ld$previous linker directives.
Progress towards: rdar://58281536
2020-01-17 15:57:25 -08:00
Doug Gregor
86c13d3c74 Revert "Reimplement function builders as statement transformations." 2020-01-17 15:52:49 -08:00
swift-ci
3a0eb0760f Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-17 10:44:12 -08:00
swift-ci
0a9b19fa4f Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 13:23:15 -08:00
David Ungar
8c2c4ab391 Fixes for fine-grained dependencies 2020-01-16 13:20:27 -08:00
Doug Gregor
9853926cb2 [Function builders] Make sure we contextualize closures with builders applied.
We used to get this contextualization "for free" because closures that
had function builders applied to them would get translated into
single-expression closures. Now, we need to check for this explicitly.
2020-01-16 13:19:21 -08:00
Doug Gregor
9e6f6d8d3b Rename FunctionBuilderClosurePreCheck -> FunctionBuilderBodyPreCheck 2020-01-16 13:18:33 -08:00
Xi Ge
80d6230105 Merge pull request #29241 from nkcsgexi/refactor-originally-defined
TBDGen: some refactoring to allow multiple platform kinds for linker directives. NFC
2020-01-16 13:16:00 -08:00
Xi Ge
caf88fb1eb TBDGen: some refactoring to allow multiple platform kinds for linker directives.
Tentatively fixing: rdar://58569201
2020-01-16 11:42:03 -08:00
Erik Eckstein
1b312a85bd Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-16 10:39:20 +01:00
Pavel Yaskevich
8269522f86 Merge pull request #28837 from xedin/rdar-56340587
[ConstraintSystem] Delay constraint generation for single-statement closure body
2020-01-16 00:29:11 -08:00
kitaisreal
53c008f32c [Parser]: Labeled block without do diagnostics (#29147)
Improve diagnostics for labeled block without 'do'.
Parse and diagnose { identifier ':' '{' } as a labeled 'do' statement.

https://bugs.swift.org/browse/SR-3867
2020-01-15 23:51:59 -08:00
Brent Royal-Gordon
99e60b03b2 Merge pull request #29237 from brentdax/revenge-of-the-synth
Revert "Merge pull request #28665 from CodaFi/the-phantom-menace"
2020-01-15 20:09:55 -08:00
Varun Gandhi
8510b9234b [NFC] Add an EmitSortedSIL member to SILOptions for consistency. (#29210)
It is a bit strange to have the FrontendOptions being used in writeSIL
instead of SILOptions, so this PR fixes that.
2020-01-15 16:25:41 -08:00
Brent Royal-Gordon
0c478b6be6 Revert "Merge pull request #28665 from CodaFi/the-phantom-menace"
This reverts commit 43a3ab7e35, reversing
changes made to 4f39d9c749.

# Conflicts:
#	include/swift/AST/Attr.def
#	lib/AST/Attr.cpp
#	lib/Serialization/Deserialization.cpp
#	lib/Serialization/ModuleFormat.h
#	lib/Serialization/Serialization.cpp
2020-01-15 15:28:42 -08:00
Dan Zheng
a1fe532151 [AutoDiff upstream] Add derivative function type calculation. (#29218)
Add `AnyFunctionType::getAutoDiffDerivativeFunctionType`.

It computes the derivative `AnyFunctionType` for an "original"
`AnyFunctionType`, given:
- Differentiability parameter indices
- Differentiability result index
- Derivative function kind
- Derivative function generic signature (optional)
- Other auxiliary parameters

Add doc comments explaining typing rules, preconditions, and other details.

Progress towards TF-828: upstream `@differentiable` attribute type-checking.
2020-01-15 09:42:48 -08:00
Varun Gandhi
4f10b1937c [NFC] Adjust SILFunctionType layout to use TrailingObjects methods. (#29124)
This makes the implementation cleaner, as well as fixes a bug in the
numTrailingObjects<SILResultInfo> method (which was unused).
2020-01-14 16:39:13 -08:00
Robert Widmann
5e155d9ef7 Merge pull request #29155 from CodaFi/west-const-story
[Gardening] Sprinkle Const Qualification Around the Frontend
2020-01-14 11:18:53 -08:00
Nathan Hawes
2354cebd1c Merge pull request #29192 from nathawes/formatting-fix
[NFC] Formatting fix in TypeMatcher.h
2020-01-14 11:02:02 -08:00
Nathan Hawes
e0ccadd3c2 [NFC] Small formatting fix in TypeMatcher.h 2020-01-14 09:12:41 -08:00
Pavel Yaskevich
58f615dfd2 [AST] NFC: Remove obsolete function builder type storage from ParameterListInfo 2020-01-14 00:09:32 -08:00