Commit Graph

1137 Commits

Author SHA1 Message Date
David Ungar
8f4fd061f9 Use Optional for fingerprint 2020-01-27 15:14:46 -08:00
David Ungar
d61f6f2f66 Changes to support per-type-body fingerprints. 2020-01-27 15:14:46 -08:00
kitaisreal
53c008f32c [Parser]: Labeled block without do diagnostics (#29147)
Improve diagnostics for labeled block without 'do'.
Parse and diagnose { identifier ':' '{' } as a labeled 'do' statement.

https://bugs.swift.org/browse/SR-3867
2020-01-15 23:51:59 -08:00
Dan Zheng
c9c51beda3 [AutoDiff] Attribute gardening. (#29050)
Upstream changes from `tensorflow` branch:
- https://github.com/apple/swift/pull/28932: deprecate `@differentiable(jvp:vjp)` arguments.
- https://github.com/apple/swift/pull/29038: gardening.

Additional gardening included.
2020-01-07 19:24:52 -08:00
Varun Gandhi
022314a640 Merge pull request #28643 from kitaisreal/using-located-instead-of-pair
[Compiler]: Using Located<T> instead of std::pair<SourceLoc, T>
2020-01-06 14:22:29 -08:00
Kita, Maksim
c1444dea18 SR-11889: Fixed code review issues 2019-12-20 17:18:59 +03:00
Slava Pestov
8e6dc39f14 Parse: Keep track of top-level declarations that follow a 'guard' statement 2019-12-19 23:46:56 -05:00
Slava Pestov
72018dbe6a Parse: Remove some dead code 2019-12-19 23:46:01 -05:00
Frederick Kellison-Linn
71697c37ca Allow implicit self in escaping closures when self usage is unlikely to cause cycle (#23934)
* WIP implementation

* Cleanup implementation

* Install backedge rather than storing array reference

* Add diagnostics

* Add missing parameter to ResultFinderForTypeContext constructor

* Fix tests for correct fix-it language

* Change to solution without backedge, change lookup behavior

* Improve diagnostics for weak captures and captures under different names

* Remove ghosts of implementations past

* Address review comments

* Reorder member variable initialization

* Fix typos

* Exclude value types from explicit self requirements

* Add tests

* Add implementation for AST lookup

* Add tests

* Begin addressing review comments

* Re-enable AST scope lookup

* Add fixme

* Pull fix-its into a separate function

* Remove capturedSelfContext tracking from type property initializers

* Add const specifiers to arguments

* Address review comments

* Fix string literals

* Refactor implicit self diagnostics

* Add comment

* Remove trailing whitespace

* Add tests for capture list across multiple lines

* Add additional test

* Fix typo

* Remove use of ?: to fix linux build

* Remove second use of ?:

* Rework logic for finding nested self contexts
2019-12-20 02:38:41 +00:00
Rintaro Ishizaki
ff97c06e8d [CodeCompletion] Use offsets in the buffer for second pass state
So that we can use the different the buffer for the second pass from the
first pass.
2019-12-18 21:52:20 -08:00
Dan Zheng
fa31c75aac Create shared utility Parser::canParseSimpleTypeIdentifier.
Use it in both `Parser::canParseTypeIdentifier` and
`Parser::canParseBaseTypeForQualifiedDeclName`.
2019-12-17 16:35:01 -08:00
Dan Zheng
c736938911 Address parsing/syntax review feedback. 2019-12-17 16:21:28 -08:00
Dan Zheng
cd1400d675 Merge branch 'master' of github.com:apple/swift into upstream-transpose-attr 2019-12-17 12:44:29 -08:00
Dan Zheng
c842fee0a4 [AutoDiff upstream] Add @transpose(of:) attribute.
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).
2019-12-16 12:23:08 -08:00
Brent Royal-Gordon
bed2ce4ac5 [NFC] Improve wording and usage of subscript/deinit flag 2019-12-15 23:46:42 -08:00
Brent Royal-Gordon
b5f02c3d0c [NFC] Remove unused Parser::parseUnqualifiedDeclName methods 2019-12-15 23:46:42 -08:00
Brent Royal-Gordon
c5747c3d96 [NFC] Refactor name parsing into Parser::parseDeclNameRef()
Gives this functionality a more self-documenting interface.
2019-12-15 23:46:42 -08:00
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
4b9a219d4f [NFC] Add DeclNameRef type to the compiler
This type wraps a DeclName, indicating that it is a reference to a declaration that exists somewhere else and it requires slightly “fuzzy” comparison (i.e. if it’s not compound, only the base names should be compared). DeclName::matchesRef() and MemberLookupTable::find() both now take a DeclNameRef instead of a DeclName.

This commit temporarily allows implicit conversion from DeclName; I’ll flip the switch on that in a later commit.
2019-12-11 00:45:08 -08:00
Brent Royal-Gordon
850583aceb [NFC] Extract Parser::parseUnqualifiedDeclBaseName 2019-12-11 00:45:07 -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
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
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
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
Robert Widmann
dd1b15775d Partially Revert #27862
When SE-110 was being implemented, we accidentally began to accept
closure parameter declarations that had no associated parameter names,
e.g.

foo { ([Int]) in /**/ }

This syntax has never been sanctioned by any version of Swift and should
be banned.  However, the change was made long enough ago and there are
enough clients relying on this, that we cannot accept the source break
at the moment.  For now, add a bit to ParamDecl that marks a parameter
as destructured, and back out setting the invalid bit on the type repr
for these kinds of declarations.

To prevent further spread of this syntax, stub in a warning that offers
to insert an anonymous parameter.

Resolves part of rdar://56673657 and improves QoI for errors like
rdar://56911630
2019-11-10 22:10:53 -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
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
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
e00fc0ce73 Revert "Merge pull request #27040 from rintaro/syntaxparse-rdar55075237"
This reverts commit 6e49443a91, reversing
changes made to 99d8042a70.
2019-10-14 13:42:58 -07:00
Rintaro Ishizaki
62408b0c78 Revert "Merge pull request #27046 from rintaro/syntaxparse-refactor-type"
This reverts commit a7d6612813, reversing
changes made to 111fb37f74.
2019-10-14 13:40:24 -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
baa0ef70b3 Revert "Merge pull request #27286 from nathawes/r55280477-tuple-type-syntax-round-trip"
This reverts commit 8555d1b84a, reversing
changes made to e315b6ff6a.
2019-10-14 12:39:44 -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
e53ad15b10 Revert "Merge pull request #27508 from rintaro/syntaxparse-expridentifier"
This reverts commit dfe962f19a, reversing
changes made to 04ce7bf779.
2019-10-14 12:18:26 -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
2f40f2493b Revert "Merge pull request #27565 from rintaro/syntaxparse-exprcollection"
This reverts commit 1724f5b704, reversing
changes made to bc1a3eaaa5.
2019-10-14 12:16:31 -07:00
Rintaro Ishizaki
0e8010d8b9 Revert "Merge pull request #27592 from rintaro/syntaxparse-exprtuple"
This reverts commit cdfd1ab2cf, reversing
changes made to eb02f20f99.
2019-10-14 12:15:48 -07:00
Rintaro Ishizaki
b56c543f0d Revert "Merge pull request #27607 from rintaro/syntaxparse-exprunresolvedmember"
This reverts commit 5e1f790b3b, reversing
changes made to 1846a5957e.
2019-10-14 12:15:12 -07:00
Rintaro Ishizaki
572cfe26a9 Revert "[SyntaxParse] Parse ObjC keypath expression syntax"
This reverts commit 1036d2a2bf.
2019-10-14 12:11:40 -07:00
Rintaro Ishizaki
1036d2a2bf [SyntaxParse] Parse ObjC keypath expression syntax 2019-10-11 11:55:22 -07:00