Commit Graph

3135 Commits

Author SHA1 Message Date
tbkka
c98d89543c Expanded discussion of protocol types (#33621)
* AnyObject behaves as if every class type implicitly conformed to it as a protocol.

* Protocols "inherit" from other protocols, and this has implications for casting to existential metatypes

I also moved the Any self-conformance invariant
to the self-conformance subsection and added a
couple of explanatory sentences.
2020-08-28 08:44:02 -07:00
Joe Groff
f588f2f478 Merge pull request #33650 from jckarter/global_init_mangling
Remove hardcoded symbol name parsing from SILOptimizer passes
2020-08-28 08:34:35 -07:00
Ole Begemann
6e8ee7cc49 [docs] Fix small mistake in DynamicCasting.md (#33641)
Foundation has no `Number` type.
2020-08-27 19:10:37 -07:00
Joe Groff
0bef4a661b Give global once symbols stabler manglings.
This allows symbol ordering and other analyses to be more robust with regards to these symbols.
2020-08-27 16:00:20 -07:00
tbkka
4c684d7a76 DynamicCast Rework, Part 1: Specification (#33010)
A specification for Swift's dynamic casting operations.

This specification tries to reflect the _intent_ of the current implementation, defining a consistent behavior that reflects as far as possible the behavior of the current implementation.  Deviations from this specification will generally be treated as bugs in the current implementation.
2020-08-17 13:37:57 -07:00
Marcel Hlopko
cb537b41fb [cxx-interop] Import typedef-ed template instantiations #32950 (#33451)
This is a roll-forward of https://github.com/apple/swift/pull/32950, with explicit c++17 version removed from tests. This is not needed since C++17 is the default anyway.

--

In this PR we teach `ClangImporter` to import typedef statements with template instantiation as its underlying type.

```c++
template<class T>
struct MagicWrapper {
  T t;
};

struct MagicNumber {};

typedef MagicWrapper<MagicNumber> WrappedMagicNumber;
```

will be made available in Swift as if `WrappedMagicNumber` is a regular struct. 

In C++, multiple distinct typedeffed instantiations resolve to the same canonical type. We implement this by creating a hidden intermediate struct that typedef aliasses.

The struct is named as `__CxxTemplateInst` plus Itanium mangled type of the instantiation. For the example above the name of the hidden struct is `__CxxTemplateInst12MagicWrapperI11MagicNumberE`. Double underscore (denoting a reserved C++ identifier) is used to discourage direct usage. We chose Itanium mangling scheme because it produces valid Swift identifiers and covers all C++ edge cases.

Imported module interface of the example above:

```swift
struct __CxxTemplateInst12MagicWrapperI11MagicNumberE {
  var t: MagicNumber
}
struct MagicNumber {}
typealias WrappedMagicNumber = __CxxTemplateInst12MagicWrapperI11MagicNumberE
```

We modified the `SwiftLookupTable` logic to show hidden structs in `swift_ide_test` for convenience.

Co-authored-by: Rosica Dejanovska <rosica@google.com>
Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
Co-authored-by: Robert Widmann <devteam.codafi@gmail.com>
2020-08-14 20:51:16 +02:00
Meghana Gupta
6b61818fff Revert "[cxx-interop] Import typedef-ed template instantiations (#32950)"
This reverts commit 643aa2d896.
2020-08-12 12:37:13 -07:00
Marcel Hlopko
643aa2d896 [cxx-interop] Import typedef-ed template instantiations (#32950)
In this PR we teach `ClangImporter` to import typedef statements with template instantiation as its underlying type.

```c++
template<class T>
struct MagicWrapper {
  T t;
};

struct MagicNumber {};

typedef MagicWrapper<MagicNumber> WrappedMagicNumber;
```

will be made available in Swift as if `WrappedMagicNumber` is a regular struct. 

In C++, multiple distinct typedeffed instantiations resolve to the same canonical type. We implement this by creating a hidden intermediate struct that typedef aliasses.

The struct is named as `__CxxTemplateInst` plus Itanium mangled type of the instantiation. For the example above the name of the hidden struct is `__CxxTemplateInst12MagicWrapperI11MagicNumberE`. Double underscore (denoting a reserved C++ identifier) is used to discourage direct usage. We chose Itanium mangling scheme because it produces valid Swift identifiers and covers all C++ edge cases.

Imported module interface of the example above:

```swift
struct __CxxTemplateInst12MagicWrapperI11MagicNumberE {
  var t: MagicNumber
}
struct MagicNumber {}
typealias WrappedMagicNumber = __CxxTemplateInst12MagicWrapperI11MagicNumberE
```

We modified the `SwiftLookupTable` logic to show hidden structs in `swift_ide_test` for convenience.

Resolves https://bugs.swift.org/browse/SR-12591.

Co-authored-by: Rosica Dejanovska <rosica@google.com>
Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
Co-authored-by: Robert Widmann <devteam.codafi@gmail.com>
2020-08-12 16:54:22 +02:00
Gabriel Igliozzi
ccd82a0589 [Gardening] Fixed 404 in SIL and SIL Optimizations -> HighLevelSILOptimizations.rst (#33384) 2020-08-10 16:31:48 +01:00
Marcel Hlopko
008cc3c2ea Document conventions for constructing names in mangling docs (#33203)
Co-authored-by: Robert Widmann <devteam.codafi@gmail.com>
Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
2020-08-10 08:50:05 +02:00
swift-ci
85dccde7b6 Merge pull request #33375 from rxwei/reword-manifesto 2020-08-07 19:03:22 -07:00
Richard Wei
ab4cdc12dc [Docs] [AutoDiff] Improve wording in various places in the manifesto. 2020-08-07 15:42:24 -07:00
Mishal Shah
b98085d69e [Doc] Update CI trigger for CentOS and Ubuntu 2020-08-06 23:44:28 -07:00
Gabriel Igliozzi
3ad98a504c [Docs] Fix broken url and filename (#33318) 2020-08-06 03:12:38 +01:00
Suyash Srijan
3502e07bf0 [Mangling] Add a new mangling for opaque return type to use when mangling an ObjC runtime name (#33035)
* [Mangling] Add a new mangling to represent opaque return type for ObjC runtime name

* [Docs] Add the new 'Qu' mangling to 'Mangling.rst' document

* [Test] Update test invocation arguments
2020-08-05 05:03:45 +01:00
Doug Gregor
f6e9f352f0 [Concurrency] Add async to the Swift type system.
Add `async` to the type system. `async` can be written as part of a
function type or function declaration, following the parameter list, e.g.,

  func doSomeWork() async { ... }

`async` functions are distinct from non-`async` functions and there
are no conversions amongst them. At present, `async` functions do not
*do* anything, but this commit fully supports them as a distinct kind
of function throughout:

* Parsing of `async`
* AST representation of `async` in declarations and types
* Syntactic type representation of `async`
* (De-/re-)mangling of function types involving 'async'
* Runtime type representation and reconstruction of function types
involving `async`.
* Dynamic casting restrictions for `async` function types
* (De-)serialization of `async` function types
* Disabling overriding, witness matching, and conversions with
differing `async`
2020-07-27 18:18:03 -07:00
Meghana Gupta
b34791a0a0 Update code as per Apple Style Guide
whitelist -> allowlist
blacklist -> denylist
2020-07-24 11:37:15 -07:00
nate-chandler
98253ae69c Merge pull request #32354 from nate-chandler/generic-metadata-prespecialization-components/crossmodule-structs-enums
[metadata prespecialization] Cross-module: structs and enums.
2020-07-21 08:04:00 -07:00
Robert Widmann
1db4120f48 Merge pull request #32731 from compnerd/sealed
docs: make Windows build instructions fully self-contained
2020-07-17 12:54:55 -07:00
Dan Zheng
f3685f9a12 [AutoDiff] Conform Optional to Differentiable. (#32948)
Make `Optional` conditionally conform to `Differentiable` when the `Wrapped` type does.
`Optional.TangentVector` is a wrapper around `Wrapped.TangentVector?`.

Also, fix `Array.TangentVector.zeroTangentVectorInitializer`.

Resolves TF-1301.
2020-07-17 12:07:52 -07:00
Robert Widmann
954fc46a7d Merge pull request #32938 from CodaFi/time-is-of-the-essence
[NFC] Remove -debug-time-compilation
2020-07-16 20:54:46 -07:00
Robert Widmann
2198d7174c Remove -debug-time-compilation
This flag no longer does anything now that the unified statistics
reporting infrastructure exists. It is better to use
-driver-time-compilation to see a bird's eye view of timing statistics
for frontend jobs, and -stats-output-dir to see a down-and-dirty view of
everything including performance counters.
2020-07-16 17:35:50 -07:00
Nate Chandler
d4b82bacca [metadata prespecialization] Cross-module: enums and structs.
When a generic type from a different module is not resilient within the
current module and at least one of its arguments is from the current
module, emit a non-canonical prespecialized record, and access that
metadata via a call to swift_getCanonicalSpecializedMetadata, passing in
the non-canonical record.

rdar://problem/56996727
rdar://problem/56997022
2020-07-16 14:14:01 -07:00
Michael Gottesman
8ea966319b [SIL.rst] Small bit of copy editing. 2020-07-16 13:12:20 -07:00
Erik Eckstein
5e21e46961 docs: add a dummy section for "begin_borrow" in SIL.rst
It fixes a doc build error
2020-07-16 18:51:19 +02:00
Michael Gottesman
8da561692b [docs] Begin adding section describing OSSA.
This just introduces ValueOwnershipKind and the partitioning of value users into
consuming and non-consuming users. I have more to add, but this I think is a
good start.
2020-07-15 15:30:27 -07:00
Michael Gottesman
6f101b88b4 Merge pull request #32830 from gottesmm/pr-3b0bbc9394dcb9de08d4961ea09ff4f7d918e6dd
[SIL.rst] Convert a bunch of bolded instruction names to inline links to the instructions docs.
2020-07-15 12:26:15 -07:00
Joe Groff
f807297f25 Merge pull request #32861 from jckarter/name-private-conformance-descriptor-cache
IRGen: Name the symbol for the private use area attached to protocol conformance descriptors.
2020-07-14 12:46:48 -07:00
Joe Groff
7d3a4b1c0c IRGen: Name the symbol for the private use area attached to protocol conformance descriptors.
Make it easier to track the memory usage of these symbols.
2020-07-14 10:02:43 -07:00
Michael Gottesman
3c95a19bd4 [SIL.rst] Convert a bunch of bolded instruction names to inline links to the instructions docs.
Seems useful to allow for quick navigation. I did not get all of them, but did a
bunch of them.
2020-07-10 15:01:33 -07:00
Michael Gottesman
5e36ae1c7c [sil] Add a forwarding cast called unchecked_value_cast.
Today unchecked_bitwise_cast returns a value with ObjCUnowned ownership. This is
important to do since the instruction can truncate memory meaning we want to
treat it as a new object that must be copied before use.

This means that in OSSA we do not have a purely ossa forwarding unchecked
layout-compatible assuming cast. This role is filled by unchecked_value_cast.
2020-07-09 21:14:32 -07:00
Saleem Abdulrasool
b8d9e3b9c7 docs: make Windows build instructions fully self-contained
Remove the extra repository dependency for the single cache file.
Update the build examples to simplify the cmake invocation
appropriately.
2020-07-06 23:14:00 +00:00
Ben Rimmington
49d4893ef6 Remove BooleanType from docs/StdlibRationales.rst 2020-07-02 14:49:47 +01:00
Robert Widmann
b766544327 Merge pull request #32642 from CodaFi/ossignpost
[Gardening] Clean Up OS Conditionals With canImport and Vendor=apple
2020-07-01 12:08:15 -07:00
Erik Eckstein
67605553df SIL: a new instruction 'base_addr_for_offset' for field offset calculations.
The ``base_addr_for_offset`` instruction creates a base address for offset calculations.
The result can be used by address projections, like ``struct_element_addr``, which themselves return the offset of the projected fields.
IR generation simply creates a null pointer for ``base_addr_for_offset``.
2020-07-01 15:10:08 +02:00
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport

This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
2020-06-30 22:55:58 -07:00
Richard Wei
9964215bfe Update status to indicate feature gate 2020-06-29 20:25:39 -07:00
Robert Widmann
6fcfbaaa51 Merge pull request #32523 from buttaface/linker
Driver: update old doc comments from when clang++ was the linker driver
2020-06-29 18:46:58 -07:00
Varun Gandhi
440cd0bcfc [docs] Add documentation describing external resources. (#32584) 2020-06-29 15:28:50 -07:00
Butta
e6fe8d47c2 Driver: update old doc comments from when clang++ was the linker driver 2020-06-24 18:38:03 +05:30
Bradley Mackey
96a0962c9c [docs] stdlib guide - fix legacy naming
_sanityCheck is now called _internalInvariant
2020-06-18 14:36:28 +01:00
Augusto Noronha
38fc849a1f Document Class Metadata offsets and fields when there is no Objective-C interoperability (#32374) 2020-06-16 14:59:41 -07:00
Saleem Abdulrasool
8bfaba76ff Update WindowsBuild.md
The CI is switching to ICU 67 since there are fixes in the latter version of ICU that are needed.  This should be further improved in the future to possibly use the the unicode.org releases.
2020-06-14 11:22:48 -07:00
Saleem Abdulrasool
8e832b6be0 Update WindowsBuild.md
Explicitly use the path to pyhon2.7 (although the tool can support python 3.x, the path is much much unwieldy as `"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe"`
2020-06-12 09:09:19 -07:00
Saleem Abdulrasool
1d1783943e Update WindowsBuild.md
Clean up some of the windows recommendations.  This is motivated by trying to setup a clean environment with @keith.

- migrate from `toolchain` to `llvm-project` for the LLVM project
- extract `swift` and `cmark` from the `llvm-project` directory structure
- use the `EXTERNAL_PROJECT` and `ENABLE_PROJECTS` properly
- convert artifact fetching to use a command line tool to fetch the URLs rather than manually using a browser

This now reflects the standard checkout layout more closely.
2020-06-11 18:06:30 -07:00
Dan Zheng
d3b6b89de6 [AutoDiff] Support multiple differentiability result indices in SIL. (#32206)
`DifferentiableFunctionInst` now stores result indices.
`SILAutoDiffIndices` now stores result indices instead of a source index.

`@differentiable` SIL function types may now have multiple differentiability
result indices and `@noDerivative` resutls.

`@differentiable` AST function types do not have `@noDerivative` results (yet),
so this functionality is not exposed to users.

Resolves TF-689 and TF-1256.

Infrastructural support for TF-983: supporting differentiation of `apply`
instructions with multiple active semantic results.
2020-06-05 16:25:17 -07:00
Varun Gandhi
09ea5fd1f7 [docs] Add module build related definitions to Lexicon. (#32153) 2020-06-04 14:40:17 -07:00
Varun Gandhi
67791cceac [docs] Add a how-to guide on running IWYU on the Swift project. (#32151) 2020-06-04 14:40:05 -07:00
martinboehme
4e0fad869c Add note that LLDB changes should be cherry-picked to swift/master (#32133)
* Add note that LLDB changes should be cherry-picked to `swift/master`

* New Swift-dependent commits should go to `swift/master`, not `swift/master-next`.

* Update naming scheme for release branches

* Fix indentation
2020-06-04 18:31:06 +02:00
Ted Kremenek
3ff520bbd1 Merge pull request #32006 from MForster/m/upstreaming-policy
Update LLVM development policy
2020-06-03 09:28:35 -07:00