Commit Graph

1452 Commits

Author SHA1 Message Date
Xi Ge
033732b1e5 ASTVerifier: avoid verifying IterableDeclContext if it has unparsed members. 2018-09-12 14:11:41 -07:00
Xi Ge
7fbd10f170 Parser: disable delayed member decl parsing when parsing SIL. 2018-09-12 12:42:41 -07:00
Xi Ge
0a03259f4a Parser: disable lexer diagnostics during delayed parsing.
The lexer diagnostics have already been emitted during token skipping.
2018-09-11 16:30:57 -07:00
Xi Ge
b02c7b15a3 parser: on demand parsing of protocol decl members. 2018-09-11 16:30:57 -07:00
Xi Ge
1798317d13 parser: on demand parsing of struct decl members. 2018-09-11 16:19:55 -07:00
Xi Ge
8cac5530b1 parser: on demand parsing of class decl members. 2018-09-11 16:19:55 -07:00
Xi Ge
549bf5d48c Parser: rename canDelayBodyParsing to canDelayMemberDeclParsing. NFC 2018-09-10 15:21:01 -07:00
Xi Ge
1b53a3c34e Parser: disallow delayed decl member parsing if interface hash is requested.
Calculating interface hash requires tokens being consumed at a deterministic
order; thus we should disable delayed decl member parsing here.
2018-09-10 15:03:44 -07:00
Rintaro Ishizaki
66df646c67 Merge pull request #19206 from rintaro/rdar44228891
[Parse] Disable support for multiline/extended escaping string literal in attribute message
2018-09-11 02:01:32 +09:00
Xi Ge
c4db69451c Parser: Ignore and recover marked parse position during on-demand member parsing.
New construction of a parser instance will reset the marked parser
position in PersistentParserState. We should recover the marked parser
position during on-demand parsing in case the marked position will be
later used to create another parser instance to continue parsing
linearly.
2018-09-09 01:28:20 -07:00
Rintaro Ishizaki
59778f8ecb [Parse] Disable support for multiline/extended escaping string literal
in attribute message

Strings of diagnostics message processed in EncodedDiagnosticMessage
aren't necessarily from parsed Swift source code. That means, they might
not have quotes around it. Furthermore, memory around them might not be
managed. The logic in 'Lexer::getEncodedStringSegment()' used to cause
access violation.

For now, disable multiline string literal and extended escaping in string
literal for attribute message position. Considering the message might be
from Clang, we cannot simply enable this.

