Commit Graph

3744 Commits

Author SHA1 Message Date
Xiaodi Wu
26dac8f5e0 Address reviewer comments for consolidated integer-to-string conversion 2018-02-06 21:40:49 -06:00
Xiaodi Wu
22da6ddaf2 Merge pull request #14401 from xwu/itoa
[WIP] [stdlib] Consolidate integer-to-string implementations
2018-02-06 21:35:50 -06:00
Xiaodi Wu
09f77ff58d Merge pull request #14361 from xwu/less-miscellany
[stdlib] Remove outdated miscellaneous functions
2018-02-06 19:49:56 -06:00
Michael Ilseman
b1f1e98a63 [string] Clean up StringObject; Clarify its tagged BridgeObjects. (#14425)
[string] Clean up StringObject; Clarify its tagged BridgeObjects.

Bifurcate StringObjects raw bit-pattern initializers to expose whether
the caller is passing a value rather than a reference. This way,
StringObject can call the approprite BridgeObject helper and
participate in upcoming peephole optimizations like retains of
known-values. This is all meant to be a NOP.

Additionally, do some cleanup while we're at it.
2018-02-06 17:36:32 -08:00
Xiaodi Wu
5b4e3f2338 Merge pull request #14386 from xwu/no-mixing
[stdlib/Sema] Minor improvements to synthesized hashValue
2018-02-05 09:17:53 -06:00
Ben Cohen
77e417f1d0 [stdlib] Hoist Array.popLast to RangeReplaceableCollection (#14392)
* Move Array.popLast to RangeReplaceableCollection

* Remove popLast from Array completion tests
2018-02-04 20:11:51 -08:00
Xiaodi Wu
76e23368ad Consolidate integer-to-string implementations 2018-02-03 19:17:48 -06:00
Xiaodi Wu
8014793cf1 Remove final _mixInt in synthesized hashValue and improve the _combineHashValues magic number 2018-02-03 00:06:48 -06:00
Mark Lacey
393eae2fb4 Merge pull request #14364 from rudkx/typealias-for-iuo
Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
2018-02-02 17:46:49 -08:00
Ben Cohen
cfaff1dc7d [stdlib] Move _copyBuffer to be an init on _ArrayBufferProtocol (#14222)
* Move _copyBuffer to be an init on _ArrayBufferProtocol

* Make init(copying:) inlineable, even though its inline(never), to allow specialization.

* Delete old array swap test, as swap on arrays is no longer valid.

* Delete the old static method
2018-02-02 10:42:45 -08:00
Mark Lacey
2008674495 Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
Also remove the decl from the known decls and remove a
bunch of code referencing that decl as well as a bunch of other
random things including deserialization support.

This includes removing some specialized diagnostics code that
matched the identifier ImplicitlyUnwrappedOptional, and tweaking
diagnostics for various modes and various issues.

Fixes most of rdar://problem/37121121, among other things.
2018-02-02 08:35:53 -08:00
Xiaodi Wu
c1f3176fe7 Remove sole use of _floorLog2 2018-02-02 10:07:18 -06:00
Xiaodi Wu
f4a3947632 Remove _countLeadingZeros and _floorLog2 2018-02-02 09:58:00 -06:00
Michael Ilseman
2785bee6e0 Merge pull request #14356 from milseman/what_a_character
[string] Minor cleanup on Character
2018-02-02 07:54:34 -08:00
Mark Lacey
e43ff7164c Merge pull request #14299 from rudkx/iuo-remove-the-type
IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>
2018-02-01 21:58:37 -08: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
c1d4b60281 [stdlib] Collection compatibility shim fixes (#14342)
* Fix compatibility shims for IndexDistance

* Add a second test for implied IndexDistance, Bidirectional conformance
2018-02-01 19:47:11 -08:00
Michael Ilseman
49a2103a60 [string] Minor simplification to Character init 2018-02-01 19:25:23 -08:00
Xiaodi Wu
37beb71708 Merge pull request #14295 from xwu/integer-documentation
[docs] Update and fill in documentation for DoubleWidth and integer protocols
2018-02-01 16:07:05 -06:00
Michael Ilseman
d5d9e2bac8 [string] Minor expression simplification. NFC 2018-02-01 12:10:25 -08:00
Michael Ilseman
9948141a99 [gardening] Strip trailing whitespace; NFC 2018-02-01 12:10:25 -08:00
Lance Parker
bce84b8c49 fix mutations for substrings through views 2018-01-31 16:49:14 -08:00
Xiaodi Wu
21d59c415d Address reviewer feedback 2018-01-31 15:09:15 -06:00
Ben Cohen
dd5e6b64ea Add custom implementations of removeLast and remove(at:) to Array (#14273) 2018-01-31 22:05:19 +01:00
Mark Lacey
f08823757a IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>.
Stop creating ImplicitlyUnwrappedOptional<T> so that we can remove it
from the type system.

Enable the code that generates disjunctions for Optional<T> and
rewrites expressions based on the original declared type being 'T!'.

Most of the changes supporting this were previously merged to master,
but some things were difficult to merge to master without actually
removing IUOs from the type system:
- Dynamic member lookup and dynamic subscripting
- Changes to ensure the bridging peephole still works

Past commits have attempted to retain as much fidelity with how we
were printing things as possible. There are some cases where we still
are not printing things the same way:
- In diagnostics we will print '?' rather than '!'
- Some SourceKit and Code Completion output where we print a Type
  rather than Decl.

Things like module printing via swift-ide-test attempt to print '!'
any place that we now have Optional types that were declared as IUOs.

There are some diagnostics regressions related to the fact that we can
no longer "look through" IUOs. For the same reason some output and
functionality changes in Code Completion. I have an idea of how we can
restore these, and have opened a bug to investigate doing so.

There are some small source compatibility breaks that result from
this change:
- Results of dynamic lookup that are themselves declared IUO can in
  rare circumstances be inferred differently. This shows up in
  test/ClangImporter/objc_parse.swift, where we have
    var optStr = obj.nsstringProperty
  Rather than inferring optStr to be 'String!?', we now infer this to
  be 'String??', which is in line with the expectations of SE-0054.
  The fact that we were only inferring the outermost IUO to be an
  Optional in Swift 4 was a result of the incomplete implementation of
  SE-0054 as opposed to a particular design. This should rarely cause
  problems since in the common-case of actually using the property rather
  than just assigning it to a value with inferred type, we will behave
  the same way.
- Overloading functions with inout parameters strictly by a difference
  in optionality (i.e. Optional<T> vs. ImplicitlyUnwrappedOptional<T>)
  will result in an error rather than the diagnostic that was added
  in Swift 4.1.
- Any place where '!' was being used where it wasn't supposed to be
  allowed by SE-0054 will now treat the '!' as if it were '?'.
  Swift 4.1 generates warnings for these saying that putting '!'
  in that location is deprecated. These locations include for example
  typealiases or any place where '!' is nested in another type like
  `Int!?` or `[Int!]`.

This commit effectively means ImplicitlyUnwrappedOptional<T> is no
longer part of the type system, although I haven't actually removed
all of the code dealing with it yet.

ImplicitlyUnwrappedOptional<T> is is dead, long live implicitly
unwrapped Optional<T>!

Resolves rdar://problem/33272674.
2018-01-31 12:15:58 -08:00
Xiaodi Wu
78875d934c Update and fill in documentation for DoubleWidth and integer protocols 2018-01-30 20:52:24 -06:00
swift-ci
b28c282f09 Merge pull request #14219 from xwu/nunc-est-dividendum 2018-01-30 17:56:50 -08:00
Xiaodi Wu
4b9ff41303 Address reviewer comments 2018-01-30 18:55:19 -06:00
swift-ci
238b876602 Merge pull request #14251 from vedantk/pretty-print 2018-01-29 18:36:24 -08:00
Vedant Kumar
5049db0dd9 [DebuggerSupport] Attempt expanding objects with .class display style
When pretty-printing objects, attempt to expand & print objects which
have the `.class` display style even if they do not have any instance
variables. The pretty-printer will still bail out if the object does not
conform to CustomReflectable.

This is enough to teach the pretty-printer to format bridged NSStrings.

rdar://36843869
2018-01-29 15:31:53 -08:00
Mike Ash
5e2b11d42d Merge pull request #14157 from mikeash/conditionally-disable-runtimefunctioncounters
[Runtime] Remove RuntimeFunctionCounters in no-assert builds.
2018-01-29 15:48:32 -05:00
Jordan Rose
1a30ffdbd7 Revert "[stdlib] Add custom implementations of removeLast and remove(at:) to Array (#14212)"
This reverts commit 5ed4afe50b. It
doesn't appear to be correct when the client is compiled with
optimizations (as in, there's a failing bot).
2018-01-28 21:26:55 -08:00
Xiaodi Wu
cc0e64dec4 Implement efficient DoubleWidth division and fix division-related bugs 2018-01-28 14:01:06 -06:00
Ben Cohen
5ed4afe50b [stdlib] Add custom implementations of removeLast and remove(at:) to Array (#14212)
* Add custom implementations of removeLast and remove(at:) to Array
2018-01-28 04:55:33 -08:00
swift-ci
39e03788a3 Merge pull request #14209 from xwu/revised-combine-hash-values-link 2018-01-26 23:13:03 -08:00
Xiaodi Wu
bd6d94063d Update link citing Hoad and Zobel (2003) 2018-01-27 00:00:27 -06:00
Mike Ash
6f37cca3e0 [Runtime] Disable RuntimeFunctionCounters tests if the counters are disabled.
Also update how the variable is managed in the build system to allow the test to be conditional based on it, and make it more natural to set it on the command line.
2018-01-26 15:35:33 -05:00
Karoy Lorentey
7a6d14f968 Merge pull request #14126 from lorentey/warnings1
[stdlib] _SwiftNativeNS*.init(): Add @nonobjc attribute
2018-01-26 11:46:35 +00:00
Mike Ash
f48bd293cb [Runtime] Remove RuntimeFunctionCounters in no-assert builds.
A build option to include or exclude RuntimeFunctionCounters. By default, it's enabled when assertions are enabled.

rdar://problem/35864525
2018-01-25 12:18:25 -05:00
Karoy Lorentey
75a376d319 [stdlib] Use Int._binaryLogarithm() to round up to nearest power of 2 2018-01-25 15:48:34 +00:00
Karoy Lorentey
34184a0162 Don't expose empty initializers in _SwiftNativeNS* classes to Objective-C
These aren't supposed to be called from Objective-C, and having them @nonobjc does not preclude subclasses from re-exposing their own initializers.

This fixes a build-time warning for @objc inference on _SwiftNativeNSArray.init.
2018-01-25 14:39:04 +00:00
Karoy Lorentey
4b2ab698ea Merge pull request #14131 from lorentey/warnings3
[stdlib] Silence deprecation warnings about CharacterView in stdlib
2018-01-25 00:13:34 +00:00
Karoy Lorentey
1c88937cf4 Merge pull request #14127 from lorentey/warnings2
[stdlib] Add a return value to _UIntBuffer.removeFirst()
2018-01-24 21:47:38 +00:00
Karoy Lorentey
e6afe829a1 [stdlib] Silence deprecation warnings about CharacterView in stdlib
- Rename `Substring.CharacterView` to `Substring._CharacterView`, adding a deprecated typealias for the original name, like we do for `String.CharacterView`.
- Add a non-deprecated `Substring._characters` property, emulating `String.characters`.
- Explicitly deprecate the following members:
    * String.withMutableCharacters<R>(_: (inout CharacterView) -> R) -> R
    * String.subscript(Range<Index>) -> String.CharacterView
    * Substring._CharacterView.subscript(Range<Index>) -> Substring.CharacterView
    * Substring.init(_: CharacterView)
    * String.init(_: Substring.CharacterView)
2018-01-24 21:16:48 +00:00
Karoy Lorentey
39bf3a2e85 [stdlib] Fix _UIntBuffer.removeFirst() to match RangeReplaceableCollection requirement. 2018-01-24 16:44:18 +00:00
Michael Ilseman
b8a870300c Merge pull request #14118 from milseman/hash_hack_attack
[string] ARC hack around hashValue
2018-01-24 08:16:38 -08:00
Karoy Lorentey
92a2f9cb8f Merge pull request #14027 from lorentey/rdar/36619317
[stdlib] Set, Dictionary: Take the max load factor into account in `.init(minimumCapacity:)`
2018-01-24 11:31:17 +00:00
Michael Ilseman
ccdba811f1 Merge pull request #14117 from milseman/sanitime_runty
[string] sanity check for runtime size
2018-01-23 23:06:31 -08:00
Michael Ilseman
436475fb99 [string] ARC hack around hashValue
Avoid a source of ARC for hashValue, which is perf-sensitive
especially for hashed collection growth.

This improves the Dictionary benchmark by around 30%.
2018-01-23 21:43:17 -08:00
Michael Ilseman
5b716bd4bc [string] sanity check for runtime size 2018-01-23 20:24:42 -08:00