Commit Graph

1174 Commits

Author SHA1 Message Date
Ben Barham
3a7bf2301b [AST] Add a new attribute @hasAsyncAlternative
This attribute marks a function has having an async alternative,
optionally providing the name of that function as a string. Intended to
be used to allow warnings when using a function with an async
alternative in an asynchronous context, to make the async refactorings
more accurate, and for documentation.
2021-02-18 16:18:38 +10:00
Michael Gottesman
02784b3cb2 Merge pull request #36025 from gottesmm/pr-36fe6ec4772e3d5e09f5031a505217e7d7aba8dc
[ownership] On non-Darwin platforms, serialize the stdlib in OSSA form.
2021-02-17 19:48:25 -08:00
Michael Gottesman
57654da4db [ownership] On non-Darwin platforms start serializing the stdlib in OSSA as well.
I had to fix a memory corruption bug (see previous commit) to land this. But now
that it is fixed, we are ready!
2021-02-17 15:59:00 -08:00
Arnold Schwaighofer
5e851ac5a0 Merge pull request #35945 from aschwaighofer/revert_make_prespecialization_experimental
Revert "Merge pull request #34848 from aschwaighofer/make_prespecialization_experimental"
2021-02-16 07:35:36 -08:00
Michael Gottesman
dd6439d31e [ownership] Change the stdlib to serialize code in ossa form on Darwin.
There is some sort of ASAN issue that this exposes on Linux, so I am going to do
this on Darwin and then debug the Linux issue using ASAN over the weekend/next
week.
2021-02-12 23:20:17 -08:00
Arnold Schwaighofer
084db0d38f Revert "Merge pull request #34848 from aschwaighofer/make_prespecialization_experimental"
This reverts commit 3aec862e62, reversing
changes made to 158427bd5b.
2021-02-12 10:12:01 -08:00
AG
a5b804602d Merge pull request #35110 from bitjammer/acgarland/emit-symbol-graph
Add optional -emit-symbol-graph output when emitting modules
2021-02-12 09:00:58 -08:00
Doug Gregor
6dd1c4768a [Concurrency] Put the flow-sensitive concurrent captures check behind a flag
We're not quite ready to commit to the flow-sensitive check that would
allow a concurrent function to read from a mutable local capture so
long as the captured variable wasn't changed after the point of
capture. Put it behind a flag and implement the more restrictive rule
(no access to mutable local captures in concurrent code). We can relax
it later.
2021-02-11 11:43:07 -08:00
Doug Gregor
866a8d8944 Introduce checking for ConcurrentValue conformance across actors.
When referring to an actor-isolated declaration from outside of the
actor, ensure that the types involved conform to the `ConcurrentValue`
protocol. Otherwise, produce a diagnostic stating that it is unsafe to
pass such types across actors.

Apply the same rule to local captures within concurrent code.
2021-02-03 17:37:43 -08:00
Ashley Garland
69c4fc47cb Add optional -emit-symbol-graph output when emitting modules
rdar://71497047
2021-01-28 09:55:33 -08:00
swift-ci
601af1352a Merge remote-tracking branch 'origin/main' into rebranch 2021-01-27 15:32:37 -08:00
nate-chandler
20930c3b4a Merge pull request #35595 from nate-chandler/other-main
[SILGen] Enable alternative entry point name.
2021-01-27 15:22:27 -08:00
swift-ci
9aad33b08f Merge remote-tracking branch 'origin/main' into rebranch 2021-01-27 10:32:29 -08:00
Michael Gottesman
6e61279dec Merge pull request #35587 from gottesmm/pr-5db2d0b093c814bacaaf559563926c5dec16acc3
[ast] Enable the ASTVerifier behind the enable-ast-verifier flag in no-asserts builds.
2021-01-27 10:13:54 -08:00
swift-ci
2967e35a49 Merge remote-tracking branch 'origin/main' into rebranch 2021-01-26 20:52:47 -08:00
Nate Chandler
e21550ad90 [SILGen] Enable alternative entry point name.
Previously, the name of the entry point function was always main.  Here,
a new frontend flag is added to enable an arbitrary name to be
specified.

rdar://58275758
2021-01-26 10:43:33 -08:00
Varun Gandhi
f9570b2d34 [NFC] Pass full convention printing boolean for types etc.
When -experimental-print-full-convention is set, we should be printing
the full convention in diagnostics, doc comments etc.
2021-01-25 18:47:39 -08:00
Michael Gottesman
1de2d3f7c0 [ast] Enable the ASTVerifier behind the enable-ast-verifier flag in no-asserts builds.
This follows the design of how we handled this with
sil-verify-all. Specifically, the default behavior is to run only in asserts
builds, but one can use the two flags: enable-ast-verifier and
disable-ast-verifier to override the default behavior.

