Commit Graph

7767 Commits

Author SHA1 Message Date
Max Moiseev
99689955c5 Adding init(bitPattern: FLOATING_POINT) to Int32 and Int64 2017-01-06 11:59:59 -08:00
Joe Groff
720f496b2e Merge pull request #6605 from jckarter/unsafe-bitcast-warnings
Sema: Warn about some common classes of `unsafeBitCast` misuse.
2017-01-06 09:13:56 -08:00
Roman Levenstein
506b2b1591 Merge pull request #6582 from djwbrown/djwbrown-OnoneSupport-reversed
[Onone][prespecialize] Added iteration through reversed() arrays.
2017-01-06 08:37:43 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Joe Groff
d0787fb6b5 Sema: Warn about some common classes of unsafeBitCast misuse.
- Most immediately, we now have `withoutActuallyEscaping` as a supported way to temporarily reference a nonescaping closure as if it were escapable, and we plan to break the ABI for escaping and nonescaping closures so that the old `unsafeBitCast` workaround no longer works.
- `unsafeBitCast` is also commonly used to kludge pointers into different types, but we have more semantically meaningful APIs for type punning now. Guide users towards those APIs.
- Suggest more specific and type-safe operations, like `bitPattern:` initializers or `unsafeDowncast`, for the situations where `unsafeBitCast` is being used to avoid dynamic type checks or reinterpret numerical bits.
2017-01-05 21:19:02 -08:00
Nate Cook
b582683ecb [stdlib] Use unsigned arithmetic in partition 2017-01-05 21:32:32 -06:00
Nate Cook
5d42113375 [stdlib] Expand comments for _sort3 2017-01-05 21:32:28 -06:00
Max Moiseev
e91536b05d Correcting doubleWidthDivide precondition 2017-01-05 16:23:49 -08:00
Max Moiseev
156b171722 Adding DoubleWidth<> 2017-01-05 14:21:05 -08:00
Florent Bruneau
68bc423be3 Clang Importer: import all indirect fields.
Until now, only indirect fields that didn't belong to a C union (somewhere
between the field declaration and the type in which it is indirectly
exposed) were imported in swift. This patch tries to provide an approach
that allows all those fields to be exposed in swift. However, the downside
is that we introduce new intermediate fields and types, some of the fields
may already have been manually defined in type extension (as seen with the
GLKit overlay).

The main idea here is that we can simply expose the anonymous
struct/unions from which the indirect types are taken and then use swift
computed properties to access the content of those anonymous
struct/unions. As a consequence, each time we encounter an anonymous
struct or union, we actually expose it at __Anonymous_field<id> (where id
is the index of the field in the structure). At this point, we use the
existing mechanism to expose the type as
__Unnamed_<struct|union>_<fieldname>. Then, each indirect field is exposed
as a computed property.

The C object:

 typedef union foo_t {
     struct {
         int a;
         int b;
     };
     int c;
 } foo_t;

Is imported as

 struct foo_t {
   struct __Unnamed_struct___Anonymous_field1 {
     var a : Int32
     var b : Int32
   }
   var __Anonymous_field1 : foo_t.__Unnamed_struct___Anonymous_field1
   var a : Int32 {
     get {
       return __Anonymous_field1.a
     }
     set(newValue) {
       __Anonymous_field1.a = newValue
     }
   }
   var b : Int32 {
     get {
       return __Anonymous_field1.b
     }
     set(newValue) {
       __Anonymous_field1.b = newValue
     }
   }
   var c : Int32
 }

This has the advantage to work for both struct and union, even in case we
have several nested anonymous struct/unions. This does not require to know
the size and/or the offset of the fields in the structures and thus can be
properly implemented using front-end data.

