Commit Graph

21665 Commits

Author SHA1 Message Date
Joe Groff
a87e9fa40c Make the diagnostic for unsupported existentials more accurate and helpful.
Better to describe how the protocol can be used than how it can't. Also include a mention of Self type requirements as a source of non-existentiability.

Swift SVN r19207
2014-06-26 01:02:03 +00:00
Joe Groff
e2f632589a stdlib: Add subscript and .null() interfaces to AutoreleasingUnsafePointer.
To make it more UnsafePointer-like.

Swift SVN r19206
2014-06-26 01:02:01 +00:00
Joe Groff
8eec49e50c stdlib: Introduce a staging typealias for the itemsPtr of fast enumeration states.
We (correctly) import this as AutoreleasingUnsafePointer instead of UnsafePointer in the new regime, but need to stage out the old regime fully before switching over.

Swift SVN r19200
2014-06-26 00:21:20 +00:00
Joe Groff
cd418a944c stdlib: Add explicit AutoreleasingUnsafePointer(*UnsafePointer) constructors.
Allow these explicit conversions by constructor, the same way we do between UnsafePointer and ConstUnsafePointer.

Swift SVN r19199
2014-06-26 00:21:20 +00:00
Manman Ren
0501da8f54 [stdlib] use noinline to get rid of closure.
Remove wrapping the callee in a closure to disable inlining, instead mark callee
as noinline.

No performance change is observed.


Swift SVN r19194
2014-06-25 23:50:14 +00:00
Doug Gregor
37df5c430c Update standard library to use [T] array syntax.
Swift SVN r19190
2014-06-25 23:39:20 +00:00
Enrico Granata
1860612161 Add reflection support for Swift.Character. Testing will follow
Swift SVN r19189
2014-06-25 23:36:52 +00:00
Dmitri Hrybenko
6b2c727850 stdlib/String: change UTF-16/UTF-16 transcoder in UTF16View to replace
ill-formed code unit sequences with U+FFFD

rdar://17451259


Swift SVN r19187
2014-06-25 22:28:33 +00:00
Manman Ren
544cd15eb9 [stdlib] add noinline on makeUnique.
Swift SVN r19174
2014-06-25 18:39:49 +00:00
Nadav Rotem
a3d2883887 Refactor the makeUnique parts of array subscript outside of the closure. We inline this closure with the new pass order.
Swift SVN r19164
2014-06-25 17:13:50 +00:00
Joe Groff
87dd6ed419 stdlib: Add #ifs to help stage in pointer conversions.
Hide the bridged C*Pointer types if the stdlib is built with -DENABLE_POINTER_CONVERSIONS as a temporary transition aid.

Swift SVN r19159
2014-06-25 16:37:25 +00:00
Dmitri Hrybenko
6bb6e1b0b4 stdlib/String: if we can not get a contiguous data buffer out of NSString,
don't call into CoreFoundation to perform UTF-8 transcoding.  CoreFoundation
can replace ill-formed sequences with a single byte, which is not good enough
to implement U+FFFD insertion.  Instead, use the same transcoding routine as
for contiguous buffer.

Pulled out the transcoding routine into a generic function that should be
specialized and simplified for the case when input is UnsafeArray; we should
not be losing efficiency here.

Fixes <rdar://problem/17297055> [unicode] println crashes when given string
with unpaired surrogate



Swift SVN r19157
2014-06-25 13:24:15 +00:00
Jordan Rose
ce4dcb7a5f [ClangImporter] Import C function types as CFunctionPointer<T>.
...where T is the equivalent Swift function type. This gives us proper type
safety (ish) for C function pointers while still not treating them the same
as Swift closures.

If the function type is not one we can represent in Swift, we fall back to
COpaquePointer. CFunctionPointer<T> and COpaquePointer can be explicitly
constructed from one another, but do not freely convert.

<rdar://problem/17215978>

Swift SVN r19154
2014-06-25 00:33:06 +00:00
Ted Kremenek
0ce574eb9e Correct mistake where some 'pred' arguments became 'predecessor' instead of 'predicate'.
Thanks to Dmitri and Joe for pointing this out.

