Commit Graph

2407 Commits

Author SHA1 Message Date
Erik Eckstein
7f684b62e2 SIL optimizer: Add a new string optimization.
Optimizes String operations with constant operands.

Specifically:
  * Replaces x.append(y) with x = y if x is empty.
  * Removes x.append("")
  * Replaces x.append(y) with x = x + y if x and y are constant strings.
  * Replaces _typeName(T.self) with a constant string if T is statically known.

With this optimization it's possible to constant fold string interpolations, like "the \(Int.self) type" -> "the Int type"

This new pass runs on high-level SIL, where semantic calls are still in place.

rdar://problem/65642843
2020-07-27 21:32:56 +02:00
Luciano Almeida
33d23719eb [tests] Fixing pattern match of note avalable overload lists diagnostic 2020-07-24 15:01:52 -03:00
Luciano Almeida
c09af513a0 [tests] Adjusting regression tests argument mismatch diagnostics on suit 2020-07-23 20:05:27 -03:00
Holly Borla
c8e9018c4d [CSGen] Don't merge type variables for literals in computeFavoredTypeForExpr 2020-07-22 14:43:05 -07:00
Brent Royal-Gordon
4394e92c3f Merge pull request #32700 from brentdax/magical-and-evolutionary
Revise #file changes from SE-0274
2020-07-17 01:57:23 -07:00
Karoy Lorentey
8961b4ea56 [test] stdlib/DefaultIndices: Adjust test conditional
This makes it easier to find & update the availability condition if this behavior ships in an OS release.
2020-07-15 14:27:21 -07:00
Nate Chandler
a2ce157a98 [Test] Disable stdlib/DefaultIndices when use_os_stdlib.
rdar://problem/65605593
2020-07-15 09:58:36 -07:00
Karoy Lorentey
5f489fc719 [test] Fix architecture conditional
rdar://64995079
2020-07-14 18:55:41 -07:00
Stephen Canon
103961a7d5 Make Float16 unavailable on macOS and macCatalyst, mirroring Xcode's Swift. (#32868)
LLVM doesn't have a stable ABI for Float16 on x86 yet; we're working with Intel to get that fixed, but we don't want to make the type available on macOS until a stable ABI is actually available, because we'd break binaries compiled before any calling convention changes if we do.
2020-07-14 20:42:12 -04:00
Nate Cook
3af1deb447 [stdlib] Add _forEachField(of:options:body:) function (#32873)
This function walks all the fields of a struct, class, or tuple, and calls
`body` with the name, offset, and type of each field. `body` can perform
any required work or validation, returning `true` to continue walking fields
or `false` to stop immediately.
2020-07-14 16:31:32 -05:00
Karoy Lorentey
40d7da4fad Merge pull request #32019 from NevinBR/patch-1
[SR-12881] DefaultIndices dynamic dispatch
2020-07-14 12:05:12 -07:00
Brent Royal-Gordon
745dbef3ef Use file IDs in generated code
Such as force unwraps, as! casts, etc.
2020-07-13 14:05:13 -07:00
Saleem Abdulrasool
08924c476d Merge pull request #32826 from compnerd/bloating-point-operations
test: make `stdlib/Integer.swift.gyb` python 3 friendly
2020-07-13 13:46:11 -07:00
Saleem Abdulrasool
cb1aeea9af test: make stdlib/Integer.swift.gyb python 3 friendly
Adjust the division operation to ensure that we get an integral value
back.  Without this, we would attempt to shift a floating point value
by bitwise operations which is not supported.
2020-07-10 14:28:49 -07:00
Nate Chandler
c5270a5968 [Test] Xfail stdlib/NSValueBridging.swift
rdar://problem/64995079
2020-07-10 06:29:52 -07:00
Karoy Lorentey
b42910a430 [test] Reenable NSValueBridging tests on i386
Instead, disable tests we cannot run with a targeted platform conditional.
2020-07-08 22:33:17 -07:00
Mishal Shah
ca87af103b Merge pull request #32705 from apple/apple-silicon-master
[master] Apple Silicon support
2020-07-04 21:53:08 -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
Dario Rexin
732698e268 Fix symbol visibility test for CentOS 7 2020-07-02 13:21:38 -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
50159d15b7 [Gardening] Use Vendor=apple Where Possible
This simplifies the usual bundle of OS checks

OS=macosx || OS=ios || OS=tvos || OS=watchos

into

VENDOR=apple

which was added in apple/swift#27307
2020-06-30 23:03: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
Károly Lőrentey
b3fb7626c1 [test] Don’t import UIKit on iOS 10.3 2020-06-29 18:44:22 -07:00
Karoy Lorentey
73c99acf29 [test] Reinstate CoreGraphics↔︎NSValue bridging tests on iOS/watchOS/tvOS 2020-06-29 16:46:50 -07:00
Saleem Abdulrasool
a817409562 test: make stdlib.NumericParsing Python 3 friendly
Use the proper division operation as the test otherwise generates
different patterns.
2020-06-29 08:55:01 -07:00
Pavel Yaskevich
a8d44bc9ce Merge pull request #32558 from xedin/fix-req-conformace-assessment
[ConstraintSystem] Adjust recording of "fixed" requirements to avoid conflicts
2020-06-26 15:28:13 -07:00
Ben Cohen
87df9961a5 Add fast string interpolation for metatypes (#32113) 2020-06-26 09:46:54 -07:00
Pavel Yaskevich
0ea0b8e27b [ConstraintSystem] Adjust recording of "fixed" requirements to avoid conflicts
Currently it's possible to have a type conflict between different
requirements deduced as the same type which leads to incorrect
diagnostics. To mitigate that let's adjust how "fixed" requirements
are stored - instead of using resolved type for the left-hand side,
let's use originating generic parameter type.
2020-06-25 13:40:15 -07:00
Mishal Shah
ace20bdeb1 Remove comment in TestData.swift 2020-06-23 09:11:39 -07:00
Mishal Shah
52d11fdc57 Remove comment in TestData.swift 2020-06-23 09:11:04 -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
Pavel Yaskevich
82fcee7bc7 [Diagnostics] NFC: Adjust diagnostic test-cases improved by new ambiguity diagnosis 2020-06-12 13:13:27 -07:00
Pavel Yaskevich
ac2305e7f1 [ConstraintSystem] Increase impact of fixes for some conditional requirements
If there is a conditional requirement failure associated with
member/function reference used in a call let's increase a score
of a fix for such failure because it renders member/function
unreachable in current context or with a given set of arguments.
2020-06-12 11:47:04 -07:00
Pavel Yaskevich
d9594c712a [TypeChecker] NFC: Adjust tests improved by new approach for ambiguity diagnosis 2020-06-12 11:47:03 -07:00
tbkka
db9cf4cd80 Filter out more std::__once_call_impl<>() constructors (#32325)
One of our Ubuntu 16.04 CI machines is seeing different variations
of the std::__once_call_impl<>() constructor than the ones we're already filtering out.

Resolves rdar://64267618
2020-06-12 10:03:13 -07:00
3405691582
7b431b4ddb [test] Mark XFAIL tests for OpenBSD.
These tests are marked XFAIL or UNSUPPORTED because either the tests:
require libc annotation, require Mach-O support, don't recognize calls to
swift-autolink-extract, requires porting alongside Linux, or rely on simd
which is not present.

Additionally, explicit REQUIRES for tsan/asan/fuzzer are added to some
tests, since OpenBSD does not support these sanitizers or fuzzers, since
it's nicer to mark that with REQUIRES rather than XFAIL.
2020-06-10 18:57:19 -04:00
Saleem Abdulrasool
017d99d7e4 test: add a test to prevent weak symbol leakage
The Swift standard library should not export weak symbols.  Ensure that
no public weak symbols are defined in the standard library by adding a
test case.  This would have identified the issue introduced by the
recent changes for the runtime.
2020-06-08 16:24:11 -07:00
Saleem Abdulrasool
63c8c005d7 test: add a ODR violation check for the static standard library
The static version of the standard library was leaking symbols in the
`llvm::` namespace which would result in ODR violations were the
artifact linking against `LLVMSupport` (via another dependency).  In
particular, `llvm::SmallVector` and `llvm::StringSwitch` symbols were
being leaked.  This adds a test case specifically for the static variant
of the library.  The dynamic variant of the library is already tested in
a separate test.
2020-05-29 14:02:25 -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
NevinBR
4bb855be4a Created unit tests for DefaultIndices 2020-05-27 09:50:57 -04:00
Mike Ash
28a61eaa19 [Test] Have llvm-support-odr-violation.sh use platform-dylib-dir.
platform-module-dir isn't quite right, since we're looking for libswiftCore.dylib.

rdar://problem/63437032
2020-05-20 11:01:08 -04:00
Robert Widmann
6379387e1d Merge pull request #31883 from gribozavr/enable-unicodescalar-test
Reenable a test for UnicodeScalar
2020-05-19 13:40:03 -07:00
Saleem Abdulrasool
bfb65ecfdb Merge pull request #31870 from compnerd/stdlib-insurance
test: ensure that we do not regress the standard library isolation
2020-05-19 07:54:30 -07:00
Dmitri Gribenko
3f5c53a6b8 Reenable a test for UnicodeScalar
This test was disabled back in 2017 when the new integer protocols were
landing due to regressions in error messages. It is better to have a
working test that verifies the desired behavior (UnicodeScalar not
supporting arithmetic and the type checker producing somewhat readable
messages), rather than a disabled test because the error messages are
not perfect.
2020-05-19 11:53:11 +02:00
Dmitri Gribenko
e055b4bbe3 Merge pull request #31859 from gribozavr/merge-coregraphics
Consolidated four CoreGraphics execution tests
2020-05-19 08:53:59 +02:00
Saleem Abdulrasool
f42a62b9fc Update llvm-support-odr-violation.test-sh
Allow empty input as PE/COFF does not provide a symbol table which results in no visible symbols.
2020-05-18 14:52:00 -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
Saleem Abdulrasool
a92894c530 test: ensure that we do not regress the standard library isolation
Add a test to ensure that the standard library does not accidentally end
up with symbols in the `llvm::` namespace.  The LLVMSupport symbols for
now are namespaced to `__swift::__runtime` with the desire that they
will move into `swift::` and become vended in the swift namespace.
2020-05-18 21:08:16 +00:00
Robert Widmann
7e00f7e6c6 Merge pull request #31853 from 3405691582/Semaphore_Typealias_OpenBSD
[stdlib] sem_t is a nullable pointer on OpenBSD.
2020-05-18 13:05:37 -07:00