Commit Graph

2017 Commits

Author SHA1 Message Date
David Ungar
d61f6f2f66 Changes to support per-type-body fingerprints. 2020-01-27 15:14:46 -08:00
Brent Royal-Gordon
0c478b6be6 Revert "Merge pull request #28665 from CodaFi/the-phantom-menace"
This reverts commit 43a3ab7e35, reversing
changes made to 4f39d9c749.

# Conflicts:
#	include/swift/AST/Attr.def
#	lib/AST/Attr.cpp
#	lib/Serialization/Deserialization.cpp
#	lib/Serialization/ModuleFormat.h
#	lib/Serialization/Serialization.cpp
2020-01-15 15:28:42 -08:00
Dan Zheng
6a7f84048d [AutoDiff upstream] Store @differentiable original declaration. (#29082)
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.
2020-01-09 10:33:22 -08:00
Hamish Knight
6b87dce845 Remove DelayedDeclLists from PersistentParserState
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.
2020-01-08 10:54:11 -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
Robert Widmann
19f0d52eca Merge pull request #28995 from CodaFi/absolutely-path-ological
[NFC] Hide SourceFile::Decls
2020-01-06 18:48:55 -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
Robert Widmann
96b3b9f0f4 [NFC] Hide SourceFile::Decls
In preparation for installing some stable paths infrastructure here,
hide access to the array of top-level decls.
2020-01-03 14:14:00 -08:00
Slava Pestov
0514248f9d Merge pull request #28596 from slavapestov/fun-with-guard-let
Fix various problems with top-level 'guard' statements and captures
2019-12-20 10:07:16 -05:00
Kita, Maksim
b4b3f98d86 SR-11889: Fixed code review issues
1. Use Located in Convention structure
2019-12-20 17:19:00 +03:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
Dan Zheng
14ee6c5d1c [AutoDiff] Enable @derivative attribute qualified declaration names. (#28892)
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.
2019-12-19 21:06:20 -08:00
Slava Pestov
72018dbe6a Parse: Remove some dead code 2019-12-19 23:46:01 -05:00
Rintaro Ishizaki
62c44126b6 [SourceKit] Reuse compiler instance between multiple completion
- 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
2019-12-18 21:52:20 -08: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
cd1400d675 Merge branch 'master' of github.com:apple/swift into upstream-transpose-attr 2019-12-17 12:44:29 -08:00
Dan Zheng
aecf9a171a Fix qualified name parsing syntax verification errors. 2019-12-17 12:17:36 -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
9fa4303dd4 [NFC] Switch uses over to parseDeclNameRef() 2019-12-15 23:46:42 -08:00
Brent Royal-Gordon
6a8598a99c [NFC] Remove DeclNameRef staging calls 2019-12-11 00:55:18 -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
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