Commit Graph

48 Commits

Author SHA1 Message Date
Owen Voorhees
43e2d107e1 [SE-0276] Implement multi-pattern catch clauses
Like switch cases, a catch clause may now include a comma-
separated list of patterns. The body will be executed if any
one of those patterns is matched.

This patch replaces `CatchStmt` with `CaseStmt` as the children
of `DoCatchStmt` in the AST. This necessitates a number of changes
throughout the compiler, including:
- Parser & libsyntax support for the new syntax and AST structure
- Typechecking of multi-pattern catches, including those which
  contain bindings.
- SILGen support
- Code completion updates
- Profiler updates
- Name lookup changes
2020-04-04 09:28:26 -07:00
Dan Zheng
6c29939f59 [AutoDiff upstream] Add @differentiable ASTScope support. (#29171)
`@differentiable` attributes may contain `where` clauses referencing generic
parameters from some generic context, just like `@_specialize` attributes.

Without special ASTScope support for `@differentiable` attributes,
ASTScopeLookup.cpp logic tries to resolve the generic parameter `DeclName`s in
`where` clauses based on source location alone
(`ASTScopeImpl::findChildContaining`) and fails.

The fix is to add a special `DifferentiableAttributeScope`, mimicking
`SpecializeAttributeScope`. Every `@differentiable` attribute has its own scope,
derived from the declaration on which it is declared. Unlike `@_specialize`,
`@differentiable` may also be declared on `AbstractStorageDecl` declarations
(subscripts and variables).

Upstreams https://github.com/apple/swift/pull/27451.

Progress towards TF-828: upstream `@differentiable` attribute type-checking.
2020-01-13 17:48:44 -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
Hamish Knight
01d5c00f9b [Sema] Requestify default arg type checking
This commit introduces a request to type-check a
default argument expression and splits
`getDefaultValue` into 2 accessors:

- `getStructuralDefaultExpr` which retrieves the
potentially un-type-checked default argument
expression.

- `getTypeCheckedDefaultExpr` which retrieves a
fully type-checked default argument expression.

In addition, this commit adds `hasDefaultExpr`,
which allows checking for a default expr without
kicking off a request.
2019-11-11 13:49:06 -08:00
David Ungar
f162a84e01 Factoring 2019-11-02 20:44:03 -07:00
David Ungar
37afa7cf98 Merge pull request #27435 from davidungar/A-9-29-recursion-assert
[ASTScopes] Use RequestEvaluator for ASTScope expansion to detect recursion
2019-10-10 19:42:22 -07:00
David Ungar
571d815c6a Remove radar numbers. 2019-10-10 17:39:42 -07:00
David Ungar
86ec6a00da Remove include order dependency 2019-10-08 14:08:43 -07:00
David Ungar
5908cfc5ba First cut at ASTScope expansion requestification 2019-10-08 09:05:19 -07:00
David Ungar
33f3213229 Fix for "private extension String { private extension String <eof>" 2019-10-03 14:47:08 -07:00
David Ungar
c25de6af75 Merge pull request #27221 from davidungar/A-9-17-astscope-off
[NFC, NameLookup, ASTScope] Bug fix for eager scope tree construction & better failure messages
2019-09-22 19:10:58 -07:00
David Ungar
5d87a66eda Ensure that after pushing start of ExtensionScope after extended type, the end is not before the beginning. 2019-09-22 17:59:40 -07:00
David Ungar
f33c4407dc Push range of extension scope after type, WIP 2019-09-22 17:59:39 -07:00
David Ungar
603cc05289 WIP lazy whole scopes 2019-09-22 17:59:39 -07:00
Jordan Rose
8d7f1b7c5d [AST] Separate SourceFile from FileUnit.h
Like the last commit, SourceFile is used a lot by Parse and Sema, but
less so by the ClangImporter and (de)Serialization. Split it out to
cut down on recompilation times when something changes.

This commit does /not/ split the implementation of SourceFile out of
Module.cpp, which is where most of it lives. That might also be a
reasonable change, but the reason I was reluctant to is because a
number of SourceFile members correspond to the entry points in
ModuleDecl. Someone else can pick this up later if they decide it's a
good idea.

No functionality change.
2019-09-17 17:54:41 -07:00
Jordan Rose
853caa66d4 [AST] Split FileUnit and its subclasses out of Module.h
Most of AST, Parse, and Sema deal with FileUnits regularly, but SIL
and IRGen certainly don't. Split FileUnit out into its own header to
cut down on recompilation times when something changes.

No functionality change.
2019-09-17 17:54:41 -07:00
David Ungar
e3f7760154 Add explanations to all asserts. 2019-09-17 16:30:25 -07:00
David Ungar
8ebba23b06 Add ASTScope_unreachable 2019-09-17 16:03:05 -07:00
David Ungar
3966d086a5 When ASTScope assertions fails, direct user to try disabling ASTScopes. 2019-09-17 15:56:33 -07:00
David Ungar
24ef696242 Lazy AbstractFunctionBodyScope creation 2019-09-13 17:02:51 -07:00
David Ungar
0c83088269 Better source-range checking for debugging 2019-09-13 17:01:21 -07:00
David Ungar
7e0d96cb59 Added debugging helpers for range-matching 2019-09-13 16:19:55 -07:00
David Ungar
7992e1c6c4 Lots of cleanups, renamings, etc. 2019-08-26 16:55:18 -07:00
David Ungar
b02b4b00ef Cleanup and fixes, also 1st cut at lazy. 2019-08-13 17:48:06 -07:00
David Ungar
f64033a2d2 Manual rebase with master 2019-08-06 22:13:20 -07:00
David Ungar
b38076490b Address review comments re clarity
setOrigInit -> setOriginalInit
2019-08-05 13:42:35 -07:00
David Ungar
1011998a97 Fix PatternBindingEntry::getSourceRange 2019-08-01 16:59:40 -07:00
Doug Gregor
015b7c5266 [AST] Use AbstractFunctionDecl::getBodySourceRange() more frequently.
A number of callers to AbstractFunctionDecl::getBody() were only
extracting the source range of the body... which can be retrieved more
efficiently with getBodySourceRange().
2019-07-11 21:31:21 -07:00
David Ungar
049c90ce29 Print source on error 2019-06-27 13:40:48 -07:00
David Ungar
8988fa9e7f Added fixmes 2019-06-12 12:04:43 -07:00
David Ungar
16ca723b00 Explain source ranges 2019-06-12 10:34:44 -07:00
David Ungar
e7cd5344f5 Fixed test 2019-06-10 15:47:42 -07:00
David Ungar
455b344397 fmt 2019-06-10 15:38:01 -07:00
David Ungar
edc6a5ce6d unfmt 2019-06-10 15:36:32 -07:00
David Ungar
f203509250 fixes, unfmted, rm startLocAccordingToCondition 2019-06-10 14:03:34 -07:00
David Ungar
17bb03112e new cond use scheme 2019-06-10 13:18:18 -07:00
David Ungar
7d1f024e07 WIP unfmt 2019-06-10 12:10:21 -07:00
David Ungar
22d37eccd8 WIP 2019-06-09 14:51:39 -07:00
David Ungar
bbd1f7618c WIP 2019-06-08 10:05:26 -07:00
David Ungar
3abfa1f384 WIP 2019-06-08 09:08:49 -07:00
David Ungar
670eb61f8e Spell out GTX 2019-06-05 15:54:10 -07:00
David Ungar
15d8a38589 Robustness 2019-06-05 15:35:24 -07:00
David Ungar
05d38e0c53 Source range optimization 2019-06-05 14:15:47 -07:00
David Ungar
1c0da7511c Renaming 2019-06-05 08:31:00 -07:00
David Ungar
e42ee8116d Fix assertion 2019-06-04 21:04:36 -07:00
David Ungar
e6012a4809 fixes 2019-05-31 13:56:29 -07:00
David Ungar
3f820c374e Some review tweaks. 2019-05-28 11:12:12 -07:00
David Ungar
663760e3b7 ASTOOScope ontology 2019-05-28 10:48:22 -07:00