Commit Graph

1645 Commits

Author SHA1 Message Date
Brent Royal-Gordon
addbe3e5ed [NFC] Thread DeclNameRef through most of the compiler
This huge commit contains as many of the mechanical changes as possible.
2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
1df792ae9f [NFC] Convert TypeRepr to use DeclName(Loc)?
Replaces `ComponentIdentTypeRepr::getIdentifier()` and `getIdLoc()` with `getNameRef()` and `getNameLoc()`, which use `DeclName` and `DeclNameRef` respectively.
2019-12-11 00:45:08 -08:00
Robert Widmann
06d27f08fd Define @_implicitly_synthesizes_nested_requirement
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.
2019-12-10 16:28:50 -08:00
Dan Zheng
0585eb0e90 [AutoDiff upstream] Add @derivative(of:) attribute. (#28321)
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).
2019-12-10 09:29:43 -08:00
Varun Gandhi
3cc452eee8 Merge pull request #28479 from varungandhi-apple/vg-allow-clang-types-in-convention-attr
Allow spelling out a C type in the convention attribute.
2019-12-09 18:36:56 -08:00
Rintaro Ishizaki
83c1e7bf4a Merge pull request #28433 from rintaro/ide-completion-secondpassend
[CodeCompletion] Stop using temporary Lexer in the second pass
2019-12-03 17:08:58 -08:00
Varun Gandhi
fb59293fe1 [Parse] Add a cType key to the convention attribute.
For example, one may write a calling convention like

  convention(c, cType: "void *(void)")

