Commit Graph

52 Commits

Author SHA1 Message Date
Doug Gregor
22eecacc35 Adopt unsafe annotations throughout the standard library 2025-02-26 14:28:01 -08:00
David Smith
bca125c760 rdar://137709108 (Mitigate the code size increase from eager-lazy array bridging by marking some methods release none) (#76966) 2024-10-10 23:29:25 -07:00
Mishal Shah
48d5aca28d Revert "Use associated objects to attach contiguous array buffers to lazy one…"
This reverts commit 7c011813f2.
2024-07-21 23:34:57 -07:00
David Smith
7c011813f2 Use associated objects to attach contiguous array buffers to lazy ones (#75148)
rdar://132124808
2024-07-19 23:21:41 -07:00
Alejandro Alonso
f9f640b141 Sendablize the standard library
oops dont add this flag

no more nonisolated
2024-03-05 15:02:09 -08:00
Doug Gregor
ea89407304 Extend the lifetime of the buffer while copying from a _CocoaArrayWrapper
Fixes rdar://90108215.
2022-03-10 18:03:07 -08:00
LucianoAlmeida
09bf4cb6d1 [NFC] Fixing some stdlib unused warnings 2022-02-20 18:18:35 -03:00
Karoy Lorentey
466e26a872 [stdlib] Implement _copyContents on internal Array types
`_copyContents(initializing:)` is a core method of Sequence, and it is used surprisingly often to copy stuff out of sequences. Array’s internal types currently have explicit implementations of it that trap (to prevent a performance bug due to the default iterator-based implementation. This has proved a bad idea, as not all code paths that end up calling `_copyContents` have actually been expunged — so we replaced a performance bug with a catastrophic correctness bug. 😥

Rather than trying to play whack-a-mole with code paths that end up in `_copyContents`, replace the traps with (relatively) efficient implementations, based on the ancient `_copyContents(subRange:initializing)` methods that have already been there all this time.

This resolves https://bugs.swift.org/browse/SR-14663.

I expect specialization will make this fix deploy back to earlier OSes in most (but unfortunately not all) cases.
2021-06-16 13:47:00 -07:00
Erik Eckstein
375f289597 stdlib: fix ARC for getting an ArraySlice of an CocoaArray with non-contiguous storage.
For this special case we copied the objects out of the cocoa array without retaining them.
This lead to a double-free crash.

Unfortunately I could not come up with an isolated test case.

rdar://74624065
2021-03-08 20:34:19 +01:00
Paul Hudson
06f82a53b5 Replaced the majority of ' : ' with ': '. 2019-07-18 20:46:07 +01:00
Ben Cohen
e9d4687e31 De-underscore @frozen, apply it to structs (#24185)
* De-underscore @frozen for enums

* Add @frozen for structs, deprecate @_fixed_layout for them

* Switch usage from _fixed_layout to frozen
2019-05-30 17:55:37 -07:00
Ben Cohen
1673c12d78 [stdlib] Replace "sanityCheck" with "internalInvariant" (#20616)
* Replace "sanityCheck" with "internalInvariant"
2018-11-15 20:50:22 -08:00
Karoy Lorentey
ee17e975ca [stdlib] Make protocol _NSArrayCore internal
These shadow protocols don’t add any real type safety, and exposing them in the ABI seems unnecessary.
2018-11-15 09:54:25 +00:00
Jordan Rose
65fe556c1a [stdlib] Mark associated type witnesses as @usableFromInline
Inlinable code is permitted to rely on these associated types, so we
need to make sure their declarations are printed in the parseable
interface.

Part of rdar://problem/43824052
2018-11-06 17:00:46 -08:00
Ben Cohen
b77b544cdc Remove remaining @ininable from @_transparent (#17968) 2018-07-16 08:12:52 -07:00
Slava Pestov
2e5aef9c8d stdlib: Remove redundant @usableFromInline attributes 2018-04-06 00:02:30 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Max Moiseev
53b8419279 [stdlib] Make all the stdlib APIs @_inlineable
This change in theory should allow us to remove a special stdlib-only
sil-serialize-all compilation mode.

<rdar://problem/34138683>
2017-09-29 11:26:56 -07:00
Roman Levenstein
29ad714bb7 Annotate stdlib functions to get a good performance even in resilient mode, when -sil-serialize-all is disabled
This commit mostly improves the performance of arrays and ranges.
It does not cover Strings, Dictionaries and Sets yet.
2017-03-16 19:46:11 -07: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
Andrew Trick
0b75ee975e Remove "illegal" UnsafePointer casts from the stdlib.
Update for SE-0107: UnsafeRawPointer

This adds a "mutating" initialize to UnsafePointer to make
Immutable -> Mutable conversions explicit.

These are quick fixes to stdlib, overlays, and test cases that are necessary
in order to remove arbitrary UnsafePointer conversions.

Many cases can be expressed better up by reworking the surrounding
code, but we first need a working starting point.
2016-07-28 20:42:23 -07:00
Bob Wilson
58395b3b2f [SE-0127] Add "to:" argument label to withUnsafe[Mutable]Pointer.
rdar://problem/26529498
2016-07-26 17:44:33 -07:00
Dave Abrahams
0d68b3a4af [stdlib] Generate RandomAccessCollection defaults
The defaults we were generating for Collection and
BidirectionalCollection didn't make any sense, because if you could do
that strideable arithmetic then you essentially had random access.
Instead we constrain the defaults to apply to RandomAccessCollection
where the Indices are a CountableRange.
2016-05-02 11:35:32 -07:00
Dave Abrahams
c99f59e3e6 [stdlib] Suppress some warnings
internal structs shouldn't have public members: nag, nag.
2016-05-02 09:20:55 -07:00
Dave Abrahams
8d809993be [stdlib] Use CountableRange for Indices more
This will be much more efficient than the default, when it applies,
because it doesn't need to carry a reference to underlying collection
storage.
2016-05-01 19:42:40 -07:00
Dave Abrahams
444aaf2100 [stdlib] Declare conformance of Random-Access Collections
Some of these collections were still only declared to conform to
Collection.
2016-05-01 17:47:32 -07:00
Dmitri Gribenko
c52787e900 Merge commit '9cdbec13eee72feccfc5f8b987882a8c52e8107b' into swift-3-indexing-model 2016-04-14 16:23:53 -07:00
Dmitri Gribenko
10697f939f Merge commit '510f29abf77e202780c11d5f6c7449313c819030' into swift-3-indexing-model 2016-04-14 13:45:27 -07:00
Jordan Rose
bc83940301 Make pointer nullability explicit using Optional.
Implements SE-0055: https://github.com/apple/swift-evolution/blob/master/proposals/0055-optional-unsafe-pointers.md

- Add NULL as an extra inhabitant of Builtin.RawPointer (currently
  hardcoded to 0 rather than being target-dependent).
- Import non-object pointers as Optional/IUO when nullable/null_unspecified
  (like everything else).
- Change the type checker's *-to-pointer conversions to handle a layer of
  optional.
- Use 'AutoreleasingUnsafeMutablePointer<NSError?>?' as the type of error
  parameters exported to Objective-C.
- Drop NilLiteralConvertible conformance for all pointer types.
- Update the standard library and then all the tests.

I've decided to leave this commit only updating existing tests; any new
tests will come in the following commits. (That may mean some additional
implementation work to follow.)

The other major piece that's missing here is migration. I'm hoping we get
a lot of that with Swift 1.1's work for optional object references, but
I still need to investigate.
2016-04-11 20:06:38 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
Dave Abrahams
f493b54e44 [stdlib] indexing model: Interval/Range merge
This is step 1; we still need to introduce ClosedRange.
2016-03-16 15:59:10 -07:00
Dmitri Gribenko
efaa39ea79 stdlib: add first argument labels and some other changes to conform to API guidelines 2016-02-15 23:47:54 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Doug Gregor
f245f18a09 Merge remote-tracking branch 'origin/swift-3-api-guidelines' into swift-3-omit-needless-words 2015-12-17 11:35:58 -08:00
Maxim Moiseev
0e54467bfa Final bulk removal of Type suffix 2015-12-16 17:06:19 -08:00
Doug Gregor
2f5f94a12c Merge remote-tracking branch 'origin/swift-3-api-guidelines' into swift-3-omit-needless-words 2015-12-15 17:11:37 -08:00
Max Moiseev
806be29941 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-14 12:05:35 -08:00
Patrick Pijnappel
6838f300b1 [stdlib] Add missing backticks around nil in docs 2015-12-13 09:40:49 +11:00
Doug Gregor
06c5e9cd5b Enable "omit needless words" by default.
Most of this is in updating the standard library, SDK overlays, and
piles of test cases to use the new names. No surprises here, although
this shows us some potential heuristic tweaks.

There is one substantive compiler change that needs to be factored out
involving synthesizing calls to copyWithZone()/copy(zone:). Aside from
that, there are four failing tests:

    Swift :: ClangModules/objc_parse.swift
    Swift :: Interpreter/SDK/Foundation_test.swift
    Swift :: Interpreter/SDK/archiving_generic_swift_class.swift
    Swift :: Interpreter/SDK/objc_currying.swift

due to two independent remaining compiler bugs:
  * We're not getting partial ordering between NSCoder's
  encode(AnyObject, forKey: String) and NSKeyedArchiver's version of
  that method, and
  * Dynamic lookup (into AnyObject) doesn't know how to find the new
  names. We need the Swift name lookup tables enabled to address this.
2015-12-11 14:46:50 -08:00
Maxim Moiseev
7e2466c14e CollectionType => Collection 2015-12-09 17:12:48 -08:00
Jordan Rose
cf8baedee2 Re-apply "Rename @transparent to @_transparent for now."
This re-applies 90fcbfe9a6. I'll be committing
the corresponding change to Foundation momentarily.
2015-11-16 10:53:56 -08:00
Xin Tong
16843684b2 Revert "Rename @transparent to @_transparent for now."
This reverts commit 90fcbfe9a6.

Seems there are still some tests that are left not modified.
2015-11-14 07:04:31 -08:00
Jordan Rose
90fcbfe9a6 Rename @transparent to @_transparent for now.
This feature has not been fully designed, let alone properly implemented.
For more information, see docs/TransparentAttr.rst.
2015-11-13 16:25:34 -08:00
Dmitri Hrybenko
57d85f70d7 stdlib: eliminate redundant implementations of 'generate()'
Swift SVN r29617
2015-06-24 20:41:47 +00:00
Dave Abrahams
5c55682d8b [stdlib] Capitalize keywords in doc comments
Again, the text is a lot more readable that way.

Swift SVN r28472
2015-05-12 16:59:13 +00:00
Dave Abrahams
106b39a497 [stdlib] Indent bullet continuations in doc comments
The text is a lot more readable that way.

Swift SVN r28471
2015-05-12 16:59:08 +00:00
Dmitri Hrybenko
7776ba5a71 stdlib: clean up capitalization in doc comments
Patch by Brian Lanier and Alex Martini.

Swift SVN r28335
2015-05-08 23:44:05 +00:00