Commit Graph

3245 Commits

Author SHA1 Message Date
Dmitri Hrybenko
09bbec7464 stdlib: fix a crash in String.rangeOfString when the result is NSNotFound
rdar://17550857


Swift SVN r19611
2014-07-07 15:25:10 +00:00
Dmitri Hrybenko
92d890361f Update references to isUniquelyReferenced in tests
Swift SVN r19600
2014-07-07 10:13:40 +00:00
Dmitri Hrybenko
62c772ad6a stdlib: hide Objective-C bridging implementation details
Swift SVN r19595
2014-07-07 09:46:07 +00:00
Dmitri Hrybenko
8a3c73e08a stdlib: hide countLeadingZeros
Swift SVN r19592
2014-07-07 09:45:56 +00:00
Chris Lattner
6b45c481eb correctly disable this
Swift SVN r19579
2014-07-04 22:24:46 +00:00
Chris Lattner
fd326a4b43 disable two more tests that take 60s to run and are very narrow in terms of utility.
Swift SVN r19578
2014-07-04 21:19:59 +00:00
Chris Lattner
24ffd63fed turn two tests into long_tests, they take 2 minutes each to run.
Swift SVN r19576
2014-07-04 21:04:23 +00:00
Chris Lattner
0ad1c248c8 fix <rdar://problem/17493994> String.toInt() returns 0 (not nil) for some non-numeric characters
Swift SVN r19575
2014-07-04 21:02:49 +00:00
Chris Lattner
011d5c6317 reformat some test lines NFC.
Swift SVN r19574
2014-07-04 21:02:35 +00:00
Dmitri Hrybenko
6e5060d471 stdlib/UnicodeScalar: remove arithmetic operations, they interact in
non-obvious ways with double-quoted literal sytax; "1" - "1" used to compile

rdar://17225816


Swift SVN r19563
2014-07-04 13:11:52 +00:00
Dmitri Hrybenko
cf2c5386a9 stdlib: change ReverseRange.isEmpty() into a property
Swift SVN r19562
2014-07-04 12:46:21 +00:00
Dmitri Hrybenko
ac7fee3a64 stdlib: add Dictionary.isEmpty property
Swift SVN r19561
2014-07-04 11:27:48 +00:00
Dmitri Hrybenko
3422201d21 stdlib/String: move lowercaseString and uppercaseString properties to
Foundation, and have them forward to Foundation.

This is slower than it could be, but at least this way we produce correct
results.

Another part of rdar://17550187


Swift SVN r19560
2014-07-04 09:27:32 +00:00
Jordan Rose
bdd1ec3116 Update stdlib and tests for accessibility, again.
I'll be turning on access control early next week.

Swift SVN r19551
2014-07-04 01:53:53 +00:00
Enrico Granata
b0548f13cd Start using the Mirror Generator
This commit removes Mirrors for RangeGenerators, since Dave and I discussed that these won't be necessary in practice
Also, it removes the Mirrors for Range types from Range.swift.gyb, and instead adds a new RangeMirrors.swift.gyb used to generate range types Mirrors



Swift SVN r19543
2014-07-03 23:43:14 +00:00
Dmitri Hrybenko
dfeaa1c360 FixedPointArithmeticTraps test: don't check for LLVM Int8*Int8 bug, it is not
present in all LLVM branches that we care about, and it is an x86-only bug


Swift SVN r19541
2014-07-03 23:04:51 +00:00
Dave Abrahams
47962b79d8 [stdlib] Slightly broaden inout violation tests
Addresses <rdar://problem/17551667>

Swift SVN r19539
2014-07-03 22:48:55 +00:00
Dave Abrahams
1f68ff48cc [stdlib] Detect/fix potential memory-safety issue
When a user violates the inout rules by "re-entering" an array that is
currently undergoing mutation, it must not admit a memory-safety
violation.  To ensure that it doesn't, temporarily make the buffer being
operated on inaccessible through the original array.

Swift SVN r19532
2014-07-03 21:44:49 +00:00
Dmitri Hrybenko
c2ae63ba72 stdlib/UnicodeScalar: hide APIs that don't work with non-ASCII correctly
rdar://17550187


Swift SVN r19513
2014-07-03 14:47:35 +00:00
Dmitri Hrybenko
75fd9cab1e stdlib/overflow checking for fixed point: add a test that checks all
combinations of types and operations

This uncovered a bug in LLVM:
<rdar://problem/17549300> [FastISel?] LLVM miscompiles @llvm.smul.with.overflow.i8 on x86-64