Signed-off-by: Florent Bruneau <florent.bruneau@intersec.com>
2017-01-05 22:52:25 +01:00
Ben Cohen
ca6353d60e Update raw version to return a typed buffer 2017-01-05 11:59:50 -08:00
Ben Cohen
d12beac355 Add UnsafeRawBufferPointer.initialize(as:from:) 2017-01-05 11:59:49 -08:00
Ben Cohen
465f243943 Move += operator for append(contentsOf:) up to RangeReplaceableCollection 2017-01-05 11:59:49 -08:00
Ben Cohen
fefc2e40df Migrate _copyContents to be called from UnsafeMutableBufferPointer with checks for overrun. 2017-01-05 11:59:49 -08:00
Max Moiseev
36ad3b4300 Introducing abs<T : SignedArithmetic & Comparable> 2017-01-05 11:33:46 -08:00
Ben Cohen
4dc5eacef5 Merge branch 'master' into im-not-warning-you-again 2017-01-05 10:11:48 -08:00
Nate Cook
c67ebf836a Merge pull request #6502 from xwu/init-with-literals
Add doc comments for initializers for literals [NFC]
2017-01-04 23:56:26 -06:00
Ben Cohen
8ca0df6074 Merge pull request #6542 from airspeedswift/who-fixes-the-fixmes
[stdlib] Tag a handful of additional issues with FIXME(ABI)
2017-01-04 18:43:04 -08:00
Ben Cohen
6bb212cb26 Merge pull request #6538 from airspeedswift/int-string-radix-default
[stdlib] Combine String.init(Integer) with and without radix
2017-01-04 18:42:17 -08:00
mekjaer
272dfb26df Gardening spacing on properties and arguments in IndexSet (stdlib) 2017-01-04 23:09:17 +01:00
Xiaodi Wu
a698ca906b Address reviewer comments 2017-01-04 15:16:50 -06:00
Slava Pestov
6bea9534fe Merge pull request #6523 from jpsim/jp-inconsistent-closure-spacing
[gardening] fix mismatched closure open/close spacing in stdlib source
2017-01-03 20:59:38 -08:00
swift-ci
f801430025 Merge pull request #6517 from sigito/patch-2 2017-01-03 19:51:16 -08:00
JP Simard
65688bdc39 [gardening] replace unused closure parameters with '_' in stdlib source (#6522)
* replace unused closure parameters with '_' in stdlib source

* fold some _ closure arguments into line above

* fold more _ closure arguments into line above
2017-01-03 20:10:41 -07:00
Robert Widmann
fca7b66b7c Merge pull request #6521 from jpsim/jp-void-return
[gardening] prefer '-> Void' over '-> ()' in stdlib source
2017-01-03 20:10:13 -07:00
Joe Groff
796df2dc44 Merge pull request #6429 from jckarter/type-of-by-overload-resolution
`withoutActuallyEscaping`
2017-01-03 18:47:29 -08:00
Ben Cohen
9a4349ce89 Combine String.init with and without radix 2017-01-03 18:39:59 -08:00
Ben Cohen
28114baeb9 Flag various FIXMEs as ABI-impacting 2017-01-03 18:36:20 -08:00
JP Simard
891729f6c2 remove redundant '-> Void' return types from functions in stdlib source
since omitting it appears to be the convention followed elsewhere in
the code base.
2017-01-03 16:38:57 -08:00
Robert Widmann
e1822bccfa Merge pull request #6516 from sigito/patch-1
Removed repetitive docstring
2017-01-03 17:35:37 -07:00
Robert Widmann
359a66488f Merge pull request #6520 from jpsim/jp-trailing-semicolon
[gardening] remove trailing semicolons in stdlib source
2017-01-03 17:31:34 -07:00
Robert Widmann
6dd2dda53e Merge pull request #6525 from jpsim/jp-omit-control-statement-parens
[gardening] remove superfluous parentheses in control statements in stdlib source
2017-01-03 17:27:23 -07:00
Robert Widmann
3828784768 Merge pull request #6526 from jpsim/jp-return-arrow-whitespace
[gardening] fix overly-spaced return arrows in XCTest.swift
2017-01-03 17:26:35 -07:00
JP Simard
83b6d3c29c remove redundant optional nil assignment in stdlib source
since this appears to be the convention followed elsewhere in the code base.
2016-12-31 18:45:01 -08:00
JP Simard
2b246893c9 fix overly-spaced return arrows in XCTest.swift 2016-12-31 18:42:52 -08:00
JP Simard
7301b79342 remove superfluous parentheses in control statements in stdlib source
since this appears to be the convention followed elsewhere in the code base.
2016-12-31 18:40:15 -08:00
JP Simard
bb0af66904 fix mismatched closure open/close spacing in stdlib source 2016-12-31 18:21:05 -08:00
JP Simard
ea5b665afa prefer '-> Void' over '-> ()'
Apple and the Swift community has settled on this style:
https://devforums.apple.com/message/1133616#1133616

> FWIW, we've recently decided to standardize on () -> Void
> (generally, () for parameters and Void for return types) across all of our
> documentation.
2016-12-31 17:55:19 -08:00
JP Simard
bd34ea5e2d remove trailing semicolons in stdlib source 2016-12-31 17:51:18 -08:00
Yurii Samsoniuk
2b62ed250a Updated index(_:offsetBy:limitedBy:) code example 2016-12-31 15:48:52 +01:00
Yurii Samsoniuk
faa7c749df Removed repetitive docstring 2016-12-31 15:19:44 +01:00
ben-cohen
c00485a0f7 use nil coalescing on URL.quarantineProperties { set } 2016-12-29 14:37:08 -08:00
ben-cohen
c7785533a1 add FIXME for default: warning 2016-12-29 13:20:59 -08:00
ben-cohen
3f7adc9c22 supress warning on printing out optionals (temporarily, waiting on conditional conformance) 2016-12-29 12:57:32 -08:00
ben-cohen
1fb653cd51 Fix warning on UIImage?-as-Any 2016-12-29 12:20:52 -08:00
ben-cohen
adf56d1435 supress function-arg-before-defaulted-arg warning 2016-12-29 10:49:14 -08:00
ben-cohen
ce0d713cd6 fixed where clauses, Optional-as-Any and unused vars 2016-12-29 07:58:12 -08:00
Xiaodi Wu
539dc2a6d0 Add doc comments for initializers for literals 2016-12-28 15:13:28 -05:00
Hugh Bellamy
3f802bb2ab Fix documentation warnings building runtime with clang-cl 2016-12-27 14:55:35 +00:00
Hugh Bellamy
888afe139c Fix creating symlinks on Windows 2016-12-27 14:55:05 +00:00