Commit Graph

6693 Commits

Author SHA1 Message Date
Alejandro Alonso
7e0eaf7b99 Remove metadata section functions from the stdlib (#39236)
add aliases in test suite
2021-09-14 11:55:39 -07:00
David Smith
8557649c11 Merge pull request #39229 from Catfish-Man/bridge-collusion
Expose __SwiftNativeNSString for Foundation's use, as well as an initializer to create Strings from them
2021-09-10 11:57:42 -07:00
David Smith
30a3b6d3f5 Expose __SwiftNativeNSString for Foundation's use, as well as an initializer to create Strings from them 2021-09-10 01:26:11 -07:00
heo
76f639a21b Remove whitespace in markup 2021-09-09 10:32:56 +09:00
Kuba (Brecka) Mracek
404badb49a Introduce SWIFT_ENABLE_REFLECTION to turn on/off the support for Mirrors and reflection (#33617) 2021-09-08 13:08:13 -07:00
Yuta Saito
9b13d1f8bb [stdlib] Fix cc mismatch violation on swift_isClassType
_isClassType is mainly called by compiler-generated code, but it's also
called by stdlib. The call-site of stdlib used @_silgen_name to link the
function, so it's called through swiftcc. However its cc is defined as
C-cc, so caller and callee used different cc.
This patch adds C-compatible decl of swift_isClassType in shims so that
it can be called by stdlib with C-cc.
This change doesn't break ABI because `_isClassType` in stdlib was
defined as internal API.
2021-09-05 02:38:32 +00:00
Karoy Lorentey
f8d72f819a [stdlib] Allow RawRepresentable types to customize their hashing without implementing hashValue
Before this change, `RawRepresentable`'s custom `hashValue` implementation used to forward to `rawValue.hashValue`. (See https://github.com/apple/swift/pull/20705.) This sort of made sense at the time (`hash(into:)` was very new and `hashValue` was still in heavy use): it allowed raw representable values to return the exact same hash value as their `rawValue`, which some code used to (mistakenly) rely on. The big drawback of this is that to customize the Hashable implementation of a RawRepresentable type, people need to implement both `hashValue` and `hash(into:)` -- the former does not otherwise pick up customizations to the latter.

This change makes the default `RawRepresentable.hashValue` implementation call `self.hash(into:)`, just like it would on non-RawRepresentable types.

rdar://82651116
2021-09-02 20:16:01 -07:00
David Smith
89144300fb Keep the __StringStorage alive while we're using its buffer 2021-08-31 08:51:33 -07:00
David Smith
4209361695 Revert "Copy the code units into a temporary buffer in the invalid UTF8 handling path of String(unsafeUninitializedCapacity:initializingWith:) before calling a function which might invalidate the String's buffer. rdar://80379070"
This reverts commit 4bdc8e3c99.
2021-08-31 08:50:35 -07:00
David Smith
52f9c77560 Revert "Remove unnecessary _fixLifetime"
This reverts commit ce17877d50.
2021-08-31 08:50:16 -07:00
David Smith
ce17877d50 Remove unnecessary _fixLifetime 2021-08-31 08:36:27 -07:00
David Smith
4bdc8e3c99 Copy the code units into a temporary buffer in the invalid UTF8 handling path of String(unsafeUninitializedCapacity:initializingWith:) before calling a function which might invalidate the String's buffer. rdar://80379070 2021-08-30 21:27:50 -07:00
Alex Martini
b0f339799f Call out the behavior for empty sequences.
Fixes rdar://60543202

(cherry picked from commit d0d4a88823)
2021-08-26 17:03:47 -07:00
Alex Martini
1401743790 Hyphenate a two-word modifier.
Fixes rdar://68225196

(cherry picked from commit 00e18a2005)
2021-08-26 17:03:47 -07:00
Alex Martini
d8aa4deacb Also fix parameter name in parameter docs.
Follow-on to commit 36832a8d47.

(cherry picked from commit 4c82b7705c)
2021-08-26 17:03:47 -07:00
Alex Martini
16a7cc390a Correct parameter names in doc comments.
Fixes rdar://76254761.

(cherry picked from commit 36832a8d47)
2021-08-26 17:03:47 -07:00
Kuba (Brecka) Mracek
c079c0897b Split SWIFT_DARWIN_PLATFORMS and SWIFT_APPLE_PLATFORMS in CMake. SWIFT_APPLE_PLATFORMS may contain 'FREESTANDING' when building the freestanding SDK and SWIFT_FREESTANDING_FLAVOR is set to 'apple'. (#38997) 2021-08-23 19:16:28 -07:00
Guillaume Lessard
6b219a9c56 [stdlib] fix another accidental infinite-recursion bug (#38950)
fixes: SR-6501, SR-11516
2021-08-23 11:06:27 -04:00
Guillaume Lessard
9fbf3594da Merge pull request #38828 from glessard/sr9604
[stdlib] implement _copyContents for UnsafeRawBufferPointer
2021-08-21 16:47:04 -06:00
David Smith
834e82b7da Avoid an unnecessary call to CFStringGetCharactersPtr in bridging 2021-08-20 00:40:54 -07:00
Karoy Lorentey
48fa06b7f9 [stdlib] ContiguousArray & ArraySlice: Stop swapping self in wUMBP
Implements https://github.com/apple/swift/pull/38867 for ContiguousArray and ArraySlice -- these have the same unnecessary swapping logic.
2021-08-16 14:27:24 -07:00
Karoy Lorentey
ed287af766 [stdlib] Stop swapping self in Array.withUnsafeMutableBufferPointer
The law of exclusivity now allows us to remove the safety belt of swapping out self, getting rid of the need to create an empty array. (Which eliminates a swift_retain call.)
2021-08-12 19:30:37 -07:00
Alejandro Alonso
b651278616 Fix a crash on Scalar init with negative numbers (#38829) 2021-08-12 11:42:54 -07:00
Guillaume Lessard
af036db7bd [stdlib] implement _copyContents for UnsafeRawPointer 2021-08-10 15:35:07 -06:00
Xi Ge
ed13a2f0e4 ABI checker: require explicit @available attributes for new APIs
Before this change, the ABI checker didn't complain about missing @available
attributes on new APIs if the enclosing scopes of new APIs have
availability information. Instead, we should require explicit @available attributes
for new APIs to prevent them inheriting wrong availability information from a
preexisting scope.

rdar://81719628
2021-08-10 11:24:08 -07:00
Stephen Canon
a3ba517837 Mark legacy overloads of &+ and &- unavailable. (#38723)
These were defined for both FixedWidthInteger and FixedWidthInteger & SignedInteger for source compatibility with Swift 3; the latter set probably should have been removed when we stabilized the ABI, but were not. We can't easily remove them entirely (because we need them for ABI stability now), but we can mark them unavailable so that the typechecker doesn't have to consider them..
2021-08-05 21:18:48 -04:00
Stephen Canon
ce122dbb81 Clarify the documentation of SignedNumeric.
Previously we said that a type conforming to SignedNumeric allows positive and negative values, but that's nonsense. A type conforms to signed numeric if it has a negate() operation; it doesn't even have to have a notion of positive or negative values (for examples, see complex numbers, quaternions, integers mod n, etc).
2021-08-04 23:03:33 -04:00
Becca Royal-Gordon
627ecbdfff Rip designated types out of the AST
Designated types were removed from the constraint solver in #34315, but they are currently still represented in the AST and fully checked. This change removes them as completely as possible without breaking source compatibility (mainly with old swiftinterfaces) or changing the SwiftSyntax tree. Designated types are still parsed, but they are dropped immediately and a warning is diagnosed. During decl checking we also still check if the precedence group is really a designated type, but only so that we can diagnose a warning and fall back to DefaultPrecedence.

This change also fixes an apparent bug in the parser where we did not diagnose operator declarations that contained a `:` followed by a non-identifier token.
2021-08-03 16:13:59 -07:00
Guillaume Lessard
92335b115a Merge pull request #38677 from glessard/sr14491-v1
[stdlib] fast path for UMBP.initialize<C>(from: C) when C is a Slice
2021-08-03 11:28:32 -06:00
Guillaume Lessard
1e6b758330 Merge pull request #38509 from glessard/sr14850
[stdlib] prevent MutableCollections from inappropriately inheriting a Slice<Self> subscript
2021-08-02 14:12:29 -06:00
Guillaume Lessard
3302750fa2 [stdlib] avoid ABI impact 2021-08-02 12:20:24 -06:00
Guillaume Lessard
f6f36fa6d1 [stdlib] simplify indexing 2021-08-02 12:20:24 -06:00
Alastair Houghton
ad147308af Merge pull request #38309 from al45tair/problem/47902425
[Runtime] Add ObjC support to isKnownUniquelyReferenced.
2021-08-02 17:39:49 +01:00
Guillaume Lessard
9457406d0b Merge pull request #38463 from wongzigii/SR-14886
Check withContiguousStorageIfAvailable before copying byte by byte
2021-07-30 09:40:09 -06:00
ZigiiWong
26b3c55c23 [SR-14886] Check wCSIA before copying byte by byte. 2021-07-30 11:04:15 +08:00
Alastair Houghton
abec55f432 [Runtime] Add ObjC support to isKnownUniquelyReferenced.
Add code to support detecting uniquely referenced Objective-C and Core
Foundation objects.

rdar://47902425
rdar://66805490
2021-07-29 16:29:48 +01:00
Guillaume Lessard
2bc053f815 [stdlib] implement _copyContents for Slice
`Sequence._copyContents(initializing:)` is the function relied on by
`UnsafeMutableBufferPointer` for performant initialization from Collections.
Until now, `Slice<Base: Collection>` has not had its own implementation,
and therefore fell back to the default version implemented on `Sequence`.

This implementation adds an attempted fast path, using
`withContiguousStorageIfAvailable`. If that fails, the `Sequence`
algorithm is used, as before.

This resolves https://bugs.swift.org/browse/SR-14491
2021-07-28 15:23:03 -06:00
Guillaume Lessard
a9e0af40d3 [stdlib] make Sequence's _copyContents call into a non-protocol function 2021-07-28 15:23:03 -06:00
Guillaume Lessard
9ccf71e0b7 [stdlib] More MutableCollection fix to _SmallString 2021-07-28 02:13:45 -06:00
swift-ci
6d07945ff2 Merge pull request #38635 from lorentey/update-subsequence-docs 2021-07-27 21:17:50 -07:00
Karoy Lorentey
849f6b9818 [stdlib] Update SubSequence docs 2021-07-27 18:40:23 -07:00
David Smith
97073fb5a8 Fast-path contains() for empty Dictionaries 2021-07-26 17:12:00 -07:00
Guillaume Lessard
53db35c80f [stdlib] fix availability annotation 2021-07-23 13:40:19 -06:00
Guillaume Lessard
0ea4e3c4d9 [stdlib] add availability annotations and tests 2021-07-21 09:20:12 -06:00
Guillaume Lessard
3789ce292a [stdlib] fix an accidental recursion bug involving MutableCollection
- add a default implementation of MutableCollection’s
  subscript(bounds: Range<_>) with the most general signature possible
- it is marked unavailable in order to prevent the
  infinite recursion bug reported in SR-14848
- add a conditionally-available subscript(bounds: Range<_>) -> Slice<Self>
  only when Subsequence is Slice<Self>. This will supersede
  the unconditional extension that provides the same signature.
2021-07-20 16:11:23 -06:00
Guillaume Lessard
50e7c98583 [stdlib] MutableCollection fix to _SmallString 2021-07-20 13:25:55 -06:00
Guillaume Lessard
3b78f38438 Merge pull request #38438 from glessard/umbp-allocate-deduplication
[stdlib] remove duplicated code
2021-07-16 22:22:23 -06:00
Guillaume Lessard
ae10c297a9 make documentation of UMRBP.allocate() more complete. 2021-07-16 12:33:24 -06:00
Guillaume Lessard
e946cd02c0 remove duplicated code
- call `UnsafeMutablePointer.allocate(capacity:)` from
  `UnsafeMutableBufferPointer.allocate(capacity:)`.
- This was a straight code duplication.
2021-07-16 12:18:33 -06:00
Guillaume Lessard
7f68d6a4f5 document the requirement that allocation alignments must be powers of two. 2021-07-15 19:19:15 -06:00