Commit Graph

1847 Commits

Author SHA1 Message Date
Azoy
fd950ebbf3 Implement Tuple Comparable Conformance
Add protocol witnesses for all Comparable requirements
2020-10-22 18:27:07 -04:00
Azoy
e60ef84bd2 Implement Tuple Equatable Conformance 2020-10-22 18:24:28 -04:00
Mike Ash
1be7171817 Merge pull request #34350 from mikeash/remove-os-object-test-workaround
[Test] Remove `as AnyObject` cast from OS_objects.swift.
2020-10-21 11:33:17 -04:00
Mike Ash
b1633fdc36 [Test] Remove as AnyObject cast from OS_objects.swift.
This workaround is no longer needed.

rdar://problem/27526994
2020-10-19 11:49:31 -04:00
Saleem Abdulrasool
2fc5cbdc14 stdlib: remove swiftMSVCRT, replace with swiftCRT on Windows
This replaces swiftMSVCRT with swiftCRT.  The big difference here is
that the `visualc` module is no longer imported nor exported.  The
`visualc` module remains in use for a singular test wrt availability,
but this should effectively remove the need for the `visualc` module.

The difference between the MSVCRT and ucrt module was not well
understood by most.  MSVCRT provided ucrt AND visualc, combining pieces
of the old MSVCRT and the newer ucrt.  The ucrt module is what you
really wanted most of the time, however, would need to use MSVCRT for
the convenience aliases for type-generic math and the deprecated math
constants.

Unfortunately, we cannot shadow the `ucrt` module and create a Swift SDK
overlay for ucrt as that seems to result in circular dependencies when
processing the `_Concurrency` module.

Although this makes using the C library easier for most people, it has a
more important subtle change: it cleaves the dependency on visualc.
This means that this enables use of Swift without Visual Studio for the
singular purpose of providing 3 header files.  Additionally, it removes
the need for the installation of 2 of the 4 support files.  This greatly
simplifies the deployment process on Windows.
2020-10-15 16:02:01 -07:00
Erik Eckstein
903786f5ab tests: correct availability checks in Interpreter/runtime_name_local_class_opaque_type.swift
The test checks a fix, which also affects the runtime.
Therefore, the test requires a minimum OS version to run without a crash.
2020-10-02 17:18:19 +02:00
Daniel Rodríguez Troitiño
9a24aaf714 [android] Disable a test that needs LTO support.
With Gold from the Android NDK setting up LTO is complicated, and the CI
machines are not setup for it.

Disable this test in platforms that do not use LLD and LTO (which is
basically Android with older NDKs).
2020-09-27 20:22:41 -07:00
Anthony Latsis
9f58968fa3 Add silgen and run-time tests 2020-09-24 02:09:18 +03:00
Michael Gottesman
f196c16532 Merge pull request #32430 from kateinoigakukun/katei/llvm-lto-driver
[LTO] Support LLVM LTO for driver
2020-09-18 14:49:07 -05:00
3405691582
cd7570fdee ManagedBuffer capacity is unavailable on OpenBSD.
On OpenBSD, malloc introspection (e.g., malloc_usable_size or
malloc_size) is not provided by the platform allocator. Since allocator
introspection is currently a load-bearing piece of functionality for
ManagedBuffer and ManagedBufferPointer, pending any API changes, as a
stopgap measure, this commit marks methods in ManagedBuffer and
ManagedBufferPointer calling _swift_stdlib_malloc_size and methods
dependent thereon unavailable on OpenBSD.

This may induce some compatibility issues for some files, but at least
this change ensures that we can get stdlib to build on this platform
until the evolution process addresses this problem more thoroughly.
2020-09-09 18:57:58 -04:00
Owen Voorhees
c6a266ef62 Merge pull request #29735 from owenv/multiple-varargs
[SE-0284] Allow Multiple Variadic Parameters in Functions, Subscripts, and Initializers
2020-09-05 11:27:21 -05:00
Slava Pestov
233eeea6cb DI: Correctly handle conditional destroy of 'self' in root class
In a designated initializer of a non-root class, 'self' becomes
fully initialized after the 'super.init' call, at which point
escaping uses of 'self' become valid, and releases of 'self' are
lowered to a 'strong_release' instruction, which runs the
deinitializer.

