Commit Graph

675 Commits

Author SHA1 Message Date
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
36cbfe3c8f stdlib: fix grammar mistake in API name (introduced by me), and use a better
name suggested by Dave

enum UTFDecodeResult -> enum UnicodeDecodingResult


Swift SVN r19462
2014-07-02 14:58:31 +00:00
Dmitri Hrybenko
f7e926e5b0 stdlib/Arrays: refer to the parameter correctly.
Swift SVN r19460
2014-07-02 14:32:50 +00:00
Dmitri Hrybenko
db4fbb4f33 stdlib/Array: use monospaced text in a comment
Swift SVN r19459
2014-07-02 14:15:38 +00:00
Dmitri Hrybenko
b304e651c8 stdlib/HeapBuffer: add a message to a runtime trap
Swift SVN r19458
2014-07-02 14:14:55 +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
Andrew Trick
8122715df7 Teach the ColdBlocks SIL analysis to recognize the branch hint semantic model.
We're temporarily using @semantics until we have mandatory inlining of branch hints.

We now have @noinline, which helps a lot, but:
- @noinline and "cold/slow" are not the same thing.

- Some functions may need to be inlined into hot paths, but that
  doesn't mean we should also inline them into cold paths.

- It is easier to find cold blocks than to look for blocks that
  contain calls to @noinline functions. And that doesn't necessarilly
  mean the blocks are cold anyway.

Swift SVN r19455
2014-07-02 06:35:09 +00:00
Manman Ren
2b2330bf5b [attribute] rename @noinline to @inline(never).
Add support for parsing inline(never), it can be easily expanded to
handle inline(always).

rdar://17527111


Swift SVN r19447
2014-07-02 01:27:05 +00:00
Doug Gregor
a5bde4e3a4 CMake: Add COMPILE_FLAGS support for add_swift_library.
COMPILE_FLAGS is currently used for two purposes:
  - For any target library, add the appropriate Swift optimization flags. This eliminates the add_swift_optimization_flags boilerplate and makes these flags work for all library variants
  - For the runtime, pass the appropriate define down when SWIFT_RUNTIME_CLOBBER_FREED_OBJECTS is set, so that all library variants get this setting.

Swift SVN r19444
2014-07-02 00:37:48 +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
Chris Lattner
7dae30f755 rename the integer 'modulus' methods to 'remainder' methods.
Swift SVN r19433
2014-07-01 22:36:54 +00:00
Jordan Rose
f746b8c6dd [Accessibility] Public variables cannot have private types.
This does not yet handle variables with inferred types, since those don't
have TypePatterns.

There is some nasty propagation of @public into the stdlib because of this
one, mainly because Foundation needs access to some of the implementation
details of Array and Dictionary. We may want to try to improve this later
(or just build Foundation with -disable-access-control if it comes to that).

Swift SVN r19432
2014-07-01 22:30:53 +00:00
Jordan Rose
f13a5af044 [Accessibility] A typealias cannot be more accessible than its underlying type.
This actually lays the groundwork for checking the TypeLocs for all sorts
of decls, but let's start with typealiases.

Swift SVN r19428
2014-07-01 20:46:30 +00:00
Doug Gregor
315575e14f CMake: Add LINK_FLAGS option for add_swift_library
Swift SVN r19417
2014-07-01 17:11:38 +00:00
Doug Gregor
1f7817360a Use build configurations to enable/disable Float80
Swift SVN r19405
2014-07-01 17:11:32 +00:00
Doug Gregor
d95b9fad69 CMake: Skeletal infrastructure for building multiple variants of Swift libraries (for iOS, iOS simulator, etc.).
This is behind a flag because it doesn’t work yet. However, we’re starting to see semi-sensible command lines coming out of it.

Swift SVN r19404
2014-07-01 17:11:32 +00:00
Dmitri Hrybenko
3f2006a00b stdlib/UnicodeTrie: add more comments, replace a _precondition()/#if
pair with _sanityCheck

Swift SVN r19395
2014-07-01 13:18:20 +00:00
Dmitri Hrybenko
27abfcb271 stdlib/String: add a performance FIXME
Swift SVN r19394
2014-07-01 13:18:18 +00:00
Dmitri Hrybenko
124eb2ae83 stdlib: reword trap messages in response to review from Dave
Swift SVN r19393
2014-07-01 13:18:16 +00:00
Enrico Granata
f59f6abc4e The bot is unhappy that these are not marked @public, so mark them @public
Swift SVN r19388
2014-07-01 01:47:13 +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
Jordan Rose
748efed913 [Accessibility] Protocol witnesses must be as accessible as the protocol.
...unless the type has less accessibility than the protocol, in which case
they must be as accessible as the type.

