Store in `DifferentiableAttr` the original declaration on which the attribute
is declared.
The original declaration is resolved during parsing and deserialization
(not yet upstreamed).
Progress towards TF-828: upstream `@differentiable` attribute type-checking.
Rather than parsing all delayed bodies for
`-dump-parse` once we finish parsing, tell the
parser not to delay any bodies. This then allows
us to remove `DelayedDeclLists` from
PersistentParserState.
Enable qualified declaration names in `@derivative` attribute, just like
`@transpose` attribute.
`DerivativeAttr` now stores a base type `TypeRepr *`, which is non-null for
parsed attributes that reference a qualified original declaration.
Add `TypeResolutionFlags::AllowModule` flag to enable module lookup via
`TypeChecker::lookupMember` given a `ModuleType`.
Add tests for type-qualified and module-qualified declaration names.
Resolves TF-1058.
- Introduce ide::CompletionInstance to manage CompilerInstance
- `CompletionInstance` vends the cached CompilerInstance when:
-- The compiler arguments (i.e. CompilerInvocation) has has not changed
-- The primary file is the same
-- The completion happens inside function bodies in both previous and
current completion
-- The interface hash of the primary file has not changed
- Otherwise, it vends a fresh CompilerInstance and cache it for the next
completion
rdar://problem/20787086
The `@transpose(of:)` attribute registers a function as a transpose of another
function. This patch adds the `@transpose(of:)` attribute definition, syntax,
parsing, and printing.
Resolves TF-827.
Todos:
- Type-checking (TF-830, TF-1060).
- Enable serialization (TF-838).
- Use module-qualified names instead of custom qualified name syntax/parsing
(TF-1066).
Replaces `ComponentIdentTypeRepr::getIdentifier()` and `getIdLoc()` with `getNameRef()` and `getNameLoc()`, which use `DeclName` and `DeclNameRef` respectively.
State the previously unstated nested type requirement that CodingKeys adds to the witness requirements of a given type. The goal is to make this member cheap to synthesize, and independent of the expensive protocol conformance checks required to append it to the member list.
Further, this makes a clean conceptual separation between what I'm calling "nested type requirements" and actual type and value requirements.
With luck, we'll never have to use this attribute anywhere else.
The `@derivative(of:)` attribute registers a function as a derivative of another
function. This patch adds the `@derivative(of:)` attribute definition, syntax,
parsing, and printing.
Resolves TF-826.
Todos:
- Type-checking (TF-829).
- Serialization (TF-837).
Since we only call one parsing function (i.e. parseAbstructFunctionBody,
parseDecl, or parseStmtOrExpr), the parser stops at the end of the node.
It's not necessary to limit the Lexer to set an ArtificialEOF.
To minimize the parsing range, modify the Parser to *not* parse the body
if the completion happens in the signature.
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
- Stop using skipBracedBlock() in parseDeclPrecedenceGroup(),
skipUntilDeclRBrace() is better at this context.
- Disable 'SyntaxParsingContext' inside skipBracedBlock()
- Removed unsound recovery logic in consumeAbstractFunctionBody(). This
doesn't match with the parser bahavior in the delayed parsing.
- Expose 'skipBracedBlock()' as a Parser instance method so it's usable
from other files.
- Use general `Parser::isIdentifier(Token, StringRef)` function.
- Remove specialized `isWRTIdentifier`, `isJVPIdentifier`, `isVJPIdentifier`
functions from `Parser`.
- Clarify doc comments and parameter nullability for attribute printing code:
`getDifferentiationParametersClauseString`.
- Minor formatting and naming updates.
- Rename code completion related names in 'PersistentParserState' so
it's clear when you are using.
- Refactor 'performCodeCompletionSecondPass()': Inline and consolidate
'parse*Delayed()' because they used to share many code.
rdar://problem/56926367
This PR introduces `@differentiable` attribute to mark functions as differentiable. This PR only contains changes related to parsing the attribute. Type checking and other changes will be added in subsequent patches.
See https://github.com/apple/swift/pull/27506/files#diff-f3216f4188fd5ed34e1007e5a9c2490f for examples and tests for the new attribute.
This is just for prototyping purposes. I also had to loosen a small restriction
where semantics functions were not allowed in local contexts. There really is no
reason to enforce this and I think since it came in the first commit that
introduced semanitcs it was most likely NadavR just being conservative and
careful.
Adds parsing for a type attribute `@differentiable`, which is optionally allowed to have argument `@differentiable(linear)`.
The typechecker currently rejects all uses of `@differentiable` with "error: attribute does not apply to type". Future work (https://bugs.swift.org/browse/TF-871https://bugs.swift.org/browse/TF-873) will update the typechecker to allow this attribute in places where it is allowed.
Resolves https://bugs.swift.org/browse/TF-822.
Previously delayed parsing was performed by AST walker
'ParseDelayedFunctionBodies' by finding "delayed" function decl from the AST
of the whole module. This is not necessary. Optimize it by remembering the
"delayed" function decl in 'PersistentParserState'.
NOTE: 'SourceLoader' stopped using this delayed parsing mechanism in
d8b745db77
rdar://problem/56819166