Commit Graph

2017 Commits

Author SHA1 Message Date
Harlan Haskins
c82c9b8210 [ModuleInterfaces] Remove references to 'parseable' interfaces everywhere
Now that we've settled on Module Interface as the name, let's remove the
vestiges of "Parseable Interfaces"
2019-09-13 14:55:48 -07:00
Robert Widmann
23969e9555 Clean up the way Parse deals with GenericParamList
- The parser no longer mutates these in place
- Pass generic param lists off to constructors that will readily take them
2019-09-06 17:20:28 -07:00
Slava Pestov
c87e1a23db Sema: Try harder not to page in all members of imported classes 2019-09-03 22:39:35 -04:00
Rintaro Ishizaki
27ded648cf Merge pull request #26974 from rintaro/syntaxparse-roundtrip2
[SyntaxParse] Don't discard 'typealias' without identifier
2019-09-03 19:58:59 +02:00
Doug Gregor
d7f6768a9d Eliminate DelayedParsingCallbacks.
DelayedParsingCallbacks only had one implementation, for code
completion, which is only used to determine which bodies to skip and
which to delay. Inline that logic into the parser's delay logic and
remove DelayedParsingCallbacks entirely.
2019-09-02 19:03:07 -07:00
Doug Gregor
b3e3d39ab3 [Parser] Only skip function bodies when delayed callbacks tell us to. 2019-09-02 19:03:07 -07:00
Doug Gregor
d8b745db77 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-31 16:23:08 -07:00
eeckstein
903eeb220b Revert "Add a request to lazily parse function bodies." 2019-08-31 12:29:01 +02:00
Doug Gregor
7ce3553c45 Merge pull request #26972 from DougGregor/request-function-body-parse
Add a request to lazily parse function bodies.
2019-08-30 21:57:15 -07:00
Rintaro Ishizaki
992cc032a7 [SyntaxParse] Don't discard 'typealias' without identifier
Fixes round trip issue
2019-08-30 16:59:40 -07:00
Doug Gregor
2ab05a6835 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-30 16:48:23 -07:00
Doug Gregor
7e21c16c66 Merge pull request #26955 from DougGregor/simplify-lazy-member-parsing
Simplify lazy member parsing
2019-08-30 14:41:29 -07:00
Doug Gregor
11969847c4 Simplify lazy parsing of nominal and extension members.
Lazy parsing for the members of nominal types and extensions depends
only on information already present in
`IterableDeclContext`. Eliminate the use of PersistentParserState as
an intermediary and have the member-parsing request construct a new
`Parser` instance itself to handle parsing. Make this possible even
for ill-formed nominal types/extensions to simplify the code path.

Eliminate `LazyMemberParser` and all of its uses, because it was only
present for lazy member parsing, which no longer needs it.
2019-08-30 08:29:43 -07:00
Rintaro Ishizaki
e49401bbca Merge pull request #26937 from rintaro/syntaxparse-leakfix
[SyntaxParse] Fix memory leaks
2019-08-30 01:28:46 +02:00
Rintaro Ishizaki
1ca90ef757 [SyntaxParse] Fix memory leaks
There were a few places discarding recorded syntax:
- '#<code-complete>' at top-level (this should be parsed as UnknownDecl).
- 'typealias' decl with inheritance clause in protocol decl.
2019-08-29 13:10:39 -07:00
Doug Gregor
9dd5a3cdd6 [Parser] Make delayed member parsing not depend on "persistent parser" state.
The `DelayedDeclKind` structure that's allocated for each case where
we delay parsing the members of a nominal type definition or extension
contains information that is already available on the
`IterableDeclContext` (or can be reconstructed trivially from it). Use
that AST information rather than this side structure.
2019-08-29 11:05:25 -07:00
Doug Gregor
d8f7c9e72c [Parser] Introduce a request for parsing type and extension members.
Ensure that lazy parsing of the members of nominal type definitions
and extensions is handled through a request. Most of the effort here
is in establishing a new request zone for parser requests.
2019-08-28 21:39:56 -07:00
Nathan Hawes
57e1732d50 Merge pull request #26919 from nathawes/r54219186-interpolated-string-code-completion-crash
[code-completion] Don't delay parsing a decl within a closure - delay the decl containing that closure instead
2019-08-28 17:18:30 -07:00
Nathan Hawes
746340f9d9 [code-completion] Don't delay parsing a decl within a closure - delay the decl containing that closure instead
We were losing the CurLocalContext state (set when entering the closure's
BraceStmt) through the delaying process, sometimes causing errors when we
got back to parsing a delayed decl.

