Commit Graph

12582 Commits

Author SHA1 Message Date
Dmitri Gribenko
09f7245dbf stdlib: add SWIFT_RUNTIME_STDLIB_INTERFACE attribute where necessary
... and remove some redundant ones.

This change fixes the RuntimeObjC.swift test.

rdar://problem/26239602
2016-05-12 15:48:25 -07:00
Roman Levenstein
1494d155c6 Don't sink open_existential instructions.
We don't sink open_existential_* instructions, because there may be some instructions depending on them, e.g. ametatype_inst, etc. But this kind of dependency cannot be expressed in SIL as a use yet. As a result, sinking open_existential may break the invariant that these instructions should dominate their uses.
2016-05-12 12:05:49 -07:00
Roman Levenstein
2eff3a1e9b Do not hoist metatype instructions with opened existentials.
Hoisting this instructions may break the invariant that each such instruction should be dominated by an open_existential instruction.
2016-05-12 12:05:20 -07:00
Michael Gottesman
bc90c3b5d4 Do not run the backtrace test when running tests with optimizations enabled.
We do not emit backtraces when optimization is enabled. We could do a negative
test here but I do not think it really adds much.
2016-05-12 10:42:57 -07:00
Andrew Trick
bc70c7e92c Merge pull request #2484 from atrick/specialize
Add unit tests for subscript specialization.
2016-05-12 08:28:45 -07:00
Slava Pestov
6196ad4e0b SIL: Teach SILVerifier::isLoweringOf() about DynamicSelfType
The concrete type of an existential might involve dynamic Self
in some cases.

Fixes <rdar://problem/22003864>.
2016-05-11 23:43:31 -07:00
Dmitri Gribenko
a2c50f55ee Revert "Revert "Temporarily comment out some runtime tests due to linker failure.""
This reverts commit 94f6bbb4b3.

It broke again:

https://ci.swift.org/job/oss-swift_tools-RA_stdlib-RDA_test-simulator/1271/
https://ci.swift.org/job/oss-swift_tools-RA_stdlib-RD_test-simulator/1349/
2016-05-11 23:33:14 -07:00
Doug Gregor
3650ce8ecd SE-0064 / SR-1239: Fix-Its for string-literal selectors naming property accessors.
When we see a string literal used to initializer a Selector, and that
string literal names the selector for the getter or setter of an
Objective-C property, suggest #selector(getter: ...) or

This completes SE-0064. Big thanks for Alex Hoppen (@ahoppen) for his
contributions here.
2016-05-11 23:03:37 -07:00
Alex Hoppen
a0a74aeb46 SE-0064 / SR-1239: Code completion for #selector of property getters/setters.
Implement basic code completion support for #selector with property
getters/setters. The vast majority of this implementation comes from
Alex Hoppen (@ahoppen), with only a handful of my own tweaks. Alex has
more interesting ideas on improving this that I wasn't quite ready to
commit to, so this is more basic than the overall goal.
2016-05-11 23:03:37 -07:00
Slava Pestov
cc0fcc56bf Add test case for rdar://21770225, which seems to have been fixed
I think John fixed this as part of the recent runtime and IRGen
work toward lazier metadata accesses.
2016-05-11 22:51:33 -07:00
Slava Pestov
c552b3c614 Sema: Remove unnecessary cast that leading to crash when subscript witness was mislabeled
Fixes <rdar://problem/22981205>.
2016-05-11 22:51:32 -07:00
Slava Pestov
3bc64f37b8 Sema: Re-purpose unavailable override checking code for protocol conformances
This was easy with a bit of refactoring, but eventually I'd love to
converge override checking and witness checking logic a bit more.

Fixes <rdar://26183366>.
2016-05-11 22:51:32 -07:00
swiftix
4eaed25a5e Merge pull request #2491 from swiftix/devirtualizer-fixes
Small fixes for the sil-devirtualizer
2016-05-11 21:35:46 -07:00
Joe Groff
04d5a6a19f Merge pull request #2487 from jckarter/r26210805
SILGen: Partial applications of methods don't lie about their nonnull-ness.
2016-05-11 21:04:14 -07:00
Stephen Canon
772d7ec3c5 Merge branch 'SE-0067' of https://github.com/stephentyrone/swift into stephentyrone-SE-0067
Implements almost all of SE-0067. There are a few outstanding features; this implementation does not have:

- formRemainder(dividingBy:)
- formSquareRoot()
- addProduct(_:,_:)

which require additions to the Builtin module. I can probably figure out how to do these, but I haven't had a chance to do so yet. Also missing are the generic initializers and comparisons whose implementation depends on having new Integer protocols.

The last remaining feature of SE-0067 is that while the basic operators +,-,*,/, etc are moved onto the FloatingPoint protocol, they are still required on the concrete types in order to disambiguate overloads. Fixing this seems to require either modifying the overload resolution rules or removing these operators from some other protocols. Or it might just require that someone smarter than me looks at the problem.

