Commit Graph

1116 Commits

Author SHA1 Message Date
Xi Ge
cf79163764 test: update test to combine @available with @_originallyDefinedIn 2019-12-17 11:29:56 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -08:00
Xi Ge
5a862e49bd Merge pull request #28369 from nkcsgexi/originally-defined-in-attribute
AST: introduce a new attribute @_originallyDefinedIn to the AST
2019-11-21 20:26:29 -08:00
Xi Ge
7f8c04e0b7 AST: introduce a new attribute @_originallDefinedIn to the AST
We need this attribute to teach compiler to use a different name from the current
module name when generating runtime symbol names for a declaration. This is to serve
the workflow of refactoring a symbol from one library to another without breaking the existing
ABI.

This patch focuses on parsing and serializing the attribute, so @_originallyDefinedIn
will show up in AST, swiftinterface files and swiftmodule files.

rdar://55268186
2019-11-21 14:25:57 -08:00
Harlan Haskins
22bab7c5f7 [ModuleInterface] Fix indentation for private(set) vars
Previously, we would print

```swift
public private(set) var x: Int
```

as

```swift
@_hasStorage public var x: Swift.Int {
  get
  }
```

which is a) incorrectly indented, and b) shouldn't have newlines in part
of the Generated Interface.

Fixes [SR-9816](https://bugs.swift.org/browse/SR-9816)
2019-11-21 13:56:07 -08:00
swift_jenkins
f584bc4b9c Merge remote-tracking branch 'origin/master' into master-next 2019-11-21 04:00:10 -08:00
Suyash Srijan
4c85dd65ae Merge pull request #28216 from theblixguy/fix/SR-11762
[Typechecker] Fix _modify for properties using a property wrapper
2019-11-21 11:42:03 +00:00
swift_jenkins
f919e12436 Merge remote-tracking branch 'origin/master' into master-next 2019-11-17 15:40:26 -08:00
Michael Gottesman
269762eee3 [ownership] Enable ownership lowering /after/ the diagnostic passes.
I also updated the last group of straggling tests.
2019-11-17 11:34:43 -08:00
Suyash Srijan
0cd59069d3 [Test] Update a few failing tests 2019-11-16 16:32:39 +00:00
swift-ci
06850c23dc Merge remote-tracking branch 'origin/master' into master-next 2019-11-11 21:10:01 -08:00
Harlan Haskins
9d08d4f48c [ModuleInterface] Don't print @_staticInitializeObjCMetadata
This attribute is computed during the build and is rejected by the
parser. Make sure not to print it.

Fixes rdar://56923079
2019-11-11 17:25:35 -08:00
Xi Ge
64c0680686 Merge remote-tracking branch 'apple/master' into master-next 2019-10-28 10:19:36 -07:00
Daniel Rodríguez Troitiño
eaae6f73d7 XFAIL SDKDependencies test in Windows.
Windows paths attack again. Some paths from the dependency tracker have
mixed folder separators, so comparing textually fail. Additionally some
paths seems to be extended paths (\\?\) which seems not to be liked by
LLVM path utilities.
2019-10-17 10:09:51 -07:00
Varun Gandhi
68a68cb564 Merge pull request #27635 from varungandhi-apple/vg-robustify-module-trace-emission
Make module trace emission more robust.
2019-10-15 20:45:04 -07:00
Varun Gandhi
903add2c3f [Frontend] Make the module trace emission more robust.
✔ More informative error messages in case of crashes.
✔ Handling and documenting different cases.
✔ Test cases for different cases.
✔ Make SDKDependencies.swift pass again.
2019-10-15 15:44:26 -07:00
Harlan Haskins
bcd6b0f202 [ModuleInterfaces] Don't diagnose @NSManaged properties with accessors
Normally, we diagnose @NSManaged properties that have getters and
setters because they are actually supposed to be stored properties with
special synthesized accessors. Since we print those accessors in module
interfaces, just don't error when we see them.

Fixes rdar://56111556
2019-10-14 18:08:51 -07:00
Varun Gandhi
f969320883 Emit traces related to sdk dependencies and mark test case failing.
Exposes the issue in rdar://problem/55752426.
2019-10-11 17:23:07 -07:00
swift-ci
2ff9c51fe1 Merge remote-tracking branch 'origin/master' into master-next 2019-10-02 23:49:45 -07:00
Harlan Haskins
ce531be1bc Merge pull request #27469 from harlanhaskins/target-acquired
[ModuleInterfaces] Combine the normalized target triple into the cache hash
2019-10-02 23:35:24 -07:00
Harlan Haskins
c0908160a6 [ModuleInterfaces] Combine the normalized target triple into the cache hash
Previously, we'd combine just the target architecture, and rely on the
fact that the .swiftinterface is in a reasonably-target-specific
subdirectory to include enough entropy to avoid hash collisions. But in
the presence of a VFS or if two targets are sharing the same
.swiftinterface file (which can sometimes happen in tests), they will
collide since the hash only includes architecture.

Instead, use the same normalization that the serialized module loader
uses, and serialize the normalized target triple instead.

Fixes rdar://55881335
2019-10-02 11:43:55 -07:00
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