Commit Graph

1357 Commits

Author SHA1 Message Date
Arnold Schwaighofer
2a2cf91dcd Add support for marking a _specialize attribute as SPI
```
  @_specialize(exported: true, spi: SPIGroupName, where T == Int)
  public func myFunc() { }
```

The specialized entry point is only visible for modules that import
using `_spi(SPIGroupName) import ModuleDefiningMyFunc `.

rdar://64993425
2020-10-12 09:19:29 -07:00
Arnold Schwaighofer
b994bf3191 Add support for _specialize(exported: true, ...)
This attribute allows to define a pre-specialized entry point of a
generic function in a library.

The following definition provides a pre-specialized entry point for
`genericFunc(_:)` for the parameter type `Int` that clients of the
library can call.

```
@_specialize(exported: true, where T == Int)
public func genericFunc<T>(_ t: T) { ... }
```

Pre-specializations of internal `@inlinable` functions are allowed.

```
@usableFromInline
internal struct GenericThing<T> {
  @_specialize(exported: true, where T == Int)
  @inlinable
  internal func genericMethod(_ t: T) {
  }
}
```

There is syntax to pre-specialize a method from a different module.

```
import ModuleDefiningGenericFunc

@_specialize(exported: true, target: genericFunc(_:), where T == Double)
func prespecialize_genericFunc(_ t: T) { fatalError("dont call") }

```

Specially marked extensions allow for pre-specialization of internal
methods accross module boundries (respecting `@inlinable` and
`@usableFromInline`).

```
import ModuleDefiningGenericThing
public struct Something {}

@_specializeExtension
extension GenericThing {
  @_specialize(exported: true, target: genericMethod(_:), where T == Something)
  func prespecialize_genericMethod(_ t: T) { fatalError("dont call") }
}
```

rdar://64993425
2020-10-12 09:19:29 -07:00
Brent Royal-Gordon
b440ab7331 [NFC] Move several types/functions to Import.h
To help consolidate our various types describing imports, this commit moves the following types and methods to Import.h:

* ImplicitImports
* ImplicitStdlibKind
* ImplicitImportInfo
* ModuleDecl::ImportedModule
* ModuleDecl::OrderImportedModules (as ImportedModule::Order)
* ModuleDecl::removeDuplicateImports() (as ImportedModule::removeDuplicates())
* SourceFile::ImportFlags
* SourceFile::ImportOptions
* SourceFile::ImportedModuleDesc

This commit is large and intentionally kept mechanical—nothing interesting to see here.
2020-10-09 18:57:07 -07:00
Robert Widmann
d695acfed1 Document 'standalone' Parameters 2020-10-06 11:50:00 -07:00
Robert Widmann
82e9935885 Correct the Serialization of Embedded Swift Dependencies
llvm-bcanalyzer does *not* like it when there are multiple block info metadata blocks in the same bitstream file. This patch will skip the emission of that and just jump straight to the metadata block when we're not reading a "standalone" incremental dependency file. While I'm here, also add the right block abbreviation info so we can get a decent dump from llvm-bcanalyzer
2020-10-05 18:40:43 -07:00
Fero
b0b546873c Fix typo 2020-10-02 01:26:33 +02:00
Varun Gandhi
8e63a4b43f [Serialization] Gate Clang type (de)serialization behind UseClangFunctionTypes. 2020-09-28 14:29:26 -07:00
Robert Widmann
d2e7bdcfab Teach SwiftModules To Embed Incremental Information
Take advantage of the binary swiftdeps serialization utliities built during #32131. Add a new optional information block to swiftdeps files. For now, don't actually serialize swiftdeps information.