I was adding this test in response to rdar://16359498


Swift SVN r19510
2014-07-03 13:54:45 +00:00
Dmitri Hrybenko
e4b62021a6 stdlib/overflow trap test: the optimizer is becoming more and more powerful;
load constants using functions that are truly opaque to the optimizer


Swift SVN r19507
2014-07-03 10:07:50 +00:00
Doug Gregor
37d69a4207 Allocator: round the size of an allocation up to the alignment on all allocation and deallocation paths.
We were rounding the size up to the alignment when allocating a new object (swift_allocObject) but not when directly allocating memory for a non-object (swift_slowAlloc). The deallocation code wasn’t rounding the size up to the alignment at all. Overall, this meant that we would get the wrong index into the allocation cache when deallocating an object whose size got rounded in a way that affects the index.

Fixes <rdar://problem/17542859>, where println(5) would fail on the 32-bit iOS simulator when building the runtime without NDEBUG (so we get extra checking) and the standard library is built without optimization (which keeps a certain 33-byte allocation on the heap). The Interpreter/SDK/objc_cast.swift test triggers this when built under those conditions.

Swift SVN r19499
2014-07-03 02:11:50 +00:00
Joe Groff
c34b4f6a9e Enable string-to-pointer conversions and remove CString.
There is some follow-up work remaining:

- test/stdlib/UnicodeTrie test kills the type checker without manual type annotations. <rdar://problem/17539704>
- test/Sema/availability test raises a type error on 'a: String == nil', which we want, but probably not as a side effect of string-to-pointer conversions. I'll fix this next.

Swift SVN r19477
2014-07-02 19:15:10 +00:00
Doug Gregor
4efc07c222 Promote warning about T[] array syntax to an error <rdar://problem/17461007>.
Swift SVN r19471
2014-07-02 18:09:28 +00:00
Dmitri Hrybenko
f3c7bdc273 stdlib/NSString APIs on String: change substringFromIndex() and
substringToIndex() to accept String.Index instead of Int

rdar://17306557


Swift SVN r19467
2014-07-02 15:58:59 +00:00
Dmitri Hrybenko
57df21cefe stdlib/comments: UTF-8 and UTF-16 are spelled with a dash
Swift SVN r19466
2014-07-02 15:45:38 +00:00
Dmitri Hrybenko
99f9f721f2 Add a test for != comparison of COpaquePointer and nil
rdar://17042852


Swift SVN r19465
2014-07-02 15:08:31 +00:00
Dmitri Hrybenko
7e4c6782ee stdlib/String: rename String.utf16count -> .utf16Count to follow naming
conventions

rdar://17016806


Swift SVN r19463
2014-07-02 15:03:02 +00:00
Dmitri Hrybenko
313cfcaaa7 Unicode trie generator: add tests for the generator itself that use non-default
trie parameters and fix a few bugs

The bugs did not affect correctness of the particular instance of trie created
for grapheme cluster property, because trie parameters that were confused with
each other happened to be equal.

Also, fix a trie size bug: we were creating a trie large enough to store
information for 0x200000 code points, but there are only 0x10ffff.  It saved
only 15 bytes in the grapheme cluster tree, because that extra information was
compressed with some supplementary planes that also had default values.  This
also improved trie generation time by almost 2x.