Passes the existing tests locally (with the included changes). I'm working on additional tests for the new features.
2016-05-11 22:11:21 -04:00
Jordan Rose
d72d0942fe Handle renaming for "unavailable in Swift" decls.
...like the "Ref" forms of imported CF types.

rdar://problem/25883961
2016-05-11 17:29:16 -07:00
Michael Gottesman
8308ad85e2 Merge pull request #2485 from gottesmm/change-backtrace-to-use-dladdr-directly-instead-of-backtrace_symbol
When producing backtraces, do not use backtrace_symbol, invoke dladdr…
2016-05-11 17:28:36 -07:00
Alex Hoppen
d2e045c8b5 Implement SE-0064 / SR-1239: #selector for property getters and setters
Implements the core functionality of SE-0064 / SR-1239, which
introduces support for accessing the Objective-C selectors of the
getter and setter of an @objc property via #selector(getter:
propertyName) and #selector(setter: propertyName).

Introduce a bunch of QoI around mistakes using #selector to refer to a
property without the "getter:" or "setter:", using Fix-Its to help the
user get it right. There is more to do in this area, still, but we
have an end-to-end feature working.

Much of the implementation and nearly all of the test cases are from
Alex Hoppen (@ahoppen). I've done a bit of refactoring, simplified the
AST representation, and replaced Alex's custom
expression-to-declaration logic with an extension to the constraint
solver. The last bit might be short-lived, based on swift-evolution
PR280, which narrows the syntax of #selector considerably.
2016-05-11 16:51:27 -07:00
Roman Levenstein
73b6a38edc [sil-devirtualizer] Do not perform a speculative devirtualization for no-opt callees. 2016-05-11 16:28:50 -07:00
swift-ci
b56c15a08e Merge pull request #2461 from russbishop/fork/master 2016-05-11 16:20:42 -07:00
Jordan Rose
670f7b5b6d Optionals of imported value types are not @objc.
While we could bridge 'NSRange' to 'NSRange' and 'NSRange?' to
'NSValue * _Nullable', that (a) would be confusing, and (b) isn't
actually implemented at the moment. Fix my mistake in 477933b to
start accepting these.
2016-05-11 16:18:24 -07:00
John McCall
e75dae491e Don't diagnose failures to call symmetrically-typed binary operators
as a failure to convert the individual operand, since the operator
is likely conceptually generic in some way and the choice of any
specific overload is probably arbitrary.

Since we now fall back to a better-informed diagnostics point, take
advantage of this to generate a specialized diagnostic when trying to
compare values of function type with ===.

Fixes rdar://25666129.

This reverts commit 073f427942,
i.e. it reapplies 35ba809fd0 with a
test fix to expect an extra note in one place.
2016-05-11 16:09:28 -07:00
Ted Kremenek
073f427942 Revert "Don't diagnose failures to call symmetrically-typed binary operators"
This reverts commit 35ba809fd0.
2016-05-11 15:53:24 -07:00
Michael Gottesman
7523d1a60b When producing backtraces, do not use backtrace_symbol, invoke dladdr directly.
Previously, we were using backtrace_symbol and then parsing/modifying its
output. By just using dladdr directly, we have a cleaner and more robust
solution.

rdar://25064742
2016-05-11 15:40:10 -07:00
John McCall
35ba809fd0 Don't diagnose failures to call symmetrically-typed binary operators
as a failure to convert the individual operand, since the operator
is likely conceptually generic in some way and the choice of any
specific overload is probably arbitrary.

Since we now fall back to a better-informed diagnostics point, take
advantage of this to generate a specialized diagnostic when trying to
compare values of function type with ===.

Fixes rdar://25666129.
2016-05-11 15:10:25 -07:00
swift-ci
ecd882168f Merge pull request #2482 from apple/reenable-runtime-objc-test 2016-05-11 14:40:52 -07:00
Joe Groff
3ce22b8955 SILGen: Partial applications of methods don't lie about their nonnull-ness.
Fixes rdar://problem/26210805.
2016-05-11 14:37:09 -07:00
swift-ci
274ff905c5 Merge pull request #2481 from apple/coregraphics-cgfloat-from-cgfloat 2016-05-11 14:16:19 -07:00
Argyrios Kyrtzidis
6b8ee42248 [fixcode] Accept the fixit for adding bang to unwrap optional.
This is useful for getting fixits for the IOU handling changes.
2016-05-11 13:58:24 -07:00
Argyrios Kyrtzidis
e5821519a4 [fixcode] Accept the warning fixit for single argument function types requiring parentheses. 2016-05-11 13:33:00 -07:00
Andrew Trick
d436c5b7c4 Add unit tests for subscript specialization. 2016-05-11 13:15:27 -07:00
eeckstein
f3b0010d41 Merge pull request #2462 from eeckstein/swift-merge-funcs
Add an LLVM pass to merge similar functions.
2016-05-11 12:19:12 -07:00
Dmitri Gribenko
94f6bbb4b3 Revert "Temporarily comment out some runtime tests due to linker failure."
This reverts commit ada23b18bd.

