Commit Graph

4242 Commits

Author SHA1 Message Date
Jordan Rose
73d5ebaad2 Rename "textual interface" to "parseable interface" (#19713)
We already have something called "module interfaces" -- it's the
generated interface view that you can see in Xcode, the interface
that's meant for developers using a library. Of course, that's also a
textual format. To reduce confusion, rename the new module stability
feature to "parseable [module] interfaces".
2018-10-04 17:49:55 -07:00
MIZUNO Hiroki
f2bdce8251 [SR-8340]Improve fix-it for var and subscript in Protocol (#19660)
* [Parser] Improve fix-it for subscription in protocol
* [Sema] Add fix-it for property in protocol

https://bugs.swift.org/browse/SR-8340
2018-10-05 07:50:03 +09:00
Rintaro Ishizaki
3d80635cf4 [CodeCompletion] Fix completion for local decls in trailing closure
Previously, local decls in trailing closure didn't show up if the
closure had preceding arguments and the completion was triggered at
beginning position of expression context. like:

   funcName(x: arg1) {
      var localVar = 12
      if <HERE>
   }

The completion mode used to be overwritten in 'completeCallArg()' which
is called from 'parseExprCallSuffix(). We should detect completion for
immediate argument position in 'parseExprList()'.

rdar://problem/41869885
2018-10-04 16:56:07 +09:00
fischertony
46dc36536c [Gardening] Typo and indentation fixes 2018-10-03 22:12:51 +03:00
fischertony
e505d417fa [Parse][CodeCompletion] Completions for precedencegroup decls
Added the 'Module::getPrecedenceGroups' API to separate precedence group lookup
from 'Module::lookupVisibleDecls', which together with 'FileUnit::lookupVisibleDecls',
to which the former is forwarded, are expected to look up only 'ValueDecl'. In particular, this
prevents completions like Module.PrecedenceGroup.
2018-10-03 22:12:20 +03:00
Jordan Rose
ceaa5db623 Merge pull request #17960 from danielmartin/new-unary-operator-ifconfig
[Parser] Support "<" unary operator in #if swift() and #if compiler() expressions
2018-09-26 15:00:48 -07:00
Rintaro Ishizaki
a0ebdbc089 [Lexer] Fix assertion failure for unterminated string literal
in string interpolation in multiline string literal.

    """
    \("<-this is unterminated.
    """

In this case, the outer multiline literal should form 'tok::unknown'
along with a error message.
2018-09-22 02:09:19 +09:00
Rintaro Ishizaki
a5759b73b5 [Lexer] Improve fix-it to remove "too long" delimiter in string literal
Fix-it to remove extra '#'s at once.
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
aaa4110a7c [Lexer] Factor out diagnostics for single-quoted string literal
For readability.
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
7b701d57d3 [Lexer] Improve diagnostics for single-quote string literal
Ignore the contents of interpolation.
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
e6e55c23e1 [Lexer] Code tweaks in lexStringLiteral()
NFC. Reorder code to improve readability.
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
1a4d37597f [Lexer] Remove unnecessary logic from lexCharacter
EOF and newline (in non-multiline string literal) must be handled by
call site. lexCharacter doesn't need to handle them. Added assertion
instead.
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
ba5172738c [Lexer] Advance pointer to the end of end-quote in lexCharacter
This simplifies main lexStringLiteral loop
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
893524ea77 [Lexer] Add assertion in advanceIfCustomDelimiter()
CurPtr[-1] must be '#' when called.
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
4536e69dd6 [Lexer] Don't emit diagnostics in skipToEndOfInterpolatedExpression()
Removed Diags parameter from it.
Skipped bytes are revisited by main lexer function anyway. So emitting
diagnostics in it causes duplicated errors.
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
c9c69633c4 [Lexer] Simplify handling quotes in skipToEndOfInterpolatedExpression()
NFC
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
0e9b232755 [Lexer] Fix double diagnostics for unterminated string literal
We should not emit diagnostics in skipToEndOfInterpolatedExpression()
2018-09-19 18:58:54 +09:00
Rintaro Ishizaki
143f55a6e5 [Lexer] Add formStringLiteralToken dedicated for forming string literal 2018-09-19 18:58:54 +09:00
John Holdsworth
eb450ee494 Fix minor bug in #sourceLocation on lex error (#19344)
Fix a minor bug in the implementation of #sourceLocation when the
directive is succeeded by token that gives an error during lexing.
The error will be reported with the wrong location. This is because
lexing of the next token occurs immediately on consuming the last
token of the directive which is before the virtual file is set up to have
the location take effect.

Resolved by moving consumption of directives last token to the end
of the function.
2018-09-19 11:03:08 +09:00
John Holdsworth
7ae5a7af6a Point link to Zero-width Jira (#19364) 2018-09-18 23:36:32 +09:00
Harlan
665db876ea [InterfaceGen] Print bodies of inlinable functions in textual interfaces (#19224)
* Introduce stored inlinable function bodies

* Remove serialization changes

* [InterfaceGen] Print inlinable function bodies

* Clean up a little bit and add test

* Undo changes to InlinableText

* Add serialization and deserialization for inlinable body text

* Allow parser to parse accessor bodies in interfaces

* Fix some tests

* Fix remaining tests

* Add tests for usableFromInline decls

* Add comments

* Clean up function body printing throughout

* Add tests for subscripts

* Remove comment about subscript inlinable text

* Address some comments

* Handle lack of @objc on Linux
2018-09-14 10:23:15 -07:00
John Holdsworth
e55d4254d2 [Parse] Allow multiline attribute messages (SE-200) (#19219)
Multiline string literal at attribute message position was disallowed in
59778f8ecb.

Reworked to try to at least get multiline strings working which might be
useful as messages for attributes (for example a detailed “unavailable”
annotation) minus the code which read off the start of the StringRef buffer.
2018-09-14 10:33:32 +09:00
Xi Ge
c94bc1d7db Merge pull request #19260 from nkcsgexi/parse-other-type
Parser: allow on-demand member decl parsing for other nominal types.
2018-09-12 22:28:18 -07:00
Xi Ge
a7a06d7ce3 FrontendTool: parse all delayed member decls when we're dumping parse tree or verifying parse diagnostics. 2018-09-12 19:40:28 -07:00
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
Jordan Rose
e180bf9d4e [Parse] Tweak a utility function that relies on reading past the end (#19230)
Lexer::getEncodedStringSegment (now getEncodedStringSegmentImpl)
assumes that it can read one byte past the end of a string segment in
order to avoid bounds-checks on things like "is this a \r\n
sequence?". However, the function was being used for strings that did
not come from source where this assumption was not always valid.
Change the reusable form of the function to always copy into a
temporary buffer, allowing the fast path to continue to be used for
normal parsing.

Caught by ASan!

rdar://problem/44306756
2018-09-11 20:11:58 -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
Slava Pestov
3d7b7bd907 Merge pull request #19233 from AnthonyLatsis/same-type-constr-commutativity
[SR-8239][Parse] Fix same-type constraint commutativity
2018-09-11 11:36:17 -07:00
fischertony
e78a42b06f [SR-8239][Parse] Fix same-type constraint commutativity 2018-09-11 05:18:44 +03: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
b4356d4f93 Merge pull request #19104 from nkcsgexi/parser-laziness
Parser: lazily parse members in extension decls.
2018-09-06 15:24:17 -07:00
John Holdsworth
4da8cbe655 Implement SE-0200 (extended escaping in string literals)
Supports string literals like #"foo"\n"bar"#.
2018-09-06 15:19:52 -07:00
Brent Royal-Gordon
df22ea1bfb Revert "[Parse] Implementation for SE-200 (raw strings)" 2018-09-06 12:22:41 -07:00
swift-ci
192587c98a Merge pull request #17668 from johnno1962a/master 2018-09-06 11:47:36 -07:00
Xi Ge
7379bc5782 Add counter for parsed decl lists. 2018-09-06 11:44:49 -07:00
Harlan
ad7e1d0e67 [InterfaceGen] Print private/internal properties (#19127)
* [Interface] Print private/internal properties

All properties which contribute to the storage of a type should be
printed, and their names should be hidden from interfaces. Print them
with '_' as their name, and teach the parser to recognize these special
patterns when parsing interface files.

Partially resolves rdar://43810647

* Address review comments

* Disable accessor generation for nameless vars

* Test to ensure interface files preserve type layout

* Ignore attribute differences on Linux
2018-09-06 09:58:33 -07:00
John Holdsworth
9208c5bca6 Final nits in comments. 2018-09-06 14:20:19 +01:00