Swift SVN r19457
2014-07-02 10:29:52 +00:00
Chris Lattner
287059b360 implement <rdar://problem/17279286> Swift has too many Unicode escape sequence forms
This consolidates the \x, \u, and \U escape sequences into one \u{abc} escape sequence.
For now we still parse and cleanly reject the old forms with a nice error message, this
will eventually be removed in a later beta (tracked by rdar://17527814)


Swift SVN r19435
2014-07-01 23:27:44 +00:00
Dmitri Hrybenko
628a300039 UnicodeTrie tests: add more comments
Swift SVN r19399
2014-07-01 13:18:28 +00:00
Dmitri Hrybenko
a37dd8c60f stdlib/Unicode tests: uncomment a test that I accidentally committed
in commented out state

Swift SVN r19392
2014-07-01 13:18:13 +00:00
Greg Parker
3df563f233 [stdlib] Revert r19835 because it doesn't work on iOS.
Swift SVN r19387
2014-07-01 01:35:48 +00:00
Enrico Granata
9abfdb372e Add a Mirror for UnsafePointer
The one design choice here was whether to expose the pointee directly through the Mirror

My choice was against that. Instead, we present UnsafePointer as UnsafePointer(0x123) and the child we expose is the 0x123 numeric pointer value

The other option, of course, would be to present it as UnsafePointer(reflect(memory)) - but that seems risky to do by default
UnsafePointers are allowed to be in, guess what, unsafe states, and the stakes of having playgrounds try and dereference at all times are quite too high.

If the user really wants to reflect the pointee reflect(pointer.memory) will do it for them - and then any crashes will be theirs to enjoy.

Of course, I am very open to arguments as to why reflect(memory) would be a better choice.



Swift SVN r19386
2014-07-01 00:54:52 +00:00
Dave Abrahams
46d9d0d4df [stdlib] Bridge the types NSValue wraps explicitly
NSRange, NSPoint, NSSize, and NSRect

Fixes <rdar://problem/16973060>

Swift SVN r19385
2014-07-01 00:14:09 +00:00
Enrico Granata
0f706ba86c Add a Mirror for EmptyCollection. Oh, and test cases too.
Swift SVN r19380
2014-06-30 23:21:08 +00:00
Dave Abrahams
6dfef2b33b [stdlib] Add a test for UnsafeArray precondition
Also clean out redundant specification of FileCheck prefix

Swift SVN r19378
2014-06-30 22:57:56 +00:00
Dave Abrahams
127a3e59d2 [stdlib] give filter() the eager treatment, too
Swift SVN r19368
2014-06-30 20:56:11 +00:00
Enrico Granata
b97490b139 Add a test for the CollectionOfOne Mirror
Swift SVN r19365
2014-06-30 20:30:05 +00:00
Dave Abrahams
52c01c9ee4 [stdlib] Give filter() the lazy() treatment
Swift SVN r19359
2014-06-30 19:32:34 +00:00
Jordan Rose
73c041b128 Revert one test change that happens after access control goes into effect.
(This is a pretty lousy error no matter what, though.)

Swift SVN r19356
2014-06-30 19:04:52 +00:00
Jordan Rose
e9f6fba434 Update tests for memberwise accessibility.
Swift SVN r19354
2014-06-30 18:50:51 +00:00
Jordan Rose
5557c3972b Update tests for accessibility.
In most cases this means adding @public to things that get serialized;
in a few cases it means using a modern public stdlib API instead of
a legacy thing I was trying to keep @internal.

Swift SVN r19350
2014-06-30 18:50:40 +00:00
Dmitri Hrybenko
68c7a45c9b stdlib/printing: change Optional<T> representation in print to be Optional(...)
Because we are adding text to show internal representation, change the
conformance from Printable to DebugPrintable.

rdar://16950055


Swift SVN r19341
2014-06-30 15:23:51 +00:00
Dmitri Hrybenko
4814e00fda stdlib/String: implement Unicode extended grapheme cluster segmentation
algorithm

The implementation uses a specialized trie that has not been tuned to the table
data.  I tried guessing parameter values that should work well, but did not do
any performance measurements.

There is no efficient way to initialize arrays with static data in Swift.  The
required tables are being generated as C++ code in the runtime library.

rdar://16013860


Swift SVN r19340
2014-06-30 14:38:53 +00:00
Dmitri Hrybenko
50a5b303a1 stdlib/String.UnicodeScalarView: rename _base to _core
NFC; improves readability of future commits.

Swift SVN r19337
2014-06-30 12:02:36 +00:00
Dmitri Hrybenko
450c21f4ec stdlib/String.UnicodeScalarView: fix out-of-bounds read of the
underlying NSString when it ends in a high-surrogate code unit

The tests did not catch this because they were creating CFString, which,
as it turns out, does not perform bounds checking.  Replaced the use of
CFString with a custom NSString subclass.

Swift SVN r19329
2014-06-30 11:54:51 +00:00
Dave Abrahams
6b0d2f92f0 [stdlib] Give reverse() the lazy() treatment
This one shows the unfortunate consequence that we need
Lazy[Forward|Bidirectional|RandomAccess]Collection.  There's gonna be a
whole lotta gyb'bing going on...

Swift SVN r19316
2014-06-28 01:35:34 +00:00
Dave Abrahams
ab322aead3 [stdlib] Introduce/use a free array-yeilding map()
Some of the lazy() instances in the previous commit that were being
immediately array'd are now even simpler.

Swift SVN r19313
2014-06-28 00:35:43 +00:00
Dave Abrahams
a7f6b97222 [stdlib] Introduce lazy() and use it for mapping
Swift SVN r19312
2014-06-28 00:35:43 +00:00