Commit Graph

827 Commits

Author SHA1 Message Date
Graydon Hoare
9cb1c52fd8 Count constraint-solving memory more precisely, rdar://29684330 2017-02-06 13:04:19 -08:00
Andrew Trick
e9c559b718 [SILGen] Bootstrapping opaque values (#7113)
[NFC] Add -enable-sil-opaque-values frontend option.

This will be used to change the SIL-level calling convention for opaque values,
such as generics and resilient structs, to pass-by-value.  Under this flag,
opaque values have SSA lifetimes, managed by copy_value and destroy_value.

This will make it easier to optimize copies and verify ownership.

* [SILGen] type lowering support for opaque values.

Add OpaqueValueTypeLowering.
Under EnableSILOpaqueValues, lower address-only types as opaque values.

* [SIL] Fix ValueOwnershipKind to support opaque SIL values.

* Test case: SILGen opaque value support for Parameter/ResultConvention.

* [SILGen] opaque value support for function arguments.

* Future Test case: SILGen opaque value specialDest arguments.

* Future Test case: SILGen opaque values: emitOpenExistential.

* Test case: SIL parsing support for EnableSILOpaqueValues.

* SILGen opaque values: prepareArchetypeCallee.

* [SIL Verify] allow copy_value for EnableSILOpaqueValues.

* Test cast: SIL serializer support for opaque values.

* Add a static_assert for ParameterConvention layout.

* Test case: Mandatory SILOpt support for EnableSILOpaqueValues.

* Test case: SILOpt support for EnableSILOpaqueValues.

* SILGen opaque values: TypeLowering emitCopyValue.

* SILBuilder createLoad. Allow loading opaque values.

* SIL Verifier. Allow loading and storing opaque values.

* SILGen emitSemanticStore support for opaque values.

* Test case for SILGen emitSemanticStore.

* Test case for SIL mandatory support for inout assignment.

* Fix SILGen opaque values test case after rebasing.
2017-01-27 18:56:53 -08:00
Jacob Bandes-Storch
49f5251c73 [QoI] offer typo correction for platform conditionals 2017-01-12 09:07:53 -08:00
Mark Lacey
5f2aeec434 Implement a new "expression too complex" metric for Swift 4 mode.
Rather than waiting until we've used a huge amount of memory, attempt to
make the choice to bail out based on the number of type bindings /
disjunction choices we visit.

I expect this will generally fail faster than the Swift 3 metric, but
will still only fail when we've got clearly exponential type checking
behvior.

Since we have multiple sources of exponential behavior today, I don't
want to make the bounds too tight. Once we fix some/most of that
behavior we can look at further tightening up the metric.
2017-01-10 22:09:11 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Slava Pestov
a760186505 AST: Remove -enable-experimental-nested-generic-types flag 2016-11-18 00:39:15 -08:00
John McCall
d123345689 Provide a frontend option to disable typo correction.
rdar://29003217
2016-11-02 14:08:56 -07:00
Michael Ilseman
12fb0bad7b [swift-version] Allow swift-version 4 and tests
The recent @escaping on variadic argument closures back-compat fix is
the first Swift 3.0 compatibility behavior that we don't want to carry
forwards indefinitely into the future. To address this, we
version-gate the diagnostic suppression.

Makes it an official compatibility check. Creates new test directory
for compatibility testing. Allow -swift-version 4 so that we can test
it both ways.
2016-10-11 17:42:25 -07:00
Slava Pestov
745a4a3974 IRGen: Disable resilient class metadata unless -enable-class-resilience is passed in
Resilient classes are not fully implemented yet, and can cause
crashes at runtime; add a flag disabling them until the code is
done, to unblock standard library testing with resilience
enabled.
2016-09-30 18:28:11 -07:00
Graydon Hoare
8970d44675 Add "-swift-version <n>" that sets LangOpts.EffectiveLanguageVersion.
This flag switches the "effective language version" of the compiler,
at least to any version supported (as of this change: "3" or "3.0").

At the moment nothing uses it except the language version build
configuration statements (#if swift(...)) and various other places
that report, encode, or otherwise check version numbers.

In the future, it's intended as scaffolding for backwards compatibility.

Fixes SR-2582
2016-09-20 15:11:37 -07:00
Doug Gregor
2552f41556 [Name lookup] Add a staging flag for ASTScope-based name lookup. 2016-09-06 09:05:11 -07:00
Doug Gregor
68c3f3b1b3 Remove EnableSwift3Private staging option. 2016-08-19 21:53:32 -07:00
Doug Gregor
f99904ac66 Eliminate the useless flag -enable-experimental-collection-casts.
This eliminates a pile of now-dead code in:
  * The type checker, where we no longer have special cases for bridging conversions
  * The expression ASTs, where we no longer need to distinguish bridging collection up/down casts
  * SILGen, which no longer uses

Still to come is the removal of the
_(set|dictionary)Bridge(From|To)ObjectiveC(Conditional)? entrypoints
from the standard library. They're still used by some tests.
2016-08-19 21:17:10 -07:00
Doug Gregor
51529ae888 Eliminate the -enable-id-as-any flag; it's always on now anyway.
Simplify e.g., ASTContext::getBridgedToObjC(), which no longer needs
the optional return.

Eliminate the now-unused constraint kind for checking bridging to
Objective-C.
2016-08-19 21:17:09 -07:00
Doug Gregor
f9d109442a Remove -suppress-argument-labels-in-types; it's dead. 2016-08-19 14:27:29 -07:00
Doug Gregor
fe7e780559 Remove -Womit-needless-words; it was a hack to bring up the Grand Renaming.
I'm slightly sad about losing the lovely code to detect
redundantly-specified defaulted arguments, but we could bring it back
later as a separate warning.
2016-08-19 14:19:51 -07:00
Doug Gregor
eb3ba78d94 Remove the swift3_migration attribute.
This attribute was a (my) bad idea that we ended up not using. Kill it.
2016-08-19 14:04:06 -07:00
Mark Lacey
8886f77348 Increase the amount of memory we allow the constraint solver to use.
Various changes throughout the compiler and libraries appear to have
resulted in an increase in memory usage in the constraint solver since
Swift 2.2.

This is a stop-gap measure to allow more expressions to compile while
the expression type checker is being improved.

We've seen several cases where even a modest increase allows things that
compiled with Swift 2.2 to continue to compile (albeit with generally
longer compile times).
2016-08-03 20:15:48 -07:00
Jordan Rose
b5aca663bc [ClangImporter] Remove importer-based NS stripping. (#3880)
* [ClangImporter] Remove importer-based NS stripping.

As Tony puts it, in the end we wound up with more Foundation
declarations imported as members or keeping "NS" than those that
dropped it, and any further decisions will be made on a case-by-case
basis. Move all of the existing cases of prefix-stripping into
Foundation's API notes and drop the logic from the compiler.

Tested by dumping the generated interface for Foundation and its
submodules for both macOS and the iOS simulator, and comparing the
results. A few cases did slip through here because of the interaction
between "SwiftName" and "Availability: nonswift".

The next commit will re-add "NS" to some stragglers that we missed.

rdar://problem/26880017

* APINotes: Add "NS" back to a few types.

NSKeyedUnarchiverDelegate
NSKeyedArchiverDelegate
NSTextCheckingTypes
NSBinarySearchingOptions
NSEnumerationOptions
NSSortOptions

More rdar://problem/26880017

* Remove now-redundant SwiftNames from API notes.

No change observed in the generated interface of Foundation and its
submodules.

Finishes rdar://problem/26880017.
2016-08-01 20:54:26 -07:00
Chris Lattner
62e4811dac Remove support for nominal type patterns, which have never been supported in an
official swift release and have bitrotted.
2016-07-31 18:44:08 -07:00
Doug Gregor
a9536906ff [SE-0111] Drop argument labels on references to function values.
When referencing a function in the type checker, drop argument labels
when we don't need them to type-check an immediate call to that
function. This provides the semantic behavior of SE-0111, e.g.,
references to functions as values produce unlabeled function types,
without the representational change of actually dropping argument
labels from the type system.

At the moment, this only works for bare references to functions. It
still needs to be pushed through more of the type checker and more AST
nodes to work in the general case.

Keep this work behind the frontend flag
-suppress-argument-labels-in-types for now.
2016-07-28 15:40:11 -07:00
Slava Pestov
1ae8e37058 Remove -enable-protocol-typealiases staging flag
It looks like migration fixits are done, and this doesn't
expose any new bugs that were not possible before, because
you could already define typealiases inside protocol
extensions.

To prevent some compiler_crasher regressions, add a simple
circularity-breaking hack. I'll need to do a sweep to clean
these up some day soon.
2016-07-25 23:18:49 -07:00
Joe Groff
10a0eb1c13 Merge pull request #3710 from jckarter/turn-on-id-as-any
Turn on id as any
2016-07-25 18:58:27 -07:00
Jordan Rose
94a47a261a Put new private/fileprivate behavior behind a LangOptions flag.
If things don't seem to be working out, we can turn it back off,
leaving 'private' and 'fileprivate' interchangeable for compatibility.
2016-07-25 13:13:35 -07:00
Joe Groff
f5306b3865 Turn on -enable-experimental-collection-casts by default. 2016-07-25 06:01:21 -07:00
Joe Groff
0703b1937f Enable id-as-any. 2016-07-25 06:01:21 -07:00
John McCall
445ff27082 Basic Sema support for covariant collection casting.
The previous revert was required because of missing stdlib support.
I believe that support is now present, at least so that this won't
crash on Linux.
2016-07-19 14:35:03 -07:00
Mishal Shah
8a660e5b85 Revert "Basic Sema support for covariant collection casting."
Ubuntu 14.04 and 15.10 bots failing due to this commit.

This reverts commit 4b6a57292f.
2016-07-14 12:35:40 -07:00
John McCall
4b6a57292f Basic Sema support for covariant collection casting. 2016-07-13 19:13:02 -07:00
Jordan Rose
d6a726e6fe SE-0106: Add "macOS" as an alias of "OSX" for #if.
...by canonicalizing it to the known platform name. This isn't a
wonderful answer, but it preserves the invariant that a platform
condition has at most one value.

A later commit will switch which one is the default.
2016-07-07 14:57:57 -07:00
Joe Groff
8c2631a37f Merge pull request #3294 from jckarter/id-as-any-import
Initial 'id as Any' Clang importer implementation
2016-07-05 16:03:35 -07:00
Joe Groff
231db9d108 Clang importer: Import ObjC 'id' as Swift 'Any' (behind a flag).
For experimentation purposes, add a flag to cause the Clang importer to map ObjC APIs using `id` to `Any` instead of `AnyObject`.
2016-07-05 12:29:45 -07:00
Saleem Abdulrasool
83901998c9 Port for PS4
Add support for the PS4 OS.  Update the standard library and add a target unit
test.
2016-06-30 20:14:50 -07:00
Mishal Shah
87b7bcfd3e Update master to build with Xcode 8 beta 1, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-06-14 14:53:55 -07:00
Slava Pestov
011e306fe8 Sema: Add -enable-experimental-nested-generic-types frontend flag
Also, split up test/decl/nested.swift into several files.
2016-06-13 16:46:41 -07:00
gregomni
2f9ac3444e Disable typealiases in protocols and add frontend flag to re-enable.
Goes back to Swift 2.2 behavior of treating the 'typealias' keyword inside a protocol as a deprecated form of an associatedtype. To get the newer (but still partly buggy) behavior of treating it as an actual typealias, add "-Xfrontend -enable-protocol-typealiases" to the compile invocation. 'decl/typealias/typealias.swift' now uses this flag to continue testing the enabled behavior.
2016-06-01 14:11:56 -07:00
Bryan Chan
bb3486df93 Add new _endian() platform condition check; valid values are "little" and "big". 2016-05-24 19:39:15 -04:00
Chris Willmore
af0c7bd620 Initial implementation of SE-0054 "Abolish IUO Type" (#2322)
This is a squash of the following commits:

* [SE-0054] Import function pointer arg, return types, typedefs as optional

IUOs are only allowed on function decl arguments and return types, so
don't import typedefs or function pointer args or return types as IUO.

* [SE-0054] Only allow IUOs in function arg and result type.

When validating a TypeRepr, raise a diagnostic if an IUO is found
anywhere other thn the top level or as a function parameter or return
tpye.

* [SE-0054] Disable inference of IUOs by default

When considering a constraint of the form '$T1 is convertible to T!',
generate potential bindings 'T' and 'T?' for $T1, but not 'T!'. This
prevents variables without explicit type information from ending up with
IUO type. It also prevents implicit instantiation of functions and types
with IUO type arguments.

* [SE-0054] Remove the -disable-infer-iuos flag.

* Add nonnull annotations to ObjectiveCTests.h in benchmark suite.
2016-05-03 14:06:19 -07:00
Joe Groff
825e02e2f1 Remove -enable-import-objc-generics staging flag. 2016-04-25 14:25:11 -07:00
Joe Groff
c49a992598 Turn on import of ObjC generics. 2016-04-25 11:56:13 -07:00
Zhuowei Zhang
7c502b6344 Port to Android
This adds an Android target for the stdlib. It is also the first
example of cross-compiling outside of Darwin.

Mailing list discussions:

1. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151207/000171.html
2. https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000492.html

The Android variant of Swift may be built using the following `build-script`
invocation:

```
$ utils/build-script \
  -R \                                           # Build in ReleaseAssert mode.
  --android \                                    # Build for Android.
  --android-ndk ~/android-ndk-r10e \             # Path to an Android NDK.
  --android-ndk-version 21 \
  --android-icu-uc ~/libicu-android/armeabi-v7a/libicuuc.so \
  --android-icu-uc-include ~/libicu-android/armeabi-v7a/icu/source/common \
  --android-icu-i18n ~/libicu-android/armeabi-v7a/libicui18n.so \
  --android-icu-i18n-include ~/libicu-android/armeabi-v7a/icu/source/i18n/
```

Android builds have the following dependencies, as can be seen in
the build script invocation:

1. An Android NDK of version 21 or greater, available to download
   here: http://developer.android.com/ndk/downloads/index.html.
2. A libicu compatible with android-armv7.
2016-04-12 19:26:21 -04:00
Chris Lattner
821c2cb98f Merge pull request #1796 from danra/swift_basic_sanitize
Canonicalize swift header files headers and footers
2016-03-29 17:31:53 -07:00
Chris Willmore
3bcb169f0b Import lightweight Objective-C generics as Swift generic type
parameters.
2016-03-28 09:50:30 -07:00
Michael Ilseman
47e73ad4f1 Merge branch 'master' of github.com:apple/swift into import-as-member 2016-03-23 17:01:47 -07:00
Michael Ilseman
d7581d1b36 Merge commit 'a31edf53d0580efe47f4e9ef89dccc4429c056e8' into import-as-member 2016-03-23 13:05:57 -07:00
Dan Raviv
29d76f3b68 Canonize swift header files headers and footers
- Added missing ifdef guard in PointerIntEnum header
- Consistent naming convention for ifdef guards
- Consistent 'end namespace swift'
- Consistent single EOL at end of header files
2016-03-23 09:04:12 +02:00
Doug Gregor
593932741c Remove historical flags -enable-omit-needless-words/-enable-infer-default-arguments/-enable-swift-name-lookup-tables.
NFC; all of these options are always-on now and we no longer have a
way to turn them off.
2016-03-22 17:04:19 -07:00
Chris Willmore
4cc75187c6 [Sema] Flag -disable-infer-iuos: don't infer IUO type for untyped bindings
If this option is enabled, when generating potential bindings for a type
variable, don't propagate IUO type. Instead try the optional type and
the underlying type. This way, untyped bindings will not be given IUO
type when they are initialized with exprs of IUO type.
2016-03-21 17:33:29 -07:00
Michael Ilseman
1b83dee698 [Clang importer] Inferr import as member flags
Plumbing for -enable-infer-import-as-member options and flags.Tests
coming soon.
2016-03-06 23:54:56 -08:00