Frontends will use this information to determine whether to write incremental dependencies across modules into their swiftdeps files. We will then teach the driver to deserialize the data from this section and integrate it into its incremental decision making.
2020-09-24 20:07:01 -06:00
Varun Gandhi
734b8a2533 Merge pull request #33986 from varungandhi-apple/vg-import-filter-cleanup
[NFC] Clarify import filtering logic and naming.
2020-09-23 18:23:11 -07:00
Varun Gandhi
4b5d885114 [NFC] Clarify semantics of getImportedModules.
The lack of clarity manifested as unexpected behavior when using
getImportedModules to create the module import graph. The new behavior
makes SPI-ness and Shadowing-ness behave similarly in terms of
filtering. We also check if a filter is well-formed to avoid
accidental empty import lists.
2020-09-23 12:50:37 -07:00
Varun Gandhi
d3369f7711 [NFC] Rename ImportFilterKind cases to be clearer. 2020-09-23 12:50:20 -07:00
Slava Pestov
d4cc35a938 AST: Remove VarDecl::hasNonPatternBindingInit() 2020-09-18 16:11:06 -04:00
Slava Pestov
8e83dd902f Sema: Don't compute isSimpleDidSet() from getStorageImplInfo() 2020-09-15 22:03:58 -04:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Holly Borla
3332df6f89 Merge pull request #33777 from hborla/rename-storage-wrapper
[NFC][Property Wrappers] Rename "storage wrapper var" to "projection var/projected value"
2020-09-03 18:29:04 -07:00
Holly Borla
3fd882cadf [NFC] Rename "storage wrapper var" to "projection var" or "projected value"
in property wrapper-related code.
2020-09-02 18:07:40 -07:00
swift_jenkins
fb946baf59 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-28 11:08:22 -07:00
Pavel Yaskevich
a6c3e6f543 Merge pull request #33658 from xedin/introduce-hole-type
[ConstraintSystem] Introduce a new type to represent a type hole
2020-08-28 10:40:15 -07:00
Pavel Yaskevich
78ea3de8e4 [AST] Introduce a new type to represent a type hole in constraint system
Instead of using `UnresolvedType` as a placeholder for a type hole,
let's switch over to a dedicated "rich" `HoleType` which is capable
of storing "originator" type - type variable or dependent member
type which couldn't be resolved.

This makes it easier for the solver to determine origins of
a hole which helps to diagnose certain problems better. It also
helps code completion to locate "expected type" of the context
even when it couldn't be completely resolved.
2020-08-26 16:55:39 -07:00
swift_jenkins
3134f7e170 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-24 20:25:48 -07:00
Slava Pestov
995eb66aa7 AST: Rename SpecializeAttr::getSpecializedSgnature() 2020-08-24 19:16:36 -04:00
Nathan Hawes
280d4c995a Merge remote-tracking branch 'upstream/master' into HEAD 2020-08-21 22:23:58 -07:00
Alexis Laferrière
2f7e0d496f Revert "Revert "[Serialization] Serialize isUserAccessible on functions""
This reverts commit bf25a01701.
2020-08-20 16:23:57 -07:00
swift_jenkins
8cfd9be2cb Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-19 15:06:17 -07:00
Nate Chandler
9b8828848d [SIL] Add SILFunctionType flag for async. 2020-08-19 11:29:58 -07:00
swift_jenkins
54abd7b0be Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-18 13:12:21 -07:00
Alexis Laferrière
bf25a01701 Revert "[Serialization] Serialize isUserAccessible on functions"
This reverts commit f523c88754.
2020-08-18 09:31:32 -07:00
swift_jenkins
9ab003bcf9 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-08-14 15:14:01 -07:00
Alexis Laferrière
f523c88754 [Serialization] Serialize the isUserAccessible bit on functions
rdar://problem/53891642
SR-7460
2020-08-14 09:50:31 -07:00
Nathan Hawes
51beab6889 Manually merge remote-tracking branch 'upstream/master' into HEAD
Conflicts:
	test/DebugInfo/modulecache.swift
2020-08-13 11:16:33 -07:00
Yuta Saito
d913e57d84 [Serialization] Serialize Differentiability WT index sorted
When there are sil_property and sil_differentiability_witness at once,
serialized file couldn't be deserialized because it's index table is
serialized un-sortedly but deserializer assumes that contents of table
index are sorted.

