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
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)
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.
✔ More informative error messages in case of crashes.
✔ Handling and documenting different cases.
✔ Test cases for different cases.
✔ Make SDKDependencies.swift pass again.
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
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
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
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`
```
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".
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`.
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.
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.
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!
* [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
* [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
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.
* 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
* [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
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.
* [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
* [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
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!
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.
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.