The reason why this is interesting is that this means that when compiling
normally, we will not run the verifier, so we won't have a perf hit. But we can
now ask the user to run with this flag (or in a future maybe a re-run in the
driver would do this for them), saving us time when screening bugs by avoiding
the need to build an asserts compiler to triage if the ASTVerifier would catch
the bug.
2021-01-25 11:55:47 -08:00
swift-ci
74761e3ffe Merge remote-tracking branch 'origin/main' into rebranch 2021-01-19 18:32:17 -08:00
Slava Pestov
c456748551 Frontend: Remove a couple of obsolete staging flags
-enable-subst-sil-function-types-for-function-values
-enable-large-loadable-types

These defaulted to on, and there were no corresponding flags for
turning them off, so the flags had no effect.
2021-01-19 17:47:53 -05:00
Nate Chandler
20db2c0981 Merge branch 'main' into rebranch
Conflicts:
	include/swift/Basic/AnyValue.h
2021-01-12 16:30:02 -08:00
Brent Royal-Gordon
5036a55550 [Frontend] Allow additional files for diagnostic verifier
This change adds a frontend flag, -verify-additional-file, which can be used to pass extra files directly to the diagnostic verifier. These files are not otherwise considered to be Swift source files; they are not compiled or even properly parsed.

This feature can be used to verify diagnostics emitted in non-source files, such as in module interfaces or header files.
2021-01-11 15:59:25 -08:00
Slava Pestov
28e7ed03d0 AST: Remove the 'legacy' request dependency graph implementation 2021-01-08 23:17:12 -05:00
swift_jenkins
de9e56fb12 Merge remote-tracking branch 'origin/main' into next 2020-12-16 19:43:18 -08:00
Dan Liew
8e95189d24 Merge pull request #35074 from apple/dliew/rdar-69335186
Disable "UseOdrIndicator" ASan instrumentation mode by default.
2020-12-16 19:19:40 -08:00
Dan Liew
9208b52de1 Disable "UseOdrIndicator" ASan instrumentation mode by default.
Previously Swift enabled the "UseOdrIndicator" ASan instrumentation mode
and gave no option to disable this. This probably wasn't intentional but
happened due to the fact the
`createModuleAddressSanitizerLegacyPassPass()` function has a default
value for the `UseOdrIndicator` parameter of `true` and in Swift we
never specified this parameter explicitly.

Clang disables the "UseOdrIndicator" mode by default but allows it to be
enabled using the `-fsanitize-address-use-odr-indicator` flag.
Having "UseOdrIndicator" off by default is probably the right
default choice because it bloats the binary. So this patch changes the
Swift compiler to match Clang's behavior.

This patch disables the "UseOdrIndicator" mode by default but adds a
hidden driver and frontend flag (`-sanitize-address-use-odr-indicator`)
to enable it. The flag is hidden so that we can remove it in the future
if needed.