This patch fixes the un-sorted serialization and adds test case to
ensure that table index contents can be deserialized
2020-08-07 08:49:26 +09:00
Nathan Hawes
607e2b8822 Manually merge remote-tracking branch 'upstream/master' into HEAD 2020-08-04 13:47:48 -07:00
Varun Gandhi
3882beb85d [NFC] Use consistent naming scheme for predicate methods. (#33265)
bool throws() -> isThrowing(), bool async() -> isAsync()
2020-08-03 16:37:29 -07:00
Varun Gandhi
f219e58ada [NFC] Refactor ExtInfo to use a builder-pattern based API.
Since the two ExtInfos share a common ClangTypeInfo, and C++ doesn't let us
forward declare nested classes, we need to hoist out AnyFunctionType::ExtInfo
and SILFunctionType::ExtInfo to the top-level.

We also add some convenience APIs on (AST|SIL)ExtInfo for frequently used
withXYZ methods. Note that all non-default construction still goes through the
builder's build() method.

We do not add any checks for invariants here; those will be added later.
2020-07-31 13:55:55 -07:00
swift-ci
0d8e3e1d71 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-07-29 09:14:39 -07: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
Nathan Hawes
9d4ed5f39c Manually merge remote-tracking branch 'upstream/master' into manually-merge-master-to-master-rebranch 2020-07-20 16:09:55 -07:00
Michael Gottesman
d2f986739c Merge pull request #32940 from gottesmm/pr-8414ddbc369ed5bb8c0622162de920b962426cf1
[ast] Rename VarPattern -> BindingPattern.
2020-07-18 20:47:21 -07:00
Brent Royal-Gordon
4394e92c3f Merge pull request #32700 from brentdax/magical-and-evolutionary
Revise #file changes from SE-0274
2020-07-17 01:57:23 -07:00
Michael Gottesman
092edd6621 [ast] Rename VarPattern -> BindingPattern.
VarPattern is today used to implement both 'let' and 'var' pattern bindings, so
today is already misleading. The reason why the name Var was chosen was done b/c
it is meant to represent a pattern that performs 'variable binding'. Given that
I am going to add a new 'inout' pattern binding to this, it makes sense to
give it now a better fitting name before I make things more confusing.
2020-07-16 18:56:01 -07:00
Robert Widmann
638977454b Remove SharedTimer Infrastructure
Teach the UnifiedStatsReporter to directly construct
llvm::NamedRegionTimer for itself.
2020-07-16 17:35:50 -07:00
Brent Royal-Gordon
9a838bb654 Differentiate between Swift 5 and “Swift 6” #file
In -swift-version 5 and earlier, #file will continue to be a synonym for #filePath; in a future -swift-version (“Swift 6 mode”), it will become a synonym for #fileID. #file in libraries will be interpreted according to the language mode the library was compiled in, not the language mode its client uses.

Implement this behavior, tied to a frontend flag instead of a language version. We do so by splitting the old `MagicIdentifierLiteralExprKind::File` into two separate cases, `FileIDSpelledAsFile` and `FilePathSpelledAsFile`, and propagating this distinction throughout the AST. This seems cleaner than looking up the setting for the module the declaration belongs to every time we see `File`.

This doesn’t handle module interfaces yet; we’ll take care of those in a separate commit.
2020-07-13 14:06:55 -07:00
Brent Royal-Gordon
0e569f5d9e Add support for #fileID
This temporarily breaks -enable-experimental-concise-pound-file.

fixup adding #fileID
2020-07-13 14:05:13 -07:00
Dan Zheng
bf47403162 [AutoDiff] Serialize and print @derivative and @transpose accessor kind. (#32839)
Serialize and print the optional accessor kind in `@derivative` and `@transpose`
attributes.

Resolves TF-1293.
2020-07-12 15:04:49 -07:00
Nathan Hawes
4fd0cdc2ef Fix up calls to clang::Type::dump() now that it requires a clang::ASTContext. 2020-07-07 15:05:34 -07:00
swift_jenkins
63f5e3401f Merge remote-tracking branch 'origin/master' into master-next 2020-07-01 08:39:15 -07:00
David Zarzycki
fae2c19edb NFC: Make SILType.h and SILDeclRef.h not depend on SIL/*.h
SILType and SILDeclRef do not actually need anything from SIL/*.h. Also,
a few dependencies can be pushed out of the headers into cpp files to
speed up incremental rebuilds.
2020-07-01 08:05:58 -04:00
swift_jenkins
75bea14185 Merge remote-tracking branch 'origin/master' into master-next 2020-06-23 10:39:14 -07:00
Robert Widmann
0da060e95e Merge pull request #32447 from martinboehme/option-set-initializer-list
Give OptionSet an initializer_list constructor
2020-06-23 10:36:57 -07:00
Martin Boehme
d806ba53f6 Give OptionSet an initializer_list constructor.
This makes it easier to specify OptionSet arguments.

Also modify appropriate uses of ModuleDecl::ImportFilter to take
advantage of the new constructor.
2020-06-22 06:57:29 +02:00