Commit Graph

908 Commits

Author SHA1 Message Date
Nate Cook
58933d88c5 [stdlib] Rename index(...) methods to firstIndex(...)
A la SE-204.
2018-04-21 18:07:25 -05:00
Karoy Lorentey
5ab67115dc [test] MinimalHashable types: Replace hashValue hook with hash(into:) 2018-04-20 19:22:19 +01:00
Karoy Lorentey
8d18d1a55d [test] checkHashable: Check that unequal values produce different hashes
This is safe to do with hash(into:), because random hash collisions can be eliminated with awesome certainty by trying a number of different hash seeds. (Unless there is a weakness in SipHash.)

In some cases, we intentionally want hashing to produce looser equivalency classes than equality — to let those cases keep working, add an optional hashEqualityOracle parameter.

Review usages of checkHashable and add hash oracles as needed.
2018-04-20 19:22:19 +01:00
Karoy Lorentey
d55b14b193 [test] MinimalHashable{Value,Class}: Implement CustomStringConvertible
This makes it easier to understand failure traces in test logs.
2018-04-20 17:42:02 +01:00
Karoy Lorentey
f873a5193e [test] MinimalTypes: Move ==, < definitions into the corresponding type (NFC) 2018-04-20 17:40:42 +01:00
Michael Ilseman
c4614a9208 [test] De-gyb stdlib unittest.
StdlibUnittest uses gyb to avoid duplicating many source-context
arguments. However, this means that any test that wishes to add new
expect helpers has to also be gybbed. Given that this structure hasn't
changed in years, and we should have a real language support
eventually, de-gyb it.
2018-04-19 13:06:14 -07:00
Mark Lacey
32d006de4a stdlib: Collapse some multi-line closures to single-line closures.
The change in CheckMutableCollectionType.swift.gyb previously resulted
in a runtime failure, and before that a compiler crash.

It appears that whatever type checker bug(s) were causing the issue
have been resolved in the last few months, so I'm returning this
closure to a single-expression form and cleaning up a couple other
places where we had an unneeded temporary as well.

Resolves rdar://problem/33781464.
2018-04-03 22:26:33 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Michael Ilseman
683fb47c01 Merge pull request #14755 from milseman/so_smol
Smol String
2018-03-28 18:29:50 -07:00
Michael Ilseman
cdfeb88cfe [string] Simplify creation logic, especially for C strings.
Streamline internal String creation. Previously, everything funneled
into a single generic function, however, every single call of the
generic funnel had relevant specific information that could be used
for a more efficient algorithm.

In preparation for efficiently forming small strings, refactor this
logic into a handful of more specialized subroutines to preserve more
specific information from the callers.
2018-03-27 10:49:02 -07:00
Devin Coughlin
e9d0be2365 [stdlib] Fix exclusivity warning in SwiftPrivate/IO.swift. NFC. 2018-03-25 16:13:18 -07:00
Arnold Schwaighofer
0c11e1a0a3 Mark swift sections as swift4 for Swift 4.2
rdar://36363251
2018-03-14 10:27:28 -07:00
Karoy Lorentey
3e90284883 [test] Disable hash randomization using environment variables
The hash seed is not settable at runtime anymore; update lit config to set the SWIFT_DETERMINISTIC_HASHING environment variable instead.
2018-03-13 16:15:09 +00:00
Karoy Lorentey
ab0c74b85c Merge pull request #14913 from lorentey/resilient-hashing
Switch to a resilient hashing interface, currently implementing SipHash-1-3.
Compiler-synthesized Hashable conformances still use the old _combineHashValues interface for now.
2018-03-09 19:57:03 +00:00
Karoy Lorentey
8cf5bc8bdc [stdlib] Switch to using SipHash-1-3 as the standard hash function
Beyond switching hashing algorithms, this also enables per-execution hash seeds, fulfilling a long-standing prophecy in Hashable’s documentation.

To reduce the possibility of random test failures, StdlibUnittest’s TestSuite overrides the random hash seed on initialization.

