Commit Graph

7628 Commits

Author SHA1 Message Date
Dave Abrahams
0b40374d10 [stdlib] [Generator|Sequence]Of => Any[Generator|Sequence]
Retire the old components now that the new ones have passed API review.

<rdar://20406937> covers the migration fallout of this change.

Swift SVN r26904
2015-04-02 21:55:22 +00:00
Chris Willmore
690daa539a Back out changes for in-place methods/operators from Xcode 7.
This reverts commits r26508, r26545, and r26576.

Swift SVN r26900
2015-04-02 21:14:28 +00:00
Jordan Rose
13e8137113 [test] Add more testability tests, including execution tests.
Swift SVN r26785
2015-04-01 01:12:25 +00:00
Ted Kremenek
a01843b291 Disable running compiler_crashers tests when using Address Sanitizer.
Swift SVN r26759
2015-03-31 15:15:14 +00:00
Ted Kremenek
1d393307a9 Mark 0066-diagnoseunknowntype.swift to have an expected failure under ASan.
Swift SVN r26727
2015-03-30 21:18:42 +00:00
Chris Lattner
21b2e9e057 add parser and AST representation support for where/else clauses on let/var decls, some highlights:
- Enhance PBD with a whereExpr/elseStmt field to hold this.
- Start parsing the pattern of let/var decls as a potentially refutable pattern.  It becomes 
  a semantic error to use a refutable pattern without an 'else' (diagnostics not in place yet).
- Change validatePatternBindingDecl to use 'defer' instead of a goto to ensure cleanups on exit.
- Have it resolve the pattern in a PBD, rewriting it from expressions into pattern nodes when valid.
- Teach resolvePattern to handle TypedPatterns now that they can appear (wrapping) refutable patterns.
- Teach resolvePattern to handle refutable patterns in PBD's without initializers by emitting a diagnostic
  instead of by barfing, fixing regressions on validation tests my previous patch caused, and fixing
  two existing validation test crashers.

Sema, silgen, and more tests coming later.




Swift SVN r26706
2015-03-29 22:08:44 +00:00
Doug Gregor
2609a971b6 Perform name lookup for where clauses based on the generic parameter's context.
We were ending up looking in the parent context, but it didn't matter
because the parser pre-resolved the names of generic parameters. We
shouldn't be relying on the parser to do that.

Note that this regresses four compiler crashes, because they end up
looking back into their own generic parameter lists in unhealthy
ways. I'm going to temporarily burn some karma because of what this
enables...

Swift SVN r26688
2015-03-29 05:42:33 +00:00
Doug Gregor
d4d4694615 Introduce a few defensive null checks to fix 157 compiler crashers.
Swift SVN r26655
2015-03-27 23:57:45 +00:00
Doug Gregor
1bbcb913a3 Clean up some "XFAIL: asan"'s that are no longer valid.
Swift SVN r26596
2015-03-26 18:04:18 +00:00
Doug Gregor
3d77855b31 Start allowing extensions of protocol types.
Remove the semantic restrictions that prohibited extensions of
protocol types, and start making some systematic changes so that
protocol extensions start to make sense:
  - Replace a lot of occurrences of isa<ProtocolDecl> and
    dyn_cast<ProtocolDecl> on DeclContexts to use the new
    DeclContext::isProtocolOrProtocolExtensionContext(), where we want
    that behavior to apply equally to protocols and protocol extensions.
  - Eliminate ProtocolDecl::getSelf() in favor of
    DeclContext::getProtocolSelf(), which produces the appropriate
    generic type parameter for the 'Self' of a protocol or protocol
    extension. Update all of the callers of ProtocolDecl::getSelf()
    appropriately.
  - Update extension validation to appropriately form generic
    parameter lists for protocol extensions.
  - Methods in protocol extensions always use the witnesscc calling
  convention.

At this point, we can type check and SILGen very basic definitions of
protocol extensions with methods that can call protocol requirements,
generic free functions, and other methods within the same protocol
extension.

Regresses four compiler crashers but improves three compiler
crashers... we'll call that "progress"; the four regressions all hit
the same assertion in the constraint system that will likely be
addressed as protocol extensions starts working.