This restriction applies even with access control checking disabled, but
shouldn't affect any decls not already marked with access control modifiers.

Swift SVN r19382
2014-06-30 23:38:35 +00:00
Dave Abrahams
8e7d45f2c0 [stdlib] Normalize .gyb files
- Follow LLVM conventions for emacs mode specification

- Use local variables suffix to make the output read-only (at least on
  Emacs)

- But drop the admonitions not to edit the generated files;
  line-directive mostly takes care of that problem now.

Swift SVN r19381
2014-06-30 23:24:17 +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
e38c32742b [stdlib] Dictionary: fix 80-column/endline violations
Swift SVN r19375
2014-06-30 22:12:16 +00:00
Dave Abrahams
c703a76cdc [stdlib] Add missing precondition check
Fixes <rdar://problem/17392712> UnsafeArray.init() should _precondition(length >= 0)

Swift SVN r19373
2014-06-30 21:59:42 +00:00
Dave Abrahams
c04aae5dce [stdlib] Add some missing mode lines for gyb files
Swift SVN r19372
2014-06-30 21:55:30 +00:00
Dave Abrahams
9825954746 [stdlib] That's not a doc comment!
Fixes <rdar://problem/17028678> comments for sort() don't make sense in
the synthesized header.  Putting the right comments in there is
<rdar://problem/17511801> Algorithm.swift needs doc comments

Swift SVN r19370
2014-06-30 21:46:19 +00:00
Enrico Granata
fcebadb355 Bit needs a Mirror too. It would be nice if we had automagical reflection for C-style enums, then this would just work OOTB
Swift SVN r19369
2014-06-30 21:16:50 +00:00
Dave Abrahams
127a3e59d2 [stdlib] give filter() the eager treatment, too
Swift SVN r19368
2014-06-30 20:56:11 +00:00
Nadav Rotem
715565e4ea Rename a member function
Swift SVN r19364
2014-06-30 20:16:26 +00:00
Enrico Granata
676547c5f7 Add Mirror support for CollectionOfOne
Swift SVN r19363
2014-06-30 20:14:31 +00:00
Dave Abrahams
52c01c9ee4 [stdlib] Give filter() the lazy() treatment
Swift SVN r19359
2014-06-30 19:32:34 +00:00
Joe Groff
e99fc08a36 stdlib: Add a _convertConstStringToUTF8PointerArgument entry point to assist string-to-pointer conversion.
Swift SVN r19358
2014-06-30 19:32:03 +00:00
Jordan Rose
5e59d30c6f Update stdlib for memberwise access control.
As before, there may be more things marked @public than we actually want
public. Judicious use of the frontend option -disable-access-control may
help reduce the public surface area of the stdlib.

Swift SVN r19353
2014-06-30 18:50:50 +00:00
Jordan Rose
8c1fcfa055 Make some more stdlib things public.
Swift SVN r19351
2014-06-30 18:50:46 +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
Chris Lattner
68be2902c2 remove some operator definitions that aren't implemented anywhere. We should add these
back when/if they are added to the stdlib.


Swift SVN r19326
2014-06-29 00:46:32 +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
Dave Abrahams
e18d8b02ba [stdlib] filter(x) never creates a Collection
It's both more rigorously correct and should prevent surprise when
constructing an Array from a filtered sequence.  See the comments
in-code for details.

Swift SVN r19304
2014-06-27 19:44:46 +00:00
Joe Groff
bf102f8ca4 IRGen: Fix extended method encoding for protocol members that take a single-parameter block parameter.
We were falling back to void(^)() encoding for block types whose input type was not a tuple.

Swift SVN r19299
2014-06-27 18:13:17 +00:00
Joe Groff
47fde864e9 Remove UnsafePointer.withUnsafePointer.
This is no longer necessary for API parity with CMutablePointer now that pointer conversions are in.

Swift SVN r19296
2014-06-27 16:54:51 +00:00
Joe Groff
39dbb30b57 Remove staging typealiases from the stdlib.
Swift SVN r19287
2014-06-27 02:48:38 +00:00
Doug Gregor
f0159f40a1 Ban the "new" syntax for creating an array <rdar://problem/16951969>.
We haven't been advertising this syntax much, and it's closure form
was completely broken anyway, so don't jump through hoops to provide
great Fix-Its here. 


Swift SVN r19277
2014-06-26 23:51:47 +00:00
Joe Groff
e47a4e2e5a Missed a #if. Unbreak the build for people who don't have -DENABLE_POINTER_CONVERSIONS set.
Swift SVN r19276
2014-06-26 23:49:03 +00:00