Swift SVN r19151
2014-06-24 23:47:00 +00:00
Dmitri Hrybenko
9bd0b1e8d3 stdlib: fix some bugs in UTF-16/UTF-8 transcoder that is hidden inside String
implementation:

- don't crash on NSStrings that contain isolated surrogates (partial fix, there
  is a different code path that dispatches CoreFoundation and it still
  crashes);

- insert U+FFFD according to Unicode recommendation;

- fix decoding of surrogate pairs when the internal buffer is almost full
  (we used to drop characters in that case, rdar://16833733 + dups).


Swift SVN r19147
2014-06-24 21:59:19 +00:00
Jordan Rose
cca27d02a0 Tag everything in the standard library with accessibility attributes.
Keep calm: remember that the standard library has many more public exports
than the average target, and that this contains ALL of them at once.
I also deliberately tried to tag nearly every top-level decl, even if that
was just to explicitly mark things @internal, to make sure I didn't miss
something.

This does export more than we might want to, mostly for protocol conformance
reasons, along with our simple-but-limiting typealias rule. I tried to also
mark things private where possible, but it's really going to be up to the
standard library owners to get this right. This is also only validated
against top-level access control; I haven't fully tested against member-level
access control yet, and none of our semantic restrictions are in place.

Along the way I also noticed bits of stdlib cruft; to keep this patch
understandable, I didn't change any of them.

Swift SVN r19145
2014-06-24 21:32:18 +00:00
Ted Kremenek
58558fcca3 Rename 'succ' and 'pred' to 'successor' and 'predecessor' respectively.
This is motivated by <rdar://problem/17051606>.

This ends up renaming variables as well, which seems right for
consistency since we use "predicate" as variable name.

Swift SVN r19135
2014-06-24 19:27:19 +00:00
Joe Groff
0db8de1341 SILGen: Implement inout-to-pointer conversion.
For writeback through an AutoreleasingUnsafePointer, create an intrinsic AutoreleasingWritebackComponent we can append to lvalues.

Swift SVN r19134
2014-06-24 15:11:41 +00:00
Enrico Granata
2ab2e6c07b Change the very cryptic "don't ask" to something more informative
Fixes <rdar://problem/16922703>



Swift SVN r19123
2014-06-24 01:50:02 +00:00
Jordan Rose
678bbfe683 [stdlib] Remove posix_read/posix_write asmname stubs.
...and move them into the one prototype that uses them. Also modernize
the interfaces a bit.

Swift SVN r19120
2014-06-24 01:23:05 +00:00
Jordan Rose
7d649e0a16 Use "_" instead of "c_" for primitive functions accessed through asmname.
No functionality change.

Swift SVN r19119
2014-06-24 01:23:04 +00:00
Chris Hanson
5b9b67e900 Revert "Remove XCTest overlay"
We need to actually keep the XCTest support in an overlay for now.

This reverts commit 4a2726862634a553483943baf39a251ac8071e37.

Addresses <rdar://problem/17423669>.

Swift SVN r19101
2014-06-23 21:00:47 +00:00
Dmitri Hrybenko
3cdc901354 stdlib/Unicode: fix UTF-32 decoder not to crash on invalid code units
Also implemented U+FFFD insertion in UTF-32 decoder according to Unicode
reccomendation.


Swift SVN r19092
2014-06-23 15:40:22 +00:00
Dmitri Hrybenko
2103b1d995 stdlib/Unicode: fix UTF-16 decoder not to crash on invalid code unit sequences
Also implemented U+FFFD insertion in UTF-16 decoder according to Unicode
reccomendation.


Swift SVN r19091
2014-06-23 14:52:24 +00:00
Joe Groff
1a1683e813 stdlib: Add internal entry points that can be used by intrinsic pointer conversions.
Swift SVN r19084
2014-06-22 20:10:19 +00:00
John McCall
d0dc196e8b Fix a metatype casting bug in the new casting runtime.
Swift SVN r19078
2014-06-22 09:53:34 +00:00
Greg Parker
6493bee517 Remove now-unnecessary extra retain during heap object destruction.
RC_DEALLOCATING_BIT prevents re-entrance into the destructor 
due to balanced retain/release during destruction.


Swift SVN r19060
2014-06-21 00:36:44 +00:00
Dmitri Hrybenko
aa7d6d690d Work around SIL optimizer bug to allow stdlib to be built with
optimizations

Swift SVN r19050
2014-06-20 20:03:47 +00:00
Doug Gregor
e47b0c220f Address Dmitri's review comments
Swift SVN r19047
2014-06-20 13:57:00 +00:00
Doug Gregor
22dc55058e Make bridgeFromObjectiveC return non-optional.
Now that we use bridgeFromObjectiveCConditional to perform conditional
bridging, make bridgeFromObjectiveC handle forced bridging. For the
latter, deferred checking is acceptable.

Almost all of <rdar://problem/17319154>.


Swift SVN r19046
2014-06-20 13:15:41 +00:00
Dmitri Hrybenko
f370ca0746 stdlib: fix a bunch of various Unicode issues, primarily in UTF-8 decoding
In UTF-8 decoder:
- implement U+FFFD insertion according to the recommendation given in the
  Unicode spec.  This required changing the decoder to become stateful, which
  significantly increased complexity due to the need to maintain an internal
  buffer.
- reject invalid code unit sequences properly instead of crashing rdar://16767868
- reject overlong sequences rdar://16767911

In stdlib:
- change APIs that assume that UTF decoding can never fail to account for
  possibility of errors
- fix a bug in UnicodeScalarView that could cause a crash during backward
  iteration if U+8000 is present in the string
- allow noncharacters in UnicodeScalar.  They are explicitly allowed in the
  definition of "Unicode scalar" in the specification.  Disallowing noncharacters
  in UnicodeScalar prevents actually using these scalar values as internal
  special values during string processing, which is exactly the reason why they
  are reserved in the first place.
- fix a crash in String.fromCString() that could happen if it was passed a null
  pointer

In Lexer:
- allow noncharacters in string literals.  These Unicode scalar values are not
  allowed to be exchanged externally, but it is totally reasonable to have them
  in literals as long as they don't escape the program.  For example, using
  U+FFFF as a delimiter and then calling str.split("\uffff") is completely
  reasonable.

This is a lot of changes in a single commit; the primary reason why they are
lumped together is the need to change stdlib APIs to account for the
possibility of UTF decoding failure, and this has long-reaching effects
throughout stdlib where these APIs are used.


Swift SVN r19045
2014-06-20 13:07:40 +00:00
John McCall
47427ccc5a Ensure that we deallocate opaque existential containers
if we dynamic-cast out of them as a take.

Swift SVN r19043
2014-06-20 07:47:01 +00:00
Doug Gregor
fd62de4373 Use bridgeFromObjectiveCConditional where we want conditional bridging.
More of <rdar://problem/17319154>.


Swift SVN r19038
2014-06-20 07:41:50 +00:00
Michael Gottesman
e269523e48 Reintroduce discriminator bit stripping in the runtime that was reverted
when I undid the array enum change in r19026.

Swift SVN r19028
2014-06-20 02:40:57 +00:00
Michael Gottesman
8de060ff3f Revert "[stdlib] mask unused bits in uniqueness checks"
Revert "[stdlib] Use an enum for ArrayBuffer storage"

This reverts commit r18996.
This reverts commit r18954.

The optimizer is not ready yet to handle this change especially given
the time until Beta 3. After speaking with DaveA, we agreed to revert
this and take such large changes onto private branches until we are sure
that the optimizer is ready to handle them rather than risking
performance regressions due to hitting the "optimization cliff".

Swift SVN r19026
2014-06-20 01:41:04 +00:00
Dmitri Hrybenko
c4fd1c4092 stdlib: explain the trick used to achieve @noinline without @noinline
Swift SVN r19018
2014-06-19 23:53:09 +00:00
Chris Hanson
7d1cf3d107 Remove XCTest overlay
The XCTest support for Swift is now built as part of XCTest.framework
itself, so the overlay is no longer necessary.

Addresses <rdar://problem/17383462>.

Swift SVN r19016
2014-06-19 22:08:52 +00:00
Jordan Rose
f60213e4e6 Update Joe's UnsafePointer changes to account for Chris's ..< changes.
Swift SVN r19010
2014-06-19 18:09:55 +00:00
Jordan Rose
fe5c879a1a Work around single-expression closure not returning Void.
Swift SVN r19009
2014-06-19 18:04:21 +00:00
Chris Lattner
63e34d727c fix doc comment.
Swift SVN r19007
2014-06-19 18:02:31 +00:00
Chris Lattner
444d835d00 implement <rdar://problem/17054014> map method should exist on ranges
Swift SVN r19006
2014-06-19 18:01:05 +00:00
Kuba Brecka
1da7379ff2 Changing putchar's prototype to match the C version (missing return type).
Swift SVN r19005
2014-06-19 17:32:30 +00:00
Chris Lattner
aa722e4100 mark .. as unavailable and add the operator change to the release notes. I filed
rdar://17380298 to track removing .. entirely for GM.

This finishes <rdar://problem/17203527> Swift range operators too easy to mis-type: change .. to ..<


Swift SVN r19004
2014-06-19 17:22:01 +00:00
Kuba Brecka
7f69d6d27d strcmp has a wrong prototype, the return type in C is 'int' which doesn't map to Swift Int.
Swift SVN r19002
2014-06-19 17:16:43 +00:00
Doug Gregor
2e3863b211 Introduce _ConditionallyBridgedToObjectiveC.bridgeFromObjectiveCConditional.
This entry point is used in conditional downcasts (as?) to attempt to
bridge from an Objective-C class down to a specific native type (e.g.,
array, dictionary), bridging all elements eagerly so that it can
produce nil if the bridging would fail.

This is the scaffolding for <rdar://problem/17319154>, and makes the
example there work, but there is much more cleanup and optimization to
do.



Swift SVN r18999
2014-06-19 14:48:00 +00:00
Chris Lattner
62cad3dce8 add a "..<" operator, which is an alias for ".." and switch the stdlib to use it.
Until I have a chance to update the testsuite, we'll accept both.



Swift SVN r18998
2014-06-19 05:42:29 +00:00
Dave Abrahams
2b82e8988f [stdlib] mask unused bits in uniqueness checks
Also update ArrayBuffer to take advantage of it.

This change allows us to pass a word-sized enum with a native object
reference payload directly to the runtime, without switching on the enum
to unwrap the contents.  Even though that unwrapping was semantically
equivalent to bit masking, it was causing fits in the optimizer.

Swift SVN r18996
2014-06-19 02:32:07 +00:00
John McCall
7effec113c Change ImplicitlyUnwrappedOptional to be an enum type itself,
not a struct wrapping an Optional.

Among other things, this means you can now pattern-match on
an IUO.  It also makes it more convenient to build and destroy
them.

SILGen's type lowering should probably canonicalize one kind
of optional to the other so that we don't get silly abstraction
costs from conversion.

Swift SVN r18991
2014-06-18 23:27:08 +00:00
Dave Abrahams
89fb9c8bea [stdlib] Factor out Array growth calculation
This enables testing of other growth factors, per
<rdar://problem/17230502>.  See the radar for basic performance test
results confirming (to the degree practical) that 2x growth is better
than 1.5x in our current system.

Swift SVN r18990
2014-06-18 23:17:06 +00:00
Enrico Granata
da4044a4b0 I have a theory that the logger is getting malformed strings in some cases because this table of metadatakind to string is incomplete, and as such sometimes garbled data ends up being logged. Even though MagicMirror should only be generated in a few controlled cases, it seems possible that there are more such cases than I initially envisioned - hence the issue. This is my attempt at a fix here
Swift SVN r18986
2014-06-18 22:57:21 +00:00