Commit Graph

1784 Commits

Author SHA1 Message Date
Doug Gregor
ed541f32e3 Forward matching of trailing closure arguments.
Introsuce a new "forward" algorithm for trailing closures where
the unlabeled trailing closure argument matches the next parameter in
the parameter list that can accept an unlabeled trailing closure.

The "can accept an unlabeled trailing closure" criteria looks at the
parameter itself. The parameter accepts an unlabeled trailing closure
if all of the following are true:

* The parameter is not 'inout'
* The adjusted type of the parameter (defined below) is a function type

The adjusted type of the parameter is the parameter's type as
declared, after performing two adjustments:

* If the parameter is an @autoclosure, use the result type of the
parameter's declared (function) type, before performing the second
adjustment.
* Remove all outer "optional" types.

For example, the following function illustrates both adjustments to
determine that the parameter "body" accepts an unlabeled trailing
closure:

    func doSomething(body: @autoclosure () -> (((Int) -> String)?))

This is a source-breaking change. However, there is a "fuzzy" matching
rule that that addresses the source break we've observed in practice,
where a defaulted closure parameter precedes a non-defaulted closure
parameter:

    func doSomethingElse(
       onError: ((Error) -> Void)? = nil,
       onCompletion: (Int) -> Void
    ) { }

    doSomethingElse { x in
      print(x)
    }

With the existing "backward" scan rule, the trailing closure matches
onCompletion, and onError is given the default of "nil". With the
forward scanning rule, the trailing closure matches onError, and there
is no "onCompletion" argument, so the call fails.

The fuzzy matching rule proceeds as follows:
* if the call has a single, unlabeled trailing closure argument, and
* the parameter that would match the unlabeled trailing closure
argument has a default, and
* there are parameters *after* that parameter that require an argument
(i.e., they are not variadic and do not have a default argument)

then the forward scan skips this parameter and considers the next
parameter that could accept the unlabeled trailing closure.

Note that APIs like doSomethingElse(onError:onCompletion:) above
should probably be reworked to put the defaulted parameters at the
end, which works better with the forward scan and with multiple
trailing closures:

    func doSomethingElseBetter(
       onCompletion: (Int) -> Void,
       onError: ((Error) -> Void)? = nil
    ) { }

    doSomethingElseBetter { x in
      print(x)
    }

    doSomethingElseBetter { x in
      print(x)
    } onError: { error in
      throw error
    }