Resolves rdar://problem/54219186
2019-08-28 14:44:25 -07:00
Rintaro Ishizaki
cb308b7e53 Revert "Revert "[Parser] Decouple the parser from AST creation (part 2)""
This reverts commit 8ad3cc8a82.
2019-08-27 14:36:41 -07:00
Rintaro Ishizaki
8ad3cc8a82 Revert "[Parser] Decouple the parser from AST creation (part 2)" 2019-08-27 12:28:48 -07:00
Robert Widmann
36765687b9 Merge pull request #26844 from CodaFi/extension-intervention
Requestify Extension Type Validation
2019-08-27 11:23:18 -07:00
Robert Widmann
8d22702a22 Use Integrated Caching
Replumb the TypeLoc for the extended type as a TypeRepr instead. Fixup
the myriad callsites this touches in the process.
2019-08-26 11:48:29 -07:00
Rintaro Ishizaki
3f4a4c0e2f [SyntaxParse] Don't record tokens while skipping 2019-08-26 19:10:51 +02:00
Luciano Almeida
f4423211ac SR-11261: [Diagnostics][Qol] Parser recovery for keyword (#26596)
* Fixes SR-11261
* Improving diagnostics for multi-case declaration that uses a keyword
* Only doing pattern matching if token is not a keywork or if is a possible identifier
* Using BacktrackingScope to fix expected pattern
* Updating NameLoc with the token consumed.
* Updating Name with the consumed token
2019-08-23 05:50:44 +02:00
Rintaro Ishizaki
64dab42e96 Merge pull request #26670 from rintaro/syntax-parse-sil-else
[Syntax] Create UnknownDecl node for orphan #else, et al. and SIL nodes
2019-08-16 07:03:59 +02:00
Rintaro Ishizaki
223de71ad3 [Syntax] Create UnknownDecl node for orphan #else, et al. and SIL nodes 2019-08-16 00:59:20 +00:00
Slava Pestov
70bcd74ed0 Sema: Introduce IsImplicitlyUnwrappedOptionalRequest 2019-08-15 18:41:42 -04:00
Slava Pestov
1c3ac86796 AST: Banish OptionalTypeKind to ClangImporter.h
The only place this was used in Decl.h was the failability kind of a
constructor.

I decided to replace this with a boolean isFailable() bit. Now that
we have isImplicitlyUnwrappedOptional(), it seems to make more sense
to not have ConstructorDecl represent redundant information which
might not be internally consistent.

Most callers of getFailability() actually only care if the result is
failable or not; the few callers that care about it being IUO can
check isImplicitlyUnwrappedOptional() as well.
2019-08-15 18:41:42 -04:00
Slava Pestov
19d283d9dc AST: Replace ImplicitlyUnwrappedOptionalAttr with Decl::{is,set}ImplicitlyUnwrappedOptional() 2019-08-15 18:41:41 -04:00
Slava Pestov
94149db4ec Parse: Record which delayed type and extension bodies possibly contain operators and classes
To properly delay parsing type and extension bodies we need to know
which ones might contain nested operator and class definitions, since
they must be known upfront when building the global operator lookup
and AnyObject dispatch lookup tables, respectively.

To guess if the type contains operator definitions, we look for the
'func' keyword followed by an operator token.

To guess if the type contains class definitions, we look for the
'class' keyword.

For now, this information is recorded but not used. Subsequent commits
will make use of this information to delay parsing in more cases.
2019-08-12 17:15:51 -04:00
swift-ci
c43eb9b1d8 Merge pull request #26418 from nathawes/type-attr-coloring 2019-08-09 13:47:29 -07:00
Arnold Schwaighofer
5079f1e6de Don't emit a warning to import Foundation for dynamic decls even in Swift 4 mode
Dynamic does not imply @objc anymore.
2019-08-08 11:35:34 -07:00
David Ungar
e3d6e6b844 Merge pull request #26416 from davidungar/pbd-sourcerange
[ASTScope lookup] Fix PatternBindingEntry initializer getters and rectify its source range
2019-08-05 14:48:47 -07:00
David Ungar
b38076490b Address review comments re clarity
setOrigInit -> setOriginalInit
2019-08-05 13:42:35 -07:00
Nathan Hawes
5d47b45991 [IDE][Parse] Change the source location of TypeAttributes to point to the @ like DeclAttributes 2019-08-05 11:36:32 -07:00
David Ungar
1011998a97 Fix PatternBindingEntry::getSourceRange 2019-08-01 16:59:40 -07:00
Rintaro Ishizaki
1a211e6e5f Merge pull request #26403 from rintaro/gsoc-2019-part1
Reapply: [Parser] Decouple the parser from AST creation (part 1)
2019-08-01 18:41:11 +02:00
Slava Pestov
1ee2db4520 AST: Accessors no longer appear as members of their parent DeclContext
Accessors logically belong to their storage and can be synthesized
on the fly, so removing them from the members list eliminates one
source of mutability (but doesn't eliminate it; there are also
witnesses for derived conformances, and implicit constructors).

Since a few ASTWalker implementations break in non-trivial ways when
the traversal is changed to visit accessors as children of the storage
rather than peers, I hacked up the ASTWalker to optionally preserve
the old traversal order for now. This is ugly and needs to be cleaned up,
but I want to avoid breaking _too_ much with this commit.
2019-07-30 15:56:00 -04:00
Jan Svoboda
f0395a469a Revert "Revert "[Parser] Decouple the parser from AST creation (part 1)"" 2019-07-30 04:34:09 +00:00
David Ungar
d236a178ca Merge pull request #26095 from davidungar/parser-changes
[Parser] Fixes for ASTScope lookup
2019-07-29 19:59:00 -07:00
David Ungar
634a6eb718 Remove code for updating closure body. 2019-07-29 15:21:36 -07:00
David Ungar
30769127c8 Insert in order and other fix 2019-07-28 21:00:51 -07:00
Holly Borla
709efbc52c Sema: implement getInitKind using a request evaluator.
Add the request `InitKind` to lazily compute the kind of an initializer
declaration.
2019-07-26 15:55:09 -07:00
Holly Borla
58394eda5e Parse: check if constructor decls are marked as convenience rather than (indirectly) calling getInitKind
When we requestify `getInitKind`, we don't want to invoke the request during parsing. What the parsing code
really cares about is whether or not the decl has `ConvenienceAttr`.
2019-07-26 14:16:28 -07:00
David Ungar
9f60bb4c2f Adapt to streamlined record. 2019-07-25 08:44:02 -07:00
David Ungar
008791fc0a Ensure that an accessor can be found from its VarDecl. 2019-07-25 07:50:39 -07:00
David Ungar
691b3c6f30 When delayed parsing a Decl in a closure body, add it to the body. 2019-07-25 07:50:39 -07:00
David Ungar
6577e68b6b Fixes for review 2019-07-25 07:50:39 -07:00
David Ungar
3c7de8d707 Oops! Missed porting over the line to set the alias decl end. 2019-07-25 07:50:39 -07:00