A side effect  of disabling "UseOdrIndicator" is that by we will no
longer use private aliases for poisoning globals. Private aliases were
introduced to avoid crashes
(https://github.com/google/sanitizers/issues/398) due to ODR violations
with non-instrumented binaries. On Apple platforms the use of two-level
namespaces probably means that using private aliases wasn't ever really
necessary to avoid crashes. On platforms with a flat linking namespace
(e.g. Linux) using private aliases might matter more but should users
actually run into problems they can either:

* Fix their environment to remove the ODR, thus avoiding the crash.
* Instrument the previously non-instrumented code to avoid the crash.
* Use the new `-sanitize-address-use-odr-indicator` flag

rdar://problem/69335186
2020-12-15 11:09:30 -08:00
swift_jenkins
6253b23539 Merge remote-tracking branch 'origin/main' into next 2020-12-11 18:51:07 -08:00
Xi Ge
1ba1bd93b2 PrebuiltModules: being resilient to 0-specified build number
swift-driver passes down an SDK version number with a non-existing build number as 0.
The compiler should be resilient to this so we can locate prebuilt module cache.

rdar://72230172
2020-12-11 13:50:51 -08:00
swift_jenkins
766832d57d Merge remote-tracking branch 'origin/main' into next 2020-11-30 14:09:40 -08:00
Alexis Laferrière
2328132f4f Merge pull request #34832 from xymus/rmodule-loading
[Frontend] Intro flag to remark on loaded modules location
2020-11-30 12:58:20 -08:00
swift_jenkins
3bfd2a4bc7 Merge remote-tracking branch 'origin/main' into next 2020-11-30 11:31:01 -08:00
Arnold Schwaighofer
8346bf7e90 Pre-specialization: This is an experimental feature
Only enable if explicitly required.
2020-11-20 09:13:16 -08:00
Alexis Laferrière
de42b1f2fa [Frontend] Optional remarks on loaded modules location
Passing the frontend flag -Rmodule-loading makes the compiler emit
remarks with the path of every module loaded. The path for Swift modules
is either the swiftinterface file for modules built with library
evolution or the binary swiftmodule otherwise. The path for clangmodules
is always in the cache which could be improved as it may be less useful.

Here's an extract of the output for a simple SwiftUI app:

<unknown>:0: remark: loaded module from
/Users/xymus/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/2VJP7CNCGWRF0/SwiftShims-18ZF6992O9H75.pcm
<unknown>:0: remark: loaded module from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.2.sdk/usr/lib/swift/Swift.swiftmodule/x86_64-apple-ios-simulator.swiftinterface
<unknown>:0: remark: loaded module from
/Users/xymus/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/2VJP7CNCGWRF0/os-1HVC6DNXVU37C.pcm
<unknown>:0: remark: loaded module from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.2.sdk/usr/lib/swift/os.swiftmodule/x86_64-apple-ios-simulator.swiftinterface
<unknown>:0: remark: loaded module from
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.2.sdk/System/Library/Frameworks/SwiftUI.framework/Modules/SwiftUI.swiftmodule/x86_64-apple-ios-simulator.swiftinterface
2020-11-19 20:06:23 -08:00
swift_jenkins
365f00d32a Merge remote-tracking branch 'origin/main' into next 2020-11-16 22:37:55 -08:00
Slava Pestov
5808d9beb9 Parse: Remove parse-time name lookup 2020-11-16 22:39:44 -05:00
swift_jenkins
ef6363472e Merge remote-tracking branch 'origin/main' into next 2020-11-16 15:57:12 -08:00
Ben Barham
79b7d5fa99 [Frontend] Disable skipping any function bodies for SwiftOnoneSupport 2020-11-16 15:09:53 +10:00
Andrew Trick
8e792ad38c Merge remote-tracking branch 'origin/main' into 'origin/next' 2020-11-12 22:44:09 -08:00
Alexis Laferrière
b72b0c30fa Merge pull request #34612 from xymus/dont-skip-nested-types
[Sema] Add flag to optimize building swiftmodule files preserving type info for LLDB
2020-11-12 19:16:21 -08:00
Alexis Laferrière
02c134372f [Sema] Add option to skip non-inlinable functions without types
This frontend flag can be used as an alternative to
-experimental-skip-non-inlinable-function-bodies that doesn’t skip
functions defining nested types. We want to keep these types as they are
used by LLDB. Other functions ares safe to skip parsing and
type-checking.

rdar://71130519
2020-11-12 14:28:09 -08:00
swift_jenkins
9786acd193 Merge remote-tracking branch 'origin/main' into next 2020-11-10 14:39:06 -08:00
Ben Barham
241559dc88 [Serialization] Add an option to output modules regardless of errors
Adds a new frontend option
"-experimental-allow-module-with-compiler-errors". If any compilation
errors occur while generating the .swiftmodule, this mode will skip SIL
entirely and only serialize the (likey invalid) AST.

This existence of this option during generation is serialized into the
resulting .swiftmodule. Errors found in deserialization are only allowed
if it is set.

Primarily intended for IDE requests (eg. indexing and code completion)
to ensure robust cross-module results, despite possible errors.

Resolves rdar://69815975
2020-11-10 14:47:22 +10:00
swift_jenkins
971243f0fe Merge remote-tracking branch 'origin/main' into next 2020-11-06 15:36:54 -08:00
swift-ci
f82e962262 Merge pull request #34609 from apple/disable-implicit-concur-import 2020-11-06 15:16:45 -08:00
swift_jenkins
fb55248b20 Merge remote-tracking branch 'origin/main' into next 2020-11-06 10:16:47 -08:00
Slava Pestov
e1526a9b82 Merge pull request #34565 from slavapestov/conformance-availability-part1
Sema: (Mostly) check conformance availability
2020-11-06 12:49:05 -05:00
Kavon Farvardin
242e9fe464 add the -disable-implicit-concurrency-module-import hidden flag 2020-11-06 08:54:01 -08:00
swift_jenkins
e9f94eac71 Merge remote-tracking branch 'origin/main' into next 2020-11-05 20:52:57 -08:00
Ben Barham
7cee600bcd [SILGen] Add flag to skip typechecking and SIL gen for function bodies
Adds a new flag "-experimental-skip-all-function-bodies" that skips
typechecking and SIL generation for all function bodies (where
possible).

`didSet` functions are still typechecked and have SIL generated as their
body is checked for the `oldValue` parameter, but are not serialized.
Parsing will generally be skipped as well, but this isn't necessarily
the case since other flags (eg. "-verify-syntax-tree") may force delayed
parsing off.
2020-11-06 12:08:19 +10:00
Slava Pestov
ceb8675ad1 Sema: (Mostly) check conformance availability
If a conformance is defined in an extension, we now look for
references to the conformance in types and expressions and
respect's the extension's availability (or deprecation, etc).

The conformance checker itself still needs to check conformance
availability of associated conformances and the like; that will
be a separate change.

Note that conformances defined on types don't require any
special handling, since they are as available as the
intersection of the conforming type and the protocol.

By default, we diagnose conformance availability violations
where the OS version is not sufficiently new as warnings, to
avoid breaking source compatibility. Stricter behavior where
these violations are diagnosed as errors is enabled by passing
the -enable-conformance-availability-errors flag. There are
test cases that run both with and without this flag. In the
future, we hope to make the stricter behavior the default,
since after all, violations here can result in link errors and
runtime crashes.

Uses of completely unavailable conformances are still always
diagnosed as errors, even when this flag is not passed in.

Progress on <rdar://problem/35158274>.
2020-11-05 17:51:45 -05:00