Commit Graph

1195 Commits

Author SHA1 Message Date
Arnold Schwaighofer
ff67cffe4f Merge remote-tracking branch 'upstream/master' into master-next 2019-10-02 10:12:33 -07:00
Arnold Schwaighofer
6a23ed5438 Revert "IRGen: Leave frame pointers off SIL functions marked [thunk]."
This reverts commit b3ac66aeeb.

This is problematic when [thunk] functions get inlined into and the
function from which we inline expects a framepointer.

Specifically, _swift_os_log_return_address() reads the framepointer.

rdar://55852225
2019-10-02 06:54:49 -07:00
swift-ci
448807f579 Merge remote-tracking branch 'origin/master' into master-next 2019-09-20 19:09:54 -07:00
Pavel Yaskevich
8eaeb51fe5 [ConstraintSystem] Introduce a fix for assignment type mismatch
Introduce a fix/diagnostic when there is a contextual mismatch
between source and destination types of the assignment e.g.:

```swift
var x: Int = 0
x = 4.0 // destination expects an `Int`, but source is a `Double`
```
2019-09-20 17:12:04 -07:00
swift-ci
bd0d9603b1 Merge remote-tracking branch 'origin/master' into master-next 2019-09-16 01:29:22 -07:00
Pavel Yaskevich
a1643d94f7 [Diagnostics] NFC: Update all of the improved test-cases 2019-09-13 22:35:52 -07:00
swift-ci
0c440ff5ef Merge remote-tracking branch 'origin/master' into master-next 2019-09-13 20:49:32 -07:00
Harlan Haskins
d3b8ce7ae2 [test] Update ParseableInterface to ModuleInterface
Also remove uses of -emit-parseable-module-interface from tests
2019-09-13 14:55:48 -07:00
Jordan Rose
73d5ebaad2 Rename "textual interface" to "parseable interface" (#19713)
We already have something called "module interfaces" -- it's the
generated interface view that you can see in Xcode, the interface
that's meant for developers using a library. Of course, that's also a
textual format. To reduce confusion, rename the new module stability
feature to "parseable [module] interfaces".
2018-10-04 17:49:55 -07:00
Jordan Rose
3ea754481e [Frontend] Allow -emit-interface with -typecheck (#19676)
Textual module interfaces don't actually depend on SILGen, so we
shouldn't need to run SILGen (or serialize an entire binary module) if
we're just trying to emit a textual interface. On the other hand, if
we /are/ going to run SILGen and then SIL diagnostics, we shouldn't
delay those diagnostics by spending time emitting a textual interface,
or for that matter a TBD file.

Using this, update all the ModuleInterface tests that use
`-emit-module -o /dev/null` to use `-typecheck` instead, except for
those using `-merge-modules`.
2018-10-03 15:07:31 -07:00
Harlan
8061358211 [InlinableText] Handle multiline #if conditions (#19675)
Previously, a #if of the form:

```swift
#if (
  false
)
print("x")
#endif
```

Would be emitted after #if-stripping as

```swift
  false
)
print("x")
```

Because the old logic assumed conditions will always appear on one line.
Instead, for active clauses that have conditions, skip to the next line
after the end of the condition instead.
2018-10-02 19:48:40 -07:00
Jordan Rose
c66fcf2e61 [SILGen] Don't SILGen an @objc entry point for a deinit with no body (#19472)
In general we'll want to investigate what we are and aren't SILGen-ing
for textual interfaces of resilient modules, but for fragile modules
we may as well generate everything we can for potential optimization
purposes.
2018-09-28 13:17:47 -07:00
Jordan Rose
61057b88db [ModuleInterface] Print names for @usableFromInline struct properties (#19465)
Because they weren't 'public' we were treating them as layout-only
properties and printing `var _`, but they get referenced in inlinable
functions. We need the actual name!
2018-09-26 14:57:44 -07:00
Jordan Rose
b29f010510 [ModuleInterface] Don't print extensions of internal types (#19440) 2018-09-26 14:57:23 -07:00
Harlan
2aac8863f6 [InterfaceGen] Only print 'mutating' and 'nonmutating' on accessors (#19459)
* [InterfaceGen] Only print 'mutating' and 'nonmutating' on accessors

* Add SILGen test for usage of dynamic accessors in and out of interfaces

* Add -enable-objc-interop to dynamic_accessors test
2018-09-25 23:10:52 -07:00
Harlan
8ba8222333 [InterfaceGen] Print abstract accessors in protocols (#19379)
* [InterfaceGen] Print abstract accessors in protocols

This patch slightly cleans up printing accessors and ensures we print
accessors abstractly in protocol context for textual interfaces.

It also removes some assuptions around the FunctionBody callback and
makes them more explicit.

* Print getter and setter for didSet decls

* Test _read and _modify

* Fix logic for skipping willSet/didSet

* Update 'final' test for new getter printing behavior
2018-09-20 15:43:01 -07:00
eeckstein
814e656cf9 Merge pull request #19388 from eeckstein/mangling-prefix
change mangling prefix from $S to $s
2018-09-20 09:16:30 -07:00
Harlan
bccca6ad1e [InterfaceGen] Don't print 'final' on accessors (#19399)
We've never allowed overriding specific accessors, and we don't
currently parse this syntax.
2018-09-19 18:53:30 -07:00
Erik Eckstein
39bb14b094 change mangling prefix from $S to $s
This is the final ABI mangling prefix

rdar://problem/38471478
2018-09-19 13:55:11 -07:00
Jordan Rose
8cf938261d [ModuleInterface] Don't include 'import Builtin' for the stdlib (#19319)
The special 'Builtin' module is implicitly imported via -parse-stdlib,
and can't be found via normal import resolution, so we shouldn't print
it in a textual interface.
2018-09-14 13:28:39 -07:00
Harlan
665db876ea [InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)
* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
2018-09-14 10:23:15 -07:00
Jordan Rose
5fda0f3690 [ModuleInterface] Don't print setter access twice (#19239)
And assert from now on that people don't exclude DAK_AccessControl
without also excluding DAK_SetterAccess.
2018-09-11 09:34:02 -07:00
Harlan
eb75ad80dc [AST] Remove stored TypeLoc from TypedPattern (#19175)
* [AST] Remove stored TypeLoc from TypedPattern

TypedPattern was only using this TypeLoc as a means to a TypeRepr, which
caused it to store the pattern type twice (through the superclass and through
the TypeLoc itself.)

This also fixes a bug where deserializing a TypedPattern doesn't store
the type correctly and generally cleans up TypedPattern initialization.

Resolves rdar://44144435

* Address review comments
2018-09-07 21:14:04 -07:00
Jordan Rose
3c5fba3797 When sorting imports for uniquing purposes, use full module names
Fixes a longstanding issue where submodules with the same name in
different top-level modules weren't being sorted deterministically.
This doesn't come up very much in practice, and it would have been
hard to notice anything wrong, but it's good to be right.
2018-09-06 19:53:59 -07:00
Jordan Rose
f6ee9f6dc9 [ModuleInterface] Print imports (including '@_exported')
Part of preserving enough information to reconstitute a textual
interface back to a binary module.
2018-09-06 16:05:16 -07:00
Harlan
ad7e1d0e67 [InterfaceGen] Print private/internal properties (#19127)
* [Interface] Print private/internal properties

All properties which contribute to the storage of a type should be
printed, and their names should be hidden from interfaces. Print them
with '_' as their name, and teach the parser to recognize these special
patterns when parsing interface files.

Partially resolves rdar://43810647

* Address review comments

* Disable accessor generation for nameless vars

* Test to ensure interface files preserve type layout

* Ignore attribute differences on Linux
2018-09-06 09:58:33 -07:00
Harlan
dc1bc823e6 [InterfaceGen] Remove #ifs from default arguments (#19075)
* [InterfaceGen] Remove #ifs from default args

This patch removes all #if configs form the bodies of default arguments,
which can contain multiline closures, while preserving the bodies of the
clauses that are active.

This code is generalized and should "just work" for inlinable function
bodies, which will come in a later patch.

* Address review comments

* Fix and test CharSourceRange.overlaps

* Fix CharSourceRange::print to respect half-open ranges
2018-08-31 20:18:48 -07:00
Jordan Rose
eeb8f330f9 [ModuleInterface] Allow conformances to be missing value witnesses (#18932)
It's not clear whether we'll actually need this feature in the long
run, but we certainly need it now because non-@usableFromInline
members can (currently) satisfy public requirements when a
@usableFromInline internal type conforms to a public protocol. In
these cases, we'll treat the witnesses as present but opaque, and
clients will perform dynamic dispatch when using them even when
a generic function gets specialized.

With this, we're able to generate a textual interface for the standard
library, compile it back to a swiftmodule, and use it to build a Hello
World program!
2018-08-23 16:46:06 -07:00
Jordan Rose
46a542e75b Merge pull request #18863 from jrose-apple/gutenberg
Small improvements to AST printing in service of textual interfaces
2018-08-21 14:47:24 -07:00
Jordan Rose
71a2adbdde Check default arguments even if a function has no body (#18864)
This is needed for textual interfaces, but the behavior doesn't
have to be specific to that, since functions without bodies don't
come up in other situations.
2018-08-21 10:41:24 -07:00
Jordan Rose
7046980f99 [ModuleInterface] Print normally unprinted attributes
We need @_transparent to control mandatory inlining; @_fixed_layout to
control, well, layout; and @_effects to help optimization. We still
don't need the ImplicitlyUnwrappedOptional attribute, and we don't
need access control attributes (because we handle that uniformly).

This also fixes up the printing of the '_effects' attribute to include
its underscore, so that it matches the source spelling.
2018-08-20 18:30:01 -07:00
Jordan Rose
ad4d72568a [AST] Print "__owned" and "__shared" with leading underscores
The type printer was being optimistic about these, but that's a
problem for testing textual interfaces right now.
2018-08-20 18:30:00 -07:00
Jordan Rose
a17dbfbf29 Merge pull request #18778 from jrose-apple/towards-stability
[ModuleInterface] More changes to printing and parsing .swiftinterface files
2018-08-17 09:10:57 -07:00
Jordan Rose
dd8b37ee9f Merge pull request #18772 from jrose-apple/access-denied
Stop printing access on extensions and protocol requirements
2018-08-16 18:24:58 -07:00
Jordan Rose
c62fcad553 Don't synthesize initializers in swiftinterface files
...and then don't complain about a class not having any initializers.
2018-08-16 17:59:24 -07:00
Jordan Rose
0ca78265ef [ModuleInterface] Allow global/static variables without initial values 2018-08-16 17:59:24 -07:00
Jordan Rose
f061dff9b7 [ModuleInterface] Don't print typealiases that match generic params
These are synthesized to satisfy associated type requirements, but
they're not needed in source, and they look like self-referential
definitions (`typealias X = X`).
2018-08-16 17:59:24 -07:00
Jordan Rose
6526f11400 [ModuleInterface] Don't print access on extensions
This ends up meaning "don't print access attributes, then print access
uniformly on ValueDecls if you're not printing access attributes".
2018-08-16 16:00:42 -07:00
Jordan Rose
1a3cb5b630 [ModuleInterface] "Smoke test" struct and enum declarations too
This is not an exhaustive test of language features, but it at
least checks that the simple stuff is working.
2018-08-16 15:52:18 -07:00
Jordan Rose
e2a245d211 [SILGen] Also handle initializers without bodies
I was surprised to see this parses fine already, but SILGen still
needs a new check.
2018-08-16 15:52:18 -07:00
Jordan Rose
ec0719d3e0 Handle parsing deinitializers without bodies for .swiftinterfaces
The presence of a deinitializer will eventually indicate whether a
class's deinitializer is non-trivial for non-resilient modules.

Also improve recovery for normal source files for various bad ways
of declaring a deinitializer.
2018-08-16 15:48:13 -07:00
Jordan Rose
318e988ae1 [Parse] Allow parsing accessors without bodies for .swiftinterfaces
We're going to do need to do more here for inlinable accessors, which
/do/ have bodies, but this helps us get to a bare minimum testing
configuration.
2018-08-16 13:57:45 -07:00
Jordan Rose
d9e47650d5 Add a new SourceFileKind and InputFileKind for textual interfaces
And test this by tweaking the rules to allow functions without
definitions, like SIL files.
2018-08-07 08:55:07 -07:00
Jordan Rose
59940b7f04 [ModuleInterface] Filter using access control and @usableFromInline (#18521)
These are the parts of a (resilient) module that affect the public
interface and ABI; everything else is uninteresting. Or at least ought
to be.
2018-08-06 19:40:44 -07:00
Jordan Rose
e8e0584785 Hook up -emit-interface-path to a simple AST printer
We'll want more complexity soon, but this is a start.
2018-08-01 14:34:29 -07:00