rdar://problem/24109692
rdar://problem/35052153
2018-03-09 14:48:59 +00:00
Sho Ikeda
6263b582a0 [stdlib/private][gardening] Prefer os(macOS) over os(OSX) 2018-03-09 22:41:55 +09:00
Mike Ash
6c59410943 [ReflectionMirror] Change swift-reflection-test.c to use addReflectionInfo on non-Macho platforms. 2018-03-02 17:36:33 -05:00
Mike Ash
1dcdd939ca [Reflection] Implement swift_reflection_addImage which takes care of looking up reflection info on behalf of the client.
rdar://problem/37538580
2018-02-20 16:47:07 -05: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
Ben Cohen
ab8e3a7ebc Fix warnings in various benchmarks (#14333) 2018-02-01 19:48:35 -08:00
Michael Gottesman
ce0c40e40b [+0-all] Update more runtime files for +0 normal arguments.
This is NFC when --enable-guaranteed-normal-arguments isn't passed into
build-script.

rdar://34222540
2018-01-29 12:13:45 -08:00
swift-ci
5971c910f2 Merge pull request #14106 from gottesmm/pr-97f2cfb87f3ba9284b962c1f7c054e5550e4b335 2018-01-23 17:59:25 -08:00
Michael Gottesman
5f3dfcfa36 [stdlibunittest] Update getMetadataKindOf for +0 parameters.
rdar://34222540
2018-01-23 16:04:34 -08:00
Michael Gottesman
18bcc1e143 [+0-args] Change SWIFT_CC(Swift) functions to use SWIFT_NS_RELEASES_ARGUMENT instead of NS_RELEASES_ARGUMENT.
rdar://34222540
2018-01-23 16:01:27 -08:00
Arnold Schwaighofer
17cd95efa4 Rename swift3 section and global names to swift5
Such that old and new runtimes can co-exists
rdar://36363251
2018-01-22 10:04:46 -08:00
Ben Cohen
7b7ef56097 Fix some warnings about use of DefaultRandomAccessIndices 2018-01-13 19:49:39 -08:00
Max Moiseev
2aa3583e1f [tests] Remove unnecessary test output 2017-12-20 11:22:54 -08:00
Maxim Moiseev
128092a7d6 Rename filterMap to compactMap 2017-12-18 09:22:41 -08:00
Max Moiseev
8ec6c45d2d Use filterMap to avoid deprecation warnings 2017-12-18 09:16:37 -08:00
Arsen Gasparyan
c4c1589b84 Make expectCrash(executing:_) safer 2017-12-14 15:31:30 +03:00
Arsen Gasparyan
5d6935af04 Rename param name in expectCrash function 2017-12-13 21:23:33 +03:00
Arsen Gasparyan
a6d2c2f05d Add expectCrash function to StdlibUnittest 2017-12-13 12:16:25 +03:00
Graydon Hoare
62a6b74ad1 Revert "[stdlib] Conditional conformances for Lazy[Filter|Map]Collection" 2017-12-10 12:48:36 -08:00
Max Moiseev
e4f94a318f [stdlib] Improve default implementation of Collection.distance(from:to:)
(cherry picked from commit 72948cae9a)
2017-12-08 13:07:07 -08:00
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Max Moiseev
3bace08f9a Revert "[stdlib] Improve default implementation of Collection.distance(from:to:)"
This reverts commit 72948cae9a.
2017-12-07 14:28:19 -08:00
Max Moiseev
72948cae9a [stdlib] Improve default implementation of Collection.distance(from:to:) 2017-12-06 18:19:34 -08:00
Ben Cohen
85d190cd7d [stdlib] Replace various uses of BlahSlice with Slice to reduce warnings (#13263)
* Kill the slice variants from the gybbed collection test types

* Handful more SDK instances

* Fix SequencesCollections.swift.gyb
2017-12-05 19:09:56 -08:00
Greg Parker
da14cd79a6 [runtime] Clean up symbol exports in libc functions. (#13202) 2017-12-01 17:49:11 -08:00
Ben Cohen
c4f0b5fe94 [stdlib] Adopt conditional conformance for Indices, Slice, ReversedCollection (#12913)
* Refactor Indices and Slice to use conditional conformance

* Replace ReversedRandomAccessCollection with a conditional extension

* Refactor some types into struct+extensions

* Revise Slice documentation

* Fix test cases for adoption of conditional conformances.

* [RangeReplaceableCollection] Eliminate unnecessary slicing subscript operator.

* Add -enable-experimental-conditional-conformances to test.

* Gruesome workaround for crasher in MutableSlice tests
2017-11-30 09:10:22 -08:00
Christian Bieniak
ec0d53f96f [stdlib] [SR-4005] Allow heterogenous comparisons in elementsEqual (#8045)
* [SR-4005] Allow heterogenous comparisons in elementsEqual

When a user is supplying a predicate to compare the type equivalence
isn’t required

* elementsEqualWithPredicate tests

Compares a string of a number with an integer value by using the
elementsEqualPredicate closure

* Update test expectations to use new sequence element types

* Update hardcoded test to reference sequence
2017-11-29 17:06:38 -08:00
taylor swift
c85880899d implement SE 184: add allocation methods to Unsafe buffer pointers, drop all parameters from deallocation, adjust namings, and add repeated-value assignment methods 2017-11-17 21:28:03 -08:00
Ben Cohen
35452c2e62 [stdlib] Remove _Strideable protocol 2017-11-16 13:38:24 -08:00
Greg Parker
58c9b45c78 [runtime] Clean up symbols in StdlibUnittest and the internal leak checker.
* Export fewer symbols.
* Prefix exported but not-public symbols with `_swift_`.
2017-10-24 13:13:43 -07:00
Roman Levenstein
c3bc08ec06 Remove any mention of sil-serialize-all related flags from CMake files and build-script-impl
These flags are not needed anymore.
2017-10-21 19:18:15 -07:00
Roman Levenstein
5047e1b475 Enable the serialization of sil_vtables by default and completely remove the -sil-serialize-vtables option
Only sil_vtables of public classes with fixed layout are serialized.
2017-10-21 11:36:12 -07:00
Roman Levenstein
48d9b99675 Remove -sil-serialize-witness-tables flag completely
The functionality is always enabled now and there is no need to have a dedicated flag for it.
2017-10-20 19:45:29 -07:00
Roman Levenstein
5e67f755e0 Remove the -sil-serialize-all option 2017-10-04 14:20:53 -07:00
Slava Pestov
c272d41e2f Re-apply "SIL: Remove special meaning for @_semantics("stdlib_binary_only")"
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-04 14:07:52 -07:00
Jordan Rose
aab5f7aa4f Revert "SIL: Remove special meaning for @_semantics("stdlib_binary_only")" (#12270)
It still affects StdlibUnittest, which is still using -sil-serialize-all.
2017-10-04 12:49:21 -07:00