2020-07-24 08:10:00 -07:00
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
David Ungar
6171c4105b Remove bogus assertion with explanation. 2020-07-14 15:09:04 -07:00
Nathan Hawes
962e0bbd56 Merge pull request #32606 from nathawes/prefer-macOS-to-OSX-spelling-when-printing-platform
[AST] Prefer the 'macOS' spelling over 'OSX' when printing the platform kind.
2020-07-09 17:11:27 -07:00
Hamish Knight
f8ee94dc99 Merge pull request #32777 from hamishknight/out-of-the-link
Remove -sil-merge-partial-modules
2020-07-09 15:06:52 -07:00
martinboehme
40104ba8b1 Link against the C++ standard library when C++ interop is enabled (#30914)
This doesn't yet allow including C++ headers on platforms where libc++
isn't the default; see comments in UnixToolChains.cpp for details.

However, it does, for example, allow throwing and catching exceptions in C++
code used through interop, unblocking
https://github.com/apple/swift/pull/30674/files.

The flags (-enable-experimental-cxx-interop and -experimental-cxx-stdlib) carry
"experimental" in the name to emphasize that C++ interop is still an
experimental feature.

Co-authored-by: Michael Forster <forster@google.com>
2020-07-09 15:59:26 +02:00
Hamish Knight
e4a8e0ea45 Remove -sil-merge-partial-modules
This is now the default behaviour for -merge-modules. Stop
passing it in the driver and remove it from FrontendOptions.td.
2020-07-08 22:14:32 -07:00
Nathan Hawes
244dc4a768 [AST] Rename PlatformKind::OSX to PlatformKind::macOS
Because the names are coming from a .def file used for printing too, this
simplifies the printing logic as well.
2020-07-08 16:29:31 -07:00
Doug Gregor
f818a1e1b0 [Driver/IRGen] Put backward-deployment libraries into a table.
Describe the backward-deployment libraries via a preprocessor-driven
table. Macro-metaprogramming the two places in the code base---the
driver and IRGen---to use this tabble to determine which
backward-compatibility libraries to link against.
2020-07-07 23:11:37 -07:00
Mishal Shah
60d996f060 [Apple Silicon] Add support for triple and availability canonicalization 2020-07-02 19:26:25 -07:00
Mishal Shah
710ba14ddc [Apple Silicon] [Platform] Baseline arm64 simulators at iOS/tvOS 14.0 and watchOS 7.0. 2020-07-02 19:18:52 -07:00
Mishal Shah
a8aec14bce [Apple Silicon] Adjust linking deployment target from 11.0 down to 10.16 on x86. 2020-07-02 18:31:09 -07:00
Mishal Shah
3c9e72f6e1 [Apple Silicon] [macCatalyst] Baseline arm64(e) macCatalyst at Swift 5.3/iOS 14.0. 2020-07-02 18:28:33 -07:00
Mishal Shah
134f202e01 [Apple Silicon] Baseline arm64 macOS at Swift 5.3 / macOS 10.16 2020-07-02 16:42:15 -07:00
swift_jenkins
0b243773f6 Merge remote-tracking branch 'origin/master' into master-next 2020-07-01 03:18:10 -07:00
David Zarzycki
9e85a396f6 Merge pull request #32630 from HassanElDesouky/LocaleFlagsRE
Reopen [Diag] Create frontend flags for localization
2020-07-01 05:58:50 -04:00
HassanElDesouky
063e92aa53 Create frontend flags for localization 2020-06-30 23:12:40 +02:00
swift_jenkins
22ae05a5f7 Merge remote-tracking branch 'origin/master' into master-next 2020-06-30 08:19:10 -07:00
David Zarzycki
621cecbe71 Revert "[Diag] Create frontend flags for localization and write tests (#32568)"
This reverts commit 621b3b4223.

The driver is double faulting on my Linux box (Fedora 32 / x86-64). It
crashes due to heap corruption, then hangs trying to introspect and
print the stack. There also appears to be an unrelated(?) uninitialized
memory error that valgrind detects (as opposed to malloc's own self
diagnostics).
2020-06-30 08:31:38 -04:00
swift_jenkins
f376272f21 Merge remote-tracking branch 'origin/master' into master-next 2020-06-29 23:38:11 -07:00
Hassan ElDesouky
621b3b4223 [Diag] Create frontend flags for localization and write tests (#32568)
* Create frontend flags for localization

* Remove assertion
2020-06-29 23:32:44 -07:00
swift_jenkins
a75e04e03a Merge remote-tracking branch 'origin/master' into master-next 2020-06-29 18:58:23 -07:00
Butta
e6fe8d47c2 Driver: update old doc comments from when clang++ was the linker driver 2020-06-24 18:38:03 +05:30
swift_jenkins
b960584a93 Merge remote-tracking branch 'origin/master' into master-next 2020-06-17 15:19:31 -07:00
Doug Gregor
ad9a7efaca [Driver] .tbd files are linker inputs 2020-06-17 10:27:49 -07:00
swift_jenkins
90dd9dbae8 Merge remote-tracking branch 'origin/master' into master-next 2020-06-16 14:18:53 -07:00
Keith Smiley
1b77448d37 Add path remapping with -coverage-prefix-map to coverage data
Previously the path to covered files in the __LLVM_COV / __llvm_covmap
section were absolute. This made remote builds with coverage information
difficult because all machines would have to have the same build root.
This change uses the values for `-coverage-prefix-map` to remap files in
the coverage info to relative paths. These paths work correctly with
llvm-cov when it is run from the same source directory as the
compilation, or from a different directory using the `-path-equivalence`
argument.

This is analogous to this change in clang https://reviews.llvm.org/D81122
2020-06-15 17:38:34 -07:00
David Zarzycki
b675ddb411 Add missing header 2020-06-11 06:10:42 -04:00
Slava Pestov
965c735a06 Merge pull request #32131 from slavapestov/binary-swiftdeps-format
New binary swiftdeps format
2020-06-11 03:58:35 -04:00
Nathan Hawes
f89e213bec Merge pull request #32281 from nathawes/handle-filelists-in-sourcekit-driver-args
[Driver/SourceKit] Handle filelist driver args in getSingleFrontendInvocationFromDriverArguments
2020-06-10 17:39:52 -07:00
Slava Pestov
d59a76c248 Dependencies: New binary format for fine-grained dependency graph 2020-06-10 15:40:55 -04: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
Robert Widmann
3228a5903a [NFC] Rename Flags
-enable-experimental-private-intransitive-dependencies -> -enable-direct-intramodule-dependencies
-disable-experimental-private-intransitive-dependencies -> -disable-direct-intramodule-dependencies

While we're here, rename DependencyCollector::Mode's constants and clean
up the documentation.
2020-06-09 16:00:59 -07:00
Robert Widmann
fdf31c88a6 Add Flags to Enable or Disable EnableExperientalPrivateIntransitiveDependencies
Turn the existing flag into an on-off switch and migrate all the tests in preparation for it being on by default
2020-06-09 12:24:57 -07:00
Saleem Abdulrasool
71309a8fa9 Revert "[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows" 2020-06-07 11:25:48 -07:00
Ben Langmuir
fadfb6c945 Merge pull request #31874 from benlangmuir/driver-tmp-sad
[driver/sourcekit] Avoid creating temporary output files in TMPDIR
2020-06-05 13:43:23 -07:00
Saleem Abdulrasool
d0131ba6be Merge pull request #31146 from kateinoigakukun/katei/enable-lang-agnostic-lto
[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows
2020-06-05 11:38:09 -07:00
Arnold Schwaighofer
3f903b4891 Merge pull request #31986 from aschwaighofer/irgen_inherit_clangs_fp_elim
IRGen: Default to clang's frame pointer elimination settings
2020-06-03 07:38:24 -07:00
Anthony Latsis
267e32dcd8 Merge pull request #32118 from AnthonyLatsis/post-increment-cleanup
[NFC] Pre- increment and decrement where possible
2020-06-02 20:10:29 +03:00
Ben Langmuir
251dbb9b8c [driver] Improve handling of supplementary outputs in createCompilerInvocation
Mark the relevant options in Options.td rather than hard-coding the
list in code, and handle a few more options suggested during the review.
2020-06-01 14:00:39 -07:00
Anthony Latsis
9fd1aa5d59 [NFC] Pre- increment and decrement where possible 2020-06-01 15:39:29 +03:00
Varun Gandhi
fea589e470 [NFC] Remove redundant includes for llvm/ADT/DenseSet.h. 2020-05-31 13:07:45 -07:00
Yuta Saito
915c4a6997 [LTO] Support LLVM level link time optimization
This commit adds -lto flag for driver to enable LTO at LLVM level.
When -lto=llvm given, compiler emits LLVM bitcode file instead of object
file and perform thin LTO using libLTO.dylib plugin.
When -lto=llvm-full given, perform full LTO instead of thin LTO.
2020-05-31 08:12:52 +09:00
Arnold Schwaighofer
20f4ef93de IRGen: Default to clang's frame pointer elimination settings
Clang provides options to override that default value.
These options are accessible via the -Xcc flag.

Some Swift functions explicitly disable the frame pointer.

The clang options will not override those.
2020-05-28 12:21:42 -07:00
Owen Voorhees
e40e86fc94 Merge pull request #32017 from owenv/diag-style-opt
[Diagnostics] Add -diagnostic-style=(llvm|swift) to control printed output
2020-05-27 20:22:23 -07:00
Arnold Schwaighofer
45810d0aea Merge pull request #31921 from aschwaighofer/irgen_frame_pointer_non_leaf_only
IRGen: Always eliminate frame pointers of leaf functions
2020-05-22 16:24:27 -07:00
Tony Allevato
966ffbbd7d Propagate -vfsoverlay from driver to frontend.
Today, the driver does not propagate the flag to the frontend
but also does not emit an error (silently consuming the flag
instead).

I'll open a similar PR for apple/swift-driver once this one is
merged, in case there are any issues that need to be worked out
first.

Fixes SR-12834.
2020-05-22 10:38:32 -07:00
Arnold Schwaighofer
109813ffe5 Add option to disable leaf frame pointer elimination 2020-05-21 13:19:24 -07:00
Owen Voorhees
c4e67e29ed [Diagnostics] Add -diagnostic-style=(llvm|swift) to control printed output
This default formatting style remains the same "LLVM style". "Swift style"
is what was previously enabled via -enable-experimental-diagnostic-formatting
2020-05-20 19:34:15 -05: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