for a procedure that takes no arguments.
2019-12-02 21:06:01 -08:00
Rintaro Ishizaki
5c60af3ab1 Merge pull request #28403 from rintaro/parse-skipbracedblock-adjust
[Parse] Adjust skipBracedBlock()
2019-12-02 13:44:02 -08:00
swift-ci
0af22a47e3 Merge pull request #28329 from marcrasi/tf-971 2019-12-02 12:05:52 -08:00
Rintaro Ishizaki
8fae0893e1 [CodeCompletion] Don't use temporary Lexer in the second pass
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.
2019-11-22 17:18:32 +09: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
Rintaro Ishizaki
9dfac63ae8 [Parse] Adjust skipBracedBlock()
- 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.
2019-11-21 15:18:13 +09:00
Dan Zheng
baed3591e4 [AutoDiff upstream] Clean up parsing and printing. (#28377)
- 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.
2019-11-20 12:37:04 -08:00
Marc Rasi
8bb7c46567 [AutoDiff upstream] fix TF-971 2019-11-18 12:29:53 -08:00
Robert Widmann
f4d333d066 Sink a bunch of semantic options into TypeCheckerOptions
Sink
- DebugConstraintSolver
- DebugConstraintSolverAttempt
- DebugConstraintSolverOnLines
- DebugGenericSignatures
- DebugForbidTypecheckPrefix
- SolverMemoryThreshold
- SolverBindingThreshold
- SolverShrinkUnsolvedThreshold
- SolverDisableShrink
- EnableOperatorDesignatedTypes
- DisableConstraintSolverPerformanceHacks
- SolverEnableOperatorDesignatedTypes
2019-11-12 22:39:49 -08:00
Rintaro Ishizaki
cd8ebe49bb [Parse/CodeCompletion] Cleanup code completion facilities in Parse
- 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
2019-11-13 03:21:03 +09:00
Rintaro Ishizaki
4e50237f54 [Parse/CodeCompletion] Cleanup code completion facilities in Parse
- delayParseFromBeginningToHere is useless. Use delayDecl() instead
- Inline PersistentParserState::delayTopLevel()
- Cleanup completion handling in parseDecl()
2019-11-13 02:52:22 +09:00
Gogul Balakrishnan
5accda22b2 [AutoDiff upstream] Introduce @differentiable attribute to mark functions as differentiable. (#27506)
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.
2019-11-11 13:58:34 -08:00
Michael Gottesman
3a4c4d09e2 Merge pull request #28100 from gottesmm/pr-b169c1785bc8360aa9d4661c79b7061aec94e6a5
[semantics] Add support for annotating VarDecls with @_semantics.
2019-11-06 11:32:43 -08:00
Ben Langmuir
63ef99e20c Merge pull request #28014 from rintaro/ide-completion-secondpass-rdar56819166
[CodeCompleiton] Avoid walking the whole module to find the delayed func
2019-11-06 08:34:15 -08:00
Michael Gottesman
fe257d58a7 [semantics] Add support for annotating VarDecls with @_semantics.
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.
2019-11-05 17:31:58 -08:00
marcrasi
ce756e3189 [AutoDiff upstream] parsing for @differentiable function type (#27708)
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-871 https://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.
2019-11-04 23:40:04 -08:00
Rintaro Ishizaki
4b01a973f3 [CodeCompleiton] Avoid walking the whole module to find the delayed func
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
2019-11-01 10:51:40 -07:00
Robert Widmann
8a69f886ad Merge pull request #27955 from AnthonyLatsis/bracestmt_cleanup
NFC: Solidify and tidy up the BraceStmt interface
2019-10-31 13:48:40 -07:00
Robert Widmann
41d099bc91 Remove the argument to setInvalid() 2019-10-30 15:09:14 -07:00
Anthony Latsis
6325915b4b NFC: Solidify and tidy up the BraceStmt interface 2019-10-30 16:43:59 +03:00
Robert Widmann
5beb6f0f6e Restructure invalid parameter diagnostic
Diagnose the fact that we're missing a colon, not the fact that we're missing a type since that's actually what has gone wrong.
2019-10-24 09:56:02 -07:00
Robert Widmann
d67057a96f Clean up uses of setInvalid() and remove uses of isInvalid() in preparation for that being a semantic accessor. 2019-10-24 09:56:02 -07:00
Nathan Hawes
05ef088859 Revert "Remove The Last Vestiges of isInvalid from Parse" 2019-10-22 11:31:07 -07:00
swift-ci
4edefa8e14 Merge pull request #27820 from CodaFi/valid-the-impaler 2019-10-21 16:35:00 -07:00
Robert Widmann
961a1cf0a4 Clean up invalidation in Parse
Clean up uses of setInvalid() and remove uses of isInvalid() in preparation for that being a semantic accessor.
2019-10-21 15:17:07 -07:00
Rintaro Ishizaki
7c43083718 [SyntaxParse] Sink element layout check to right before node creations
ParsedRawSyntaxRecorder::recordRawSyntax() and
ParsedRawSyntaxNode::makeDeferred()
2019-10-18 17:46:17 -07:00
Rintaro Ishizaki
3eabc0df1c Merge pull request #27757 from rintaro/syntaxparse-orphantypealias
[SyntaxParse] Don't discard 'typealias' without identifier
2019-10-18 02:49:45 +02:00
Robert Widmann
56b6e53dae Remove raw references to PatternBindingEntry APIs
Switch most callers to explicit indices.  The exceptions lie in things that needs to manipulate the parsed output directly including the Parser and components of the ASTScope.  These are included as friend class exceptions.
2019-10-17 13:31:14 -07:00
Rintaro Ishizaki
9e99707e7f [SyntaxParse] Don't discard 'typealias' without identifier
Fixes round trip issue
2019-10-17 13:18:56 -07:00
David Ungar
2e8920ba64 Don't addUnvalidatedDeclWithOpaqueResultType when inside of an inactive clause environment. 2019-10-16 22:23:36 -07:00
Rintaro Ishizaki
aeec682c90 [SyntaxParse] Prevent memory leak in Syntax parsing
Essentially re-applying b09f87594a
2019-10-15 16:27:32 -07:00
Rintaro Ishizaki
8a03e08966 Revert "Merge pull request #26403 from rintaro/gsoc-2019-part1"
This reverts commit 1a211e6e5f, reversing
changes made to 482d0621a6.
2019-10-14 15:18:05 -07:00
Rintaro Ishizaki
570ed9361f Revert "Merge pull request #26883 from rintaro/revert-revert-26478-gsoc-2019-parser-types"
This reverts commit faaa3a859d, reversing
changes made to 62f947d6ba.
2019-10-14 15:18:05 -07:00
Rintaro Ishizaki
8df497dab6 Revert "Merge pull request #26974 from rintaro/syntaxparse-roundtrip2"
This reverts commit 27ded648cf, reversing
changes made to 42fdacc079.
2019-10-14 13:45:48 -07:00
Rintaro Ishizaki
00613db8db Revert "Merge pull request #27230 from rintaro/syntaxparsse-rdar55421369"
This reverts commit b09f87594a, reversing
changes made to d0b7ecab00.
2019-10-14 12:47:23 -07:00
Rintaro Ishizaki
8768832f24 Revert "Merge pull request #27281 from rintaro/reapply-syntaxparse-genericparam"
This reverts commit 5d3e8d6c83, reversing
changes made to 27e881d97e.
2019-10-14 12:46:31 -07:00
Rintaro Ishizaki
045593dcd9 Revert "Merge pull request #27308 from rintaro/parse-debuggercontextchange"
This reverts commit 3fd8481f06, reversing
changes made to e9bf767cbd.
2019-10-14 12:21:54 -07:00
Rintaro Ishizaki
fbc7c6c1c5 Revert "Merge pull request #27416 from rintaro/syntaxparse-declassociatedtype"
This reverts commit 5726179da9, reversing
changes made to d5adbe2c55.
2019-10-14 12:19:53 -07:00
Rintaro Ishizaki
4eadbaa9f6 Revert "Merge pull request #27466 from rintaro/syntaxparse-type"
This reverts commit a4fcd26b38, reversing
changes made to 88ecae4b9a.
2019-10-14 12:19:04 -07:00
Rintaro Ishizaki
c773c3b5cf Revert "Merge pull request #27485 from rintaro/syntaxparse-decltypealias"
This reverts commit 8c5dcc0fe5, reversing
changes made to af5eda5d24.
2019-10-14 12:18:47 -07:00
Rintaro Ishizaki
550865caf6 Revert "Merge pull request #27528 from rintaro/syntaxparse-rdar55952739"
This reverts commit 2ddba9cf21, reversing
changes made to 33770fa665.
2019-10-14 12:18:05 -07:00
Rintaro Ishizaki
cd1a2995ff Revert "Merge pull request #27531 from rintaro/syntaxparse-matchingtoken"
This reverts commit 2035658c57, reversing
changes made to 18f2b97641.
2019-10-14 12:17:45 -07:00
Rintaro Ishizaki
6f4dc258f5 Revert "Merge pull request #27544 from rintaro/syntaxparse-attrincomplete"
This reverts commit 071a7134b3, reversing
changes made to dbddb0d89a.
2019-10-14 12:17:27 -07:00