In a root class, 'self' becomes fully initialized after all stored
properties have been initialized, at which point escaping uses of
'self' become valid.

However, DI would still lower a conditional destroy of 'self' by
destroying any initialized stored properties and freeing the object
with 'dealloc_partial_ref'. This is incorrect, because 'self' may
have escaped.

In the non-conditional destroy case, we correctly lowered the
release to a 'strong_release' if all stored properties are known
to be initialized.

Fix DI to handle the conditional destroy case by first checking if all
bits in the control variable are set, and releasing the instance with
'strong_release' if so. The 'dealloc_partial_ref' is only emitted
if not at least one stored property was not initialized.

This ensures that we don't deallocate an instance that may have
escaped.

Fixes <https://bugs.swift.org/browse/SR-13439>, <rdar://problem/67746791>,
<https://bugs.swift.org/browse/SR-13355>, <rdar://problem/67361228>.
2020-08-31 22:14:36 -04:00
Tim Kientzle
62bae423b5 Un-XFAIL a test that now passes
protocol_lookup_foreign exercises CF casting that used to
be broken, but now works with the new dynamic casting implementation.
2020-08-31 10:56:47 -07:00
tbkka
524cfae1b2 [Dynamic Casting] Overhauled Runtime (#33561)
* Dynamic Cast Rework: Runtime

This is a completely refactored version of the core swift_dynamicCast
runtime method.

This fixes a number of bugs, especially in the handling of multiply-wrapped
types such as Optional within Any.  The result should be much closer to the
behavior specified by `docs/DynamicCasting.md`.

Most of the type-specific logic is simply copied over from the
earlier implementation, but the overall structure has been changed
to be uniformly recursive.  In particular, this provides uniform
handling of Optional, existentials, Any and other common "box"
types along all paths.  The consistent structure should also be
easier to update in the future with new general types.

Benchmarking does not show any noticable performance implications.

**Temporarily**, the old implementation is still available.  Setting the
environment variable `SWIFT_OLD_DYNAMIC_CAST_RUNTIME` before launching a program
will use the old runtime implementation.  This is only to facilitate testing;
once the new implementation is stable, I expect to completely remove the old
implementation.
2020-08-27 11:06:40 -07:00
Owen Voorhees
9708247065 [SE-0284] Lift the 1-vararg-per-function restriction
[SE-0284] Add round_trip_parse_gen tests

[SE-0284] Add missing test cases
2020-08-23 21:37:07 -07:00
Arnold Schwaighofer
9b29ec6b98 IRGen: Store scalars as bytes to avoid undefined bits
Don't tempt llvm to misbehave on partially initialized bytes -- it will.

rdar:///66701259
2020-08-14 11:44:04 -07:00
Saleem Abdulrasool
1d410fbc0f Merge pull request #33372 from compnerd/trapping-illness
test: repair Interpreter/bridged_casts_folding on ASi
2020-08-08 08:13:47 -07:00
Saleem Abdulrasool
1d0bf509b8 Merge pull request #33373 from compnerd/rosetta
test: repair Interpreter/SDK/interpreter_with_options on ASi
2020-08-08 08:13:22 -07:00
Mishal Shah
bc2a8f41c1 Merge pull request #33354 from apple/shahmishal/codesign-tests
[Tests] Codesign the binary before executing the test
2020-08-07 19:33:20 -07:00
Mishal Shah
473f55ced8 Remove codesign from test/Interpreter/SDK/objc_swift3_deprecated_objc_inference.swift 2020-08-07 15:53:45 -07:00
Suyash Srijan
155e20c1ac [Test] Add Interpreter and IRGen tests for SR-13203 (#33340) 2020-08-07 23:04:46 +01:00
Saleem Abdulrasool
88e13060ab test: repair Interpreter/SDK/interpreter_with_options on ASi
Remove the target specific binary and instead compile a test binary on
the fly.  Because this test is restricted to macOS platforms, we know
that we assume that we will have a compatible Objective-C runtime at our
disposal.  Use that to create a stub library for testing
`NSClassFromString`.

This allows this test to execute on ARM64.
2020-08-07 14:29:35 -07:00
Saleem Abdulrasool
a16aef2f47 test: repair Interpreter/bridged_casts_folding on ASi
ARM64 generates a `brk #0x1` for `unreachable` which generates a
SIGTRAP.  On x86, we would generate a `ud2` rather than `int 3` which
are treated as `SIGILL` and `SIGTRAP` respectively.
2020-08-07 14:01:54 -07:00
Mishal Shah
a3cd8bc9e9 [Tests] Codesign the binary before executing the test 2020-08-07 00:26:07 -07:00
Yuta Saito
d6cddaabb5 [LTO] Support LLVM LTO for driver
This commit adds LTO support for handling linker options and LLVM BC
emission. Even for ELF, swift-autolink-extract is unnecessary because
linker options are embeded in LLVM BC content when LTO.
2020-07-31 10:17:59 +09:00
Karoy Lorentey
d966dbb511 Merge pull request #32676 from lorentey/simplify-checkclass
[Foundation] Update & simplify class name stability check
2020-07-09 18:50:25 -07:00
Karoy Lorentey
f44cbe4697 [Foundation] Update & simplify class name stability check
Move the ObjC class name stability check logic to the Swift runtime, exposing it as a new SPI called _swift_isObjCTypeNameSerializable.

Update the reporting logic. The ObjC names of generic classes are considered stable now, but private classes and classes defined in function bodies or other anonymous contexts are unstable by design.

On the overlay side, rewrite the check’s implementation in Swift and considerably simplify it.

rdar://57809977
2020-07-02 19:32:22 -07:00
Mishal Shah
10dda582d6 [Apple Silicon] Update tests for no macOS target triple canonicalization
LLVM no longer canonicalizes target triples for maOS versions. Update
tests to account for this.
2020-07-02 19:30:01 -07:00
Mishal Shah
92ca9fc924 [Apple Silicon] Generalize tests for other macOS architectures
Most of the changes fall into a few categories:
* Replace explicit "x86_64" with %target-cpu in lit tests
* Cope with architecture differences in IR/asm/etc. macOS-specific tests
2020-07-02 16:27:46 -07:00
Mishal Shah
84489d87b2 [Apple Silicon] Mark several tests that require the Swift interpreter accordingly 2020-07-02 16:26:10 -07:00
tbkka
f989aa2b22 SR-12486: T.self is Any.Protocol is broken (#31662)
* SR-12486: `T.self is Any.Protocol` is broken

This turned out to be fallout from https://github.com/apple/swift/pull/27572
which was in turn motivated by our confusing metatype syntax when generic variables are bound to protocols.

In particular, the earlier PR was an attempt to make the expression
`x is T.Type` (where `T` is a generic type variable bound to a protocol `P`)
behave the same as
`x is P.Type` (where `P` is a protocol).
Unfortunately, the generic `T.Type` actually binds to `P.Protocol` in this case (not `P.Type`), so the original motivation was flawed, and as it happens, `x is T.Type` already behaved the same as `x is P.Protocol` in this situation.

This PR reverts that earlier change and beefs up some of the tests around these behaviors.

Resolves SR-12486

Resolves rdar://62201613

Reverts PR#27572
2020-07-02 13:10:01 -07:00
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport

This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
2020-06-30 22:55:58 -07:00
Karoy Lorentey
da242bd2d4 [SDK] Remove obsolete overlay code 2020-06-22 15:43:39 -07:00
Mishal Shah
272c466e47 Update master to build with Xcode 12 beta 2020-06-22 15:43:20 -07:00
Doug Gregor
3095deb0f1 [Tests] Update with explicit SDK linking where we missed it. 2020-06-18 09:48:19 -07:00
Mishal Shah
d5c40bf231 Revert "Disable objc_mangling.swift and SwiftObjectNSObject.swift test on tvOS"
This reverts commit 7e2c2452ad.
2020-05-28 14:10:40 -07:00
Michael Gottesman
f57a6cfd6d [silgen] Teach CleanupCloner how to handle OwnedValueWritebackCleanups correctly.
Previously we would just forward the cleanup and create a normal "destroy"
cleanup resulting in early deallocation and use after frees along error paths.

As part of this I also had to tweak how DI recognizes self init writebacks to
not use SILLocations. This is approach is more robust (since we aren't relying
on SourceLocs/have verifiers to make sure we don't violate SIL) and also avoids
issues from the write back store not necessarily have the same SILLocation.

<rdar://problem/59830255>
2020-05-19 16:15:33 -07:00
Michael Gottesman
bcdebc6426 Merge pull request #31893 from gottesmm/pr-e30fc84371dfcdf423f57d1078c16c88b8cc2643
[silgen] Add an extra swift-version 5 run to initializer tests.
2020-05-19 14:20:02 -07:00
Michael Gottesman
d4e09b0944 [silgen] Add an extra swift-version 5 run to initializer tests.
We currently run these in swift-version 4 by default. This caused us to miss
some bugs that only occur in swift-version 5 due to initializer changes
happening in swift 5. This at least will allow us to catch such issues in the
future.

NOTE: I am also going to change objc_throwing_initializers.swift in the same
way, but after I fix the bugs that adding -swift-version 5 exposes therein
(which is actually <rdar://problem/59830255>)
2020-05-19 11:47:08 -07:00
Dmitri Gribenko
30afc6c406 Consolidated four CoreGraphics execution tests
I don't see any reason to split the tests like this. I merged the tests
into the biggest and best-organized test file.

I also removed the `REQUIRES: OS=macosx` line and made some small
adjustments to the test to make it cross-platform.
2020-05-18 23:13:12 +02:00
Michael Gottesman
a99a93d57a [silgen] Add interpreter tests for families of throwing initializers that are @objc.
This type of code can go down different code paths in SILGen/the optimizer. I
found a bug there that I am fixing now and so I decided to expand our code
coverage here.
2020-05-15 14:23:55 -07:00
Robert Widmann
f2b3f8ffb6 Merge pull request #31621 from davezarzycki/pr31621
Remove all uses of -force-single-frontend-invocation
2020-05-08 09:48:48 -07:00
David Zarzycki
5dcc32f98f Remove all uses of -force-single-frontend-invocation
The `-force-single-frontend-invocation` flag predates WMO and is now an
alias for `-whole-module-optimization`. We should use the latter and let
the former fade into history.
2020-05-08 06:37:41 -04:00
Slava Pestov
dd0ce1ad13 Remove the integrated REPL 2020-05-06 22:29:05 -04:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Slava Pestov
1851630e81 IRGen: Fix crash with empty-sized field in a class with resilient ancestry
The problem was that HasObjCAncestry was not getting set if
HasResilientAncestry was true, and thus emitFieldOffsetGlobals() was
marking the field offset as const even though the Objective-C
runtime might slide it.

Fixes <rdar://problem/48031465>.
2020-04-27 19:41:42 -04:00
Arnold Schwaighofer
6244a819c5 Merge pull request #31280 from aschwaighofer/revert_pr30024
Revert "Merge pull request #30024 from Azoy/calling-metadata-accessor…-from-swift"
2020-04-25 09:13:41 -07:00
Meghana Gupta
27e826559a Fix analysis invalidation in ClosureLifetimeFixup (#31295)
Accumulate modifiedCFG when calling correctStackNesting.
Found this bug with -sil-verify-force-analysis=true flag
2020-04-24 16:47:11 -07:00
Arnold Schwaighofer
048e78ef79 Revert "Merge pull request #30024 from Azoy/calling-metadata-accessor-from-swift!"
This reverts commit 5fd6e98b2f, reversing
changes made to 3aee49d9d0.

Revert "XFAIL test/Interpreter/metadata_access.swift on arm64e"

This reverts commit 8fe216b004.

Revert "XFAIl test on os stdlib bots"

This reverts commit aea5fa4842.
2020-04-24 12:28:24 -07:00
Arnold Schwaighofer
8fe216b004 XFAIL test/Interpreter/metadata_access.swift on arm64e
The test manipulates raw pointers some of which might be signed and therefore it fails on arm64e
2020-04-23 11:22:41 -07:00