rdar://problem/44228891
2018-09-08 17:32:36 +09:00
Harlan
eb75ad80dc [AST] Remove stored TypeLoc from TypedPattern (#19175)
* [AST] Remove stored TypeLoc from TypedPattern

TypedPattern was only using this TypeLoc as a means to a TypeRepr, which
caused it to store the pattern type twice (through the superclass and through
the TypeLoc itself.)

This also fixes a bug where deserializing a TypedPattern doesn't store
the type correctly and generally cleans up TypedPattern initialization.

Resolves rdar://44144435

* Address review comments
2018-09-07 21:14:04 -07:00
Mark Lacey
1e7dae3741 Merge pull request #19145 from rudkx/parse-designated-protocol
Add support for parsing designated protocols in operator declarations.
2018-09-06 22:01:02 -07:00
Xi Ge
0c4ee41c48 Merge pull request #19184 from nkcsgexi/parse-enum
parser: on-demand parsing of the members in enum decls.
2018-09-06 19:35:52 -07:00
Xi Ge
4c7193b999 parser: on-demand parsing of the members in enum decls. 2018-09-06 17:59:09 -07:00
Dante Broggi
9d870e59e5 Fix typo, found by looking through commits. 2018-09-06 20:34:56 -04:00
Xi Ge
7379bc5782 Add counter for parsed decl lists. 2018-09-06 11:44:49 -07:00
Xi Ge
24b0eac9a4 Parser: parse members in extension decls incrementally. 2018-09-05 17:00:39 -07:00
Mark Lacey
039d10b709 Add support for parsing designated protocols in operator declarations.
The support is gated by a frontend option,
-enable-operator-designated-protocols.

This means that in an operator declaration we can declare a protocol
which has one or more requirements specifying this operator. The
operators from that designated protocol will be the first ones we try
when type checking an expression. If we successfully typecheck using
the operators specified in that protocol, we do not attempt any other
overloads of the same operator.

This makes it possible to dramatically speed up successful
typechecking.
2018-09-05 11:58:43 -07:00
Davide Italiano
1289b49615 [Parse] Store local typealiases, they matter for type reconstruction.
Fixes <rdar://problem/42446693>

(Thanks to Jordan for pointing out the solution)
2018-09-04 17:00:01 -07:00
Jordan Rose
78560c7aa8 Merge pull request #18895 from dingobye/sr8598
[Parser] Improve diagnostics for special platforms in available attribute.
2018-08-31 17:24:40 -07:00
Rintaro Ishizaki
2a1ab7d8e2 Merge pull request #19046 from rintaro/parse-refactor-getsetdecl
[Parse] refactor get/set block parsing
2018-09-01 00:32:57 +09:00
Rintaro Ishizaki
4797a7caf6 Merge pull request #18919 from rintaro/ide-complete-pound
[CodeCompletion] Implement completion for # directives
2018-08-31 10:50:40 +09:00
Ding Ye
3dca923371 Add a fix-it and rephrase some warning messages. 2018-08-31 08:40:19 +10:00
Ding Ye
b790eb5dcf [Parser] Improve diagnostics for special platforms in available attribute.
This patch adds warnings when a version number is used
on the non-specific '*' platform. In addition, it fixes
some misleading warning messages on 'swift' platform.

Resolves: SR-8598.
2018-08-31 08:40:19 +10:00
Rintaro Ishizaki
4df9fc111b [Parse] Remove delayed parsing for accessor decls
Now that, parsing accessor body is done by 'parseAbstractFunctionBody()'
which automatically handles delayed parsing by `delayFunctionBodyParsing()`.
So we no longer use delayed parsing facilities specific for accessor body.
2018-08-29 18:01:21 +09:00
Rintaro Ishizaki
51b7168d05 [Parse] Refactor get/set accessor parsing
* Use 'parseAbstractFunctionBody()' for accessors as well. This
  simplifies the implementation, and makes 'parseAbstractFunctionBody()'
  the single point of parsing body of every 'AbstructFunctionDecl' types.
2018-08-29 18:01:21 +09:00
Rintaro Ishizaki
327c69e563 [Parse] Don't update interface hash unless parsing interface tokens
Previously, parsing function bodies used to update interface hash
regardless of the flag. Parsing local function should not update it.
2018-08-29 01:00:02 +09:00
Rintaro Ishizaki
7c52deeb49 [Parse] Consolidate body parsing for Func/Constructor/Destructor decls 2018-08-29 01:00:02 +09:00
John McCall
b80618fc80 Replace materializeForSet with the modify coroutine.
Most of this patch is just removing special cases for materializeForSet
or other fairly mechanical replacements.  Unfortunately, the rest is
still a fairly big change, and not one that can be easily split apart
because of the quite reasonable reliance on metaprogramming throughout
the compiler.  And, of course, there are a bunch of test updates that
have to be sync'ed with the actual change to code-generation.

This is SR-7134.
2018-08-27 03:24:43 -04:00
Slava Pestov
c360c82850 AST: Automatically create the 'self' parameter when needed
Parsed declarations would create an untyped 'self' parameter;
synthesized, imported and deserialized declarations would get a
typed one.

In reality the type, if any, depends completely on the properties
of the function in question, so we can just lazily create the
'self' parameter when needed.

If the function already has a type, we give it a type right there;
otherwise, we check if a 'self' was already created when we
compute a function's type and set the type of 'self' then.
2018-08-25 10:44:55 -07:00
Rintaro Ishizaki
deb4aa84e0 [CodeCompletion] Add completion for platform condition
* 'true'/'false' keyword
* 'os(<name>)', 'canImport(<module>)' etc.
* Custom flags specified with '-D'

rdar://problem/19572779
2018-08-24 12:24:54 +09:00
Rintaro Ishizaki
5ef5f5ed84 [CodeCompletion] Implement completion for # directives
rdar://problem/29976235
2018-08-24 12:24:54 +09:00
Jordan Rose
5dfeb4c8cf [ModuleInterface] Don't setAddedImplicitInitializers() in Parse (#18933)
...wait until Sema. Parse shouldn't be messing with Sema-level
properties in the decls it builds.

No functionality change.
2018-08-23 16:02:33 -07:00
Jordan Rose
c62fcad553 Don't synthesize initializers in swiftinterface files
...and then don't complain about a class not having any initializers.
2018-08-16 17:59:24 -07:00
Jordan Rose
ed51d2255c [Parse] Simplify deinit recovery helper from previous commit
No functionality change.
2018-08-16 15:52:18 -07:00
Jordan Rose
ec0719d3e0 Handle parsing deinitializers without bodies for .swiftinterfaces
The presence of a deinitializer will eventually indicate whether a
class's deinitializer is non-trivial for non-resilient modules.

Also improve recovery for normal source files for various bad ways
of declaring a deinitializer.
2018-08-16 15:48:13 -07:00
Jordan Rose
318e988ae1 [Parse] Allow parsing accessors without bodies for .swiftinterfaces
We're going to do need to do more here for inlinable accessors, which
/do/ have bodies, but this helps us get to a bare minimum testing
configuration.
2018-08-16 13:57:45 -07:00
John McCall
5d8252b8c6 Pass around whether storage is mutable as an enum instead of a bool. 2018-08-16 02:13:54 -04:00
Slava Pestov
4b258e86e6 AST: Stop setting contextual types on ParamDecls
VarDecl::getType() lazily maps the interface type into context if needed.
2018-08-10 13:33:12 -07:00
Huon Wilson
507d3625bc [Parse] Factor out "find instance of token on current line" logic. NFC. 2018-08-09 16:37:32 +10:00
swift-ci
6198bc9375 Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 03:49:16 -07:00
Rintaro Ishizaki
5058ec9158 Merge pull request #17787 from rintaro/parse-miscdiag-drop3
[Parse] Drop Swift3 support for misc diagnostics
2018-07-25 19:36:24 +09:00
swift-ci
685b007c3f Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 20:39:45 -07:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
swift-ci
c0d6b81349 Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 00:49:34 -07:00
Slava Pestov
df9f7f979a Parse: Remove uses of getParameterLists() from default argument parsing 2018-07-22 20:56:56 -07:00
swift-ci
b4bae42909 Merge remote-tracking branch 'origin/master' into master-next 2018-07-21 13:49:33 -07:00
Slava Pestov
bfc4121971 AST: Rework AbstractFunctionDecl construction away from multiple parameter lists
There are two general constructor forms here:

- One took the number of parameter lists, to be filled in later.
  Now, this takes a boolean indicating if there is an implicit
  'self'.

- The other one took the actual parameter lists and filled them
  in right away. This now takes a separate 'self' ParamDecl and
  ParameterList.

Instead of storing the number of parameter lists, an
AbstractFunctionDecl now only needs to store if there is a 'self'
or not.

I've updated most places that construct AbstractFunctionDecls to
properly use these new forms. In the ClangImporter, there is
more code that remains to be untangled, so we continue to build
multiple ParameterLists and unpack them into a ParamDecl and
ParameterList at the last minute.
2018-07-21 07:30:30 -07:00
Bob Wilson
b2d8227a32 Merge remote-tracking branch 'origin/master' into master-next 2018-07-20 18:46:05 -07:00