I can't reproduce the failure locally.
2016-05-11 11:55:27 -07:00
Dmitri Gribenko
94f49d443d CGFloat: add CGFloat.init(CGFloat), which makes CGFloat similar to Float and Double
This is an API bugfix, this API was accidentally omitted when we added
CGFloat to the overlay, so no evolution proposal is necessary.
2016-05-11 11:45:58 -07:00
Ted Kremenek
942e524285 Revert "SE-0036: Requiring Leading Dot Prefixes for Enum Instance Member Implementations" (#2477) 2016-05-11 11:02:37 -07:00
Dmitri Gribenko
310882d9a4 Merge pull request #2472 from ruscur/powerpc64-fixes
powerpc64{le} test fixes
2016-05-11 09:47:49 -07:00
Erik Eckstein
f0022a5aac Add an LLVM pass to merge similar functions.
It's like LLVM's MergeFunctions pass, except that it can also merge functions which differ by some constants.
The intention is to merge specialized functions which only differ by metadata lookups. But it can also merge other types of functions.
It gives ~7% code size reducation for the stdlib.

There are still some open TODOs, e.g. to share common code with LLVM's MergeFunctions pass (currently much code is just copied).
2016-05-11 09:46:46 -07:00
Russ Bishop
9af775bd57 Use existing flatMapToOptionalTests dataset 2016-05-11 01:15:12 -07:00
Jordan Rose
14a7334aef Merge pull request #2224: SE-0036: Requiring Leading Dot Prefixes for Enum Instance Member Implementations
from @ahoppen
2016-05-10 19:58:09 -07:00
Russell Currey
0605254dc6 test: Fix IRGen/condfail.sil to work on powerpc64{le} 2016-05-11 11:54:59 +10:00
Russell Currey
4fb2310de2 test: Fix IRGen/c_layout.sil to work on powerpc64{le} 2016-05-11 11:54:59 +10:00
Russell Currey
421d0997ec test: Fix 1_stdlib/tgmath.swift to work on powerpc64{le} 2016-05-11 11:54:59 +10:00
David Farler
414cfe7487 Minor changes to keyword-as-identifier diagnostics
- Remove stray newline
- Adjust wording when recommending backticks for a keyword identifier
- Provide fix-it when encountering a keyword as an identifier

rdar://problem/25761380
2016-05-10 14:49:21 -07:00
Jordan Rose
bd18590686 Override checking: believe full-name matches over types. (#2466)
This at least emits notes when someone overrides something but
gets the types a little wrong (more than just mismatched optionals,
as handled in d669d152).

Part of rdar://problem/26183575
2016-05-10 14:39:40 -07:00
John McCall
82d849edd7 Remove the portions of these tests that were relying on old stdlib APIs.
Judging from history, the original tests appear to just be attempts to
flesh out test coverage rather than specific regression tests, and the
features in question are well-covered by other tests.
2016-05-10 14:17:35 -07:00
Joe Groff
063e755e7e Merge pull request #2456 from jckarter/sr1323
AST: More robust rewrite of ProtocolConformance::getInheritedConformance.
2016-05-10 12:42:04 -07:00
Doug Gregor
aec6ea71a0 Merge pull request #2463 from milseman/newtype
[SILGen] Recognize swift_newtype-ed CF foreign class types
2016-05-10 12:00:08 -07:00
Jordan Rose
07b7e38429 Merge #2457 "Fix @objc checking for optional value types"
We previously treated 'NSFoo?' as ObjC-compatible simply because
'NSFoo' was an imported type or was marked '@objc'.
2016-05-10 11:39:27 -07:00
Ben Langmuir
c77af6907e [CodeCompletion] Switch filter-rules and popular api to follow SE-0021 naming
We want inputs for function names to follow SE-0021 with the exception
that a function with no arguments is spelled `foo()` instead of `foo`,
because we have no type to disambiguate with and it's not ambiguous with
a call in this context.

Internally, we use a filter name without underscores because we don't
want to introduce spurious matches to the `_` character which might be
part of identifiers.

For now, continue to accept the old names to ease the transition.

rdar://problem/24350800
2016-05-10 11:13:46 -07:00
Ben Langmuir
b4ce34aba9 [CodeCompletion] Remove ... and & from function filter names
The filter name of a function should match the spelling of the function
name according to the language except that we don't insert _ for unnamed
parameters because underscores are legal inside identifiers and we don't
want to introduce spurious matches (also, we keep the () on a
parameterless function for disambiguation).

rdar://problem/26118915
2016-05-10 11:13:45 -07:00