Swift SVN r26579
2015-03-26 04:50:51 +00:00
Doug Gregor
cce9081fe2 Teach getSelfTypeForContainer() that it's rude to crash when the container has no type.
Fixes 68 crashes in the compiler-crashers suite.

Swift SVN r26564
2015-03-25 23:20:59 +00:00
Chris Willmore
972d0d6cba Compiler crasher 1293 no longer crashes after r26508.
Swift SVN r26545
2015-03-25 18:46:50 +00:00
Mark Lacey
b7dc974c1f Fix test by adjusting spacing around range operator.
Swift SVN r26544
2015-03-25 18:15:38 +00:00
Dave Abrahams
2822677b4b [stdlib] Clean up some endline layout in the tests
Just following our coding convention...

Swift SVN r26507
2015-03-24 23:55:55 +00:00
Doug Gregor
a18cd9849c Update compiler crashers that don't fully crash under ASan.
rdar://problem/20198158

Swift SVN r26505
2015-03-24 23:43:56 +00:00
Graham Batty
82242f67cf Update flags for linux compat.
Swift SVN r26504
2015-03-24 23:16:57 +00:00
Dmitri Hrybenko
87aa7a25ba Update String test to new Foundation API (nullability audit)
Swift SVN r26493
2015-03-24 18:00:09 +00:00
Dmitri Hrybenko
1258662db9 CoreAudio overlay: add APIs that were blocked by rdar://16974298
(extensions on generic types in a different module)

Swift SVN r26486
2015-03-24 07:50:51 +00:00
Dmitri Hrybenko
c421c51a42 StdlibUnittest: add facilities to replace NSLocale.currentLocale()
Will use this API to write tests for rdar://20171815.

Swift SVN r26391
2015-03-21 05:41:46 +00:00
Ben Langmuir
c7da7457e6 Update validation/IDE tests missed in previous commit
Swift SVN r26263
2015-03-18 17:26:11 +00:00
Doug Gregor
7677a454ea Move "non-self-conforming protocol type" check out of type validation.
Having semantic checking in type validation introduces the potential for more recursion, triggering crashes. By moving this semantic restriction out to a later stage, we make it more robust. Fixes 6 compiler crashers, although it regressed one compiler crasher that hits a different known issue (assertions in addGenericParameters when we have multiple parameters at the same depth).

Swift SVN r26226
2015-03-17 16:34:28 +00:00
Chris Lattner
59c22383fb Rework PatternBindingDecl to maintain a list of pattern/initexpr pairs inside of it.
Previously, a multi-pattern var/let decl like:
  var x = 4, y = 17

would produce two pattern binding decls (one for x=4 one for y=17).  This is convenient
in some ways, but is bad for source reproducibility from the ASTs (see, e.g. the improvements
in test/IDE/structure.swift and test/decl/inherit/initializer.swift).

The hardest part of this change was to get parseDeclVar to set up the AST in a way
compatible with our existing assumptions. I ended up with an approach that forms PBDs in 
more erroneous cases than before.  One downside of this is that we now produce a spurious
  "type annotation missing in pattern"
diagnostic in some cases.  I'll take care of that in a follow-on patch.





Swift SVN r26224
2015-03-17 16:14:18 +00:00
Chris Lattner
bf643410d6 tweaks to the validation test RUN lines.
Swift SVN r26181
2015-03-16 15:06:28 +00:00
Chris Lattner
ce9b0131a1 Change the testsuite to not use typed patterns in nested contexts, which
requires pushing the types out.  The only interesting one is this diff:

-  var (e,f,g:(),h) = MRV()
+  var (e,f,g,h) : (Int, Float, (), Double) = MRV()

... where the type annotation is required to silence the warning about "void type
may be unexpected".  This seems perfectly reasonable to me.



Swift SVN r26161
2015-03-15 19:11:18 +00:00
Chris Lattner
20f8f09ea8 Land: <rdar://problem/19382905> improve 'if let' to support refutable patterns and untie it from optionals
This changes 'if let' conditions to take general refutable patterns, instead of
taking a irrefutable pattern and implicitly matching against an optional.

