Commit Graph

7762 Commits

Author SHA1 Message Date
Guillaume Lessard
4aed3d1aac [gardening] add spaces after commas, for readability 2021-10-16 12:46:42 -06:00
Guillaume Lessard
4d05b759b2 [stdlib] a minor optimization
We have already done the hard work of unwrapping the optionals
that represent the first and last pointer, and calling `self.count` does it all over again. Use the distance between the unwrapped pointers instead.
2021-10-15 11:46:58 -06:00
Kuba (Brecka) Mracek
7538949859 Split out CommandLine enum into a separate static library, allow removing it from stdlib (#39591)
This is for the 'freestanding' build to stop assuming the platform has argc/argv.

- Introduce a new sub-library, libswiftCommandLineSupport.a
- Move stubs/CommandLine.cpp into this library
- Conditionally embed it into libswiftCore
- Conditionally embed it into libswiftPrivateLibcExtras if not in libswiftCore to support testing
- Add SWIFT_STDLIB_HAS_COMMANDLINE CMake (and build-script) flag
2021-10-13 07:02:43 -07:00
Kuba (Brecka) Mracek
1147d08ae3 Disable stable ABI on freestanding stdlib (#39674) 2021-10-12 15:25:57 -07:00
Karoy Lorentey
dd40ff2929 [stdlib][NFC] Put stored properties & primary initializers before other members in struct declarations 2021-10-05 22:01:35 -07:00
Max Desiatov
e4f71c8e11 stdlib: add support for WebAssembly in VarArgs (#39361)
When targeting `wasm32` we're relying on the alignment padding branch that's used for 32-bit ARM.
2021-10-05 10:21:31 +01:00
Alex Martini
2ccf3a29a3 Merge pull request #39403 from amartini51/identifiable_83422517
Avoid 'e.g.' per Apple Style.
2021-10-04 10:58:40 -07:00
Michael Ilseman
f8e5f28b86 Merge pull request #38922 from Azoy/native-normalization
[stdlib] Implement native normalization for String
2021-10-01 13:58:48 -06:00
eeckstein
2135f247d4 Merge pull request #39520 from eeckstein/fix-cow-checks
stdlib: add a build-script option --enable-array-cow-checks to enable compilation of COW checks.
2021-10-01 07:08:51 +02:00
Meghana Gupta
83c023446a Use -enable-ossa-modules for all of stdlib/public (#39478)
With this, even non-transparent functions will have their ownership eliminated later in the pipeline
2021-09-30 10:20:08 -07:00
Erik Eckstein
eb9621fe86 stdlib: add a build-script option --enable-array-cow-checks to enable compilation of COW checks.
And set this option in various presets for buildbots.

Don't enable the checks by default because when linking against the OS library (which does not support COW checking) it will result in unresolved symbol errors.
So far it was handled by an availability checks against 9999 (which was a hack), but this does not work anymore.

Note, all this is only relevant for assert builds of the stdlib.

rdar://83673798
2021-09-30 18:06:52 +02:00
Alejandro Alonso
014e822cb2 Address Michael's comments
fix infinite recursion bug

NFC: Remove early ccc check

remember that false is turned on
2021-09-29 14:20:22 -07:00
Alejandro Alonso
98aaa157ec Implement native normalization for String
use >/< instead of !=

fix some bugs

fix
2021-09-29 14:20:21 -07:00
Nate Cook
2daa005c5c [Docs] Note that partition(by:) is unstable (#39384) 2021-09-29 13:54:31 -05:00
Erik Eckstein
af71088d29 libswift: bootstrapping build
Adding build modes for libswift: off, hosttools, bootstrapping, bootstrapping-with-hostlibs
The two bootstrapping modes are new. For details see libswift/README.md
2021-09-28 18:51:42 +02:00
Alex Martini
9fa3121181 Avoid 'e.g.' per Apple Style. 2021-09-22 16:51:45 -07:00
Kuba (Brecka) Mracek
6766824d51 Add a SWIFT_STDLIB_HAS_STDIN flag to compile out the Swift.readLine() API from the stdlib (for the 'freestanding' preset) (#39332) 2021-09-17 10:42:14 -07:00
Karoy Lorentey
8e5ccec2c7 Merge pull request #39155 from lorentey/RawRepresentable-hashing-fix
[stdlib] Allow RawRepresentable types to customize their hashing without implementing hashValue
2021-09-17 00:50:10 -07:00
LucianoAlmeida
00cb1c5330 [stdlib] Improve set isDisjoint by iterating on smaller set 2021-09-14 17:28:45 -03:00
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