Where before you might have written:
  if let x = foo() {

you now need to write:
  if let x? = foo() {
    
The upshot of this is that you can write anything in an 'if let' that you can
write in a 'case let' in a switch statement, which is pretty general.

To aid with migration, this special cases certain really common patterns like
the above (and any other irrefutable cases, like "if let (a,b) = foo()", and
tells you where to insert the ?.  It also special cases type annotations like
"if let x : AnyObject = " since they are no longer allowed.

For transitional purposes, I have intentionally downgraded the most common
diagnostic into a warning instead of an error.  This means that you'll get:

t.swift:26:10: warning: condition requires a refutable pattern match; did you mean to match an optional?
if let a = f() {
       ^
        ?

I think this is important to stage in, because this is a pretty significant
source breaking change and not everyone internally may want to deal with it
at the same time.  I filed 20166013 to remember to upgrade this to an error.

In addition to being a nice user feature, this is a nice cleanup of the guts
of the compiler, since it eliminates the "isConditional()" bit from
PatternBindingDecl, along with the special case logic in the compiler to handle
it (which variously added and removed Optional around these things).




Swift SVN r26150
2015-03-15 07:06:22 +00:00
Graham Batty
388f0dd5de Check if existing capacity is enough even on non-objc.
Fixes rdar://problem/20089729

Swift SVN r26109
2015-03-13 20:14:20 +00:00
Dmitri Hrybenko
445d51c551 Annotate tests that don't crash under AddressSanitizer anymore
Swift SVN r26096
2015-03-13 07:42:45 +00:00
Chris Lattner
718d82f5c9 rework our treatment of identifiers in refutable patterns that are inside of
a let/var pattern.  Now any identifier in one of these is a variable binding,
not sometimes a value references (depending on contextual syntax).

This isn't expected to have a widespread effect on existing real world code:
 - No impact on the stdlib.
 - It does fix two validation crash tests, but possibly because the original issue is hidden by a different diagnostic path in the compiler.
 - This needed two tests to be tweaked to undistribute "let".

On the positive side, this means that "case let x?:" now works properly, woo.



Swift SVN r26000
2015-03-11 23:08:55 +00:00
Dmitri Hrybenko
c31c286932 Annotate valiation tests that don't crash without assertions anymore
Swift SVN r25970
2015-03-11 05:46:04 +00:00
Dmitri Hrybenko
1048d5703b Add a test for assertionFailure not being @noreturn
It is a no-op in -O.

Swift SVN r25920
2015-03-10 07:25:50 +00:00
Dave Abrahams
6423209466 [stdlib] Fix assert docs and semantics
We must not lie to the user or to the optimizer!

Swift SVN r25913
2015-03-10 04:37:12 +00:00
Dmitri Hrybenko
e460eb6264 Revert "[stdlib] Replace aString.toInt() with Int(aString)"
This reverts commit r25636.  It depends on integer parsing APIs, which
are being moved to SwiftExperimental.

Swift SVN r25889
2015-03-09 19:04:18 +00:00
Dmitri Hrybenko
abd0b72638 SwiftPrivateSerialization: refuse to deserialize extremely large arrays
and dictionaries on 32-bit platforms, where size does not fit into an
Int

Swift SVN r25886
2015-03-09 17:10:07 +00:00
Dmitri Hrybenko
3d548845f5 Disable the serialization test on Linux, since it does not finish in any
reasonable time

Swift SVN r25882
2015-03-09 10:09:37 +00:00
Dmitri Hrybenko
b7498a1efd stdlib: add a private serialization API
These APIs will be used for writing automation tools in Swift.  Just
like other private APIs, this module is not exposed to extrenal users.

The primary motivation for doing instead of using NSCoder this is that
NSCoder does not work with structs and Swift containers.  Using classes
for everything just to satisfy NSCoder forces unnatural code.

This API requires two times (!) less boilerplate than NSCoding, since
the same method is used for serialization and deserialization.  This API
is also more type-safe, it does not require the user to write 'as' type
casts, unlike NSCoding.

Please take a look at
validation-test/stdlib/SwiftPrivateSerialization.swift to see the
intended use pattern.

The performance of the underlying implementation is already decent, and
there's a lot of room for improvement.

This is a re-commit of r25678, with a fix for 32-bit platforms.

Swift SVN r25877
2015-03-09 06:55:19 +00:00
Dmitri Hrybenko
350248dae5 Reorganize the directory structure under 'stdlib'
The standard library has grown significantly, and we need a new
directory structure that clearly reflects the role of the APIs, and
allows future growth.

See stdlib/{public,internal,private}/README.txt for more information.

Swift SVN r25876
2015-03-09 05:26:05 +00:00
Dmitri Hrybenko
e58d06c8d6 StdlibUnittest: run race tests for equal amount of time on small and
large machines

Swift SVN r25859
2015-03-08 11:31:26 +00:00
Dmitri Hrybenko
dfe04e55da tests: port StringSlicesConcurrentAppend.swift to Linux
Swift SVN r25858
2015-03-08 11:31:24 +00:00
Dmitri Hrybenko
1d2f5ed69e Hide the SwiftUnstable dependency on libbsd on Linux
Swift SVN r25857
2015-03-08 11:31:23 +00:00
Dmitri Hrybenko
524f8c4a8c tests: port StdlibUnittestStdin.swift to Linux
Swift SVN r25856
2015-03-08 11:31:21 +00:00
Dmitri Hrybenko
0326cfede2 Fix the Concatenate.swift test on Linux
Looks like on Linux, GNU ld is more agressive at removing internal
stdlib symbols, so -disable-access-control is even less useful.

Swift SVN r25855
2015-03-08 06:48:18 +00:00
Dmitri Hrybenko
eee130d9d4 tests: set %target-sdk-name on Linux
Swift SVN r25853
2015-03-08 06:33:40 +00:00
Dmitri Hrybenko
ff508c94f0 StdlibUnittest: implement test().xfail() matchers for Linux
Swift SVN r25849
2015-03-08 04:15:12 +00:00
Dmitri Hrybenko
7ec747157f More tests pass on Linux when autolinking information is present in -O
Swift SVN r25848
2015-03-08 04:15:10 +00:00
Graham Batty
0a73f54e98 Implement a glibc module for StdlibUnittest on linux
Swift SVN r25807
2015-03-06 22:05:13 +00:00
Graham Batty
dd92de792f Use ICU to implement basic string functions.
Swift SVN r25803
2015-03-06 19:15:34 +00:00
Dmitri Hrybenko
99904a02b5 Revert "XFAIL for <rdar://problem/20035755> Swift.stdlib.HashingAvalanche.swift test failure on incremental RA"
This reverts commit r25753. The failure is caused by unstable iOS
testing tools.

Swift SVN r25754
2015-03-04 08:47:35 +00:00
Andrew Trick
35b9707184 XFAIL for <rdar://problem/20035755> Swift.stdlib.HashingAvalanche.swift test failure on incremental RA
Swift SVN r25753
2015-03-04 08:40:29 +00:00
Graham Batty
98be432723 Updating tests and flags for linux
Swift SVN r25714
2015-03-03 18:26:20 +00:00
Doug Gregor
57a056dcef Revert "stdlib: add an experimental serialization API"
This reverts commit r25678, which breaks the build:

/Users/dgregor/Projects/Apple/swift/stdlib/serialization/MsgPack.swift:117:34: error: integer literal overflows when stored into 'Int'
    } else if utf8Bytes.count <= 0xffff_ffff {
                                 ^
/Users/dgregor/Projects/Apple/swift/stdlib/serialization/MsgPack.swift:139:34: error: integer literal overflows when stored into 'Int'
    } else if dataBytes.count <= 0xffff_ffff {
                                 ^
/Users/dgregor/Projects/Apple/swift/stdlib/serialization/MsgPack.swift:160:24: error: integer literal overflows when stored into 'Int'
    } else if count <= 0xffff_ffff {
                       ^
/Users/dgregor/Projects/Apple/swift/stdlib/serialization/MsgPack.swift:189:31: error: integer literal overflows when stored into 'Int'
    } else if mappingCount <= 0xffff_ffff {
                              ^
/Users/dgregor/Projects/Apple/swift/stdlib/serialization/MsgPack.swift:235:29: error: integer literal overflows when stored into 'Int'
    } else if data.count <= 0xffff_ffff {
                            ^

Swift SVN r25693
2015-03-02 22:41:29 +00:00