Commit Graph

149 Commits

Author SHA1 Message Date
Rintaro Ishizaki
550865caf6 Revert "Merge pull request #27528 from rintaro/syntaxparse-rdar55952739"
This reverts commit 2ddba9cf21, reversing
changes made to 33770fa665.
2019-10-14 12:18:05 -07:00
Rintaro Ishizaki
6f4dc258f5 Revert "Merge pull request #27544 from rintaro/syntaxparse-attrincomplete"
This reverts commit 071a7134b3, reversing
changes made to dbddb0d89a.
2019-10-14 12:17:27 -07:00
Rintaro Ishizaki
d2971fa1a0 [SyntaxParse] Fix crasher for generic parameter with attributes
It used to crash for:
Attribute without its name (e.g. Foo<@>)
Missing name with attributes (e.g. Foo<@available(*, unavailable)>

- Synthesize identifier token so that the SyntaxParsingContext can
  successfully construct the Attribute syntax.
- Don't throw away the parsed attributes if the parameter name is
  missing. Instead, construct GenericParamater syntax anyway, and handle
  it in ASTGen.
2019-10-04 11:03:23 -07:00
Rintaro Ishizaki
edbf24c5b3 [SyntaxParse] Fix attribute generation in ASTGen
For the intermediate lookup table of the parsed decl attributes, use
location the first token of the attributes instead of the start location
of the *parsed* attribute list because some attributes can be ignored
during the parsing.

rdar://problem/55952739
2019-10-03 12:57:53 -07:00
Rintaro Ishizaki
5914325a02 [SyntaxParse] Parse typealias declaration 2019-10-02 14:24:33 -07:00
Rintaro Ishizaki
9eb4c216ee Revert "Revert "[SyntaxParse] Parse associatedtype decl""
This reverts commit 859f90afc1.
2019-09-27 23:52:39 -07:00
Rintaro Ishizaki
6a0bc459fc Merge pull request #27377 from rintaro/syntaxparse-rdar55711699
[SyntaxParse] Fix ASAN issue
2019-09-28 05:03:45 +02:00
Jordan Rose
8ff1dac381 [AST] Break some header dependencies for faster rebuilds (#27374)
DiagnosticEngine.h no longer depends on Attr.h.
Expr.h no longer depends on TypeRepr.h.

No functionality change.
2019-09-26 09:17:10 -07:00
Rintaro Ishizaki
d9eba19b74 [SyntaxParse] Fix ASAN issue
rdar://problem/55711699
rdar://problem/55711787
rdar://problem/55711952
2019-09-25 21:27:44 -07:00
Rintaro Ishizaki
859f90afc1 Revert "[SyntaxParse] Parse associatedtype decl" 2019-09-25 11:00:21 -07:00
Rintaro Ishizaki
fc8a2e6f86 [SyntaxParse] Parse associatedtype decl
Along with inheritance clause.
2019-09-24 12:03:06 -07:00
Rintaro Ishizaki
0569cbfb28 Revert "Revert "[SyntaxParse] Parse generic parameter clause and generic where clause""
This reverts commit 1584e87aa7.
2019-09-20 15:26:04 -07:00
Rintaro Ishizaki
1584e87aa7 Revert "[SyntaxParse] Parse generic parameter clause and generic where clause" 2019-09-20 14:02:53 -07:00
Rintaro Ishizaki
f919b2ddd8 [SyntaxParse] Parse generic parameter clause and generic where clause 2019-09-19 23:09:58 -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
Rintaro Ishizaki
9ba232d718 [CodeCompletion] Implement completion at custom attribute argument 2019-05-31 11:09:54 -07:00
Doug Gregor
32b0245187 [Parser] Consistently use consumeIdentifier() for normal identifiers.
consumeIdentifier() provides the general way in which we consume an
identifier token and fill in an Identifier. Use it consistently in the
parser.
2019-04-23 11:31:58 -07:00
Christopher Ian Stern
469a0f3eb0 fix stack overflow on deeply nested parens [SR-4866] (#19631)
Make sure StructureMarkerRAII checks structure nesting level on all paths.  Previously swift crashed with  no diagnostic on deeply nested '('. Now we print an error when more than 256 parens deep, just as we always have for '['.

fixes SR-4866
2018-10-10 13:42:18 +09:00
Slava Pestov
d488509cca Parse: Remove Swift 3 support 2018-10-08 17:21:32 -07:00
fischertony
e78a42b06f [SR-8239][Parse] Fix same-type constraint commutativity 2018-09-11 05:18:44 +03:00
Rintaro Ishizaki
2134f9f768 [Parse] Move SyntaxParsingContext to Parse (#14360)
This is only for the Parser.
Also, this resolves layering violation where libAST and libSyntax
depends on each other.
2018-02-03 10:43:52 +09:00
Rintaro Ishizaki
48eb60702e [Syntax] Stop using SyntaxBuilders for TypeIdentifier
Since we haven't handled error cases yet, Error type identifier (e.g.
'Array.+') used to case round trip problem.
2017-12-27 13:18:17 +09:00
Xi Ge
fec040d95e libSyntax: support generic parameter clause. (#13286)
This patch also performs minor refactoring to align syntax parsing
context with the right scope. We start to support the generic clauses
because they are necessary pieces to construct struct or
function syntax node.
2017-12-05 19:34:55 -08:00
Xi Ge
ad70fb07f9 libSyntax: parse generic where clause.
Because generic where clause doesn't coerce well to our existing syntax
context kinds, we add a new syntax context kind with this patch called
"Syntax". This context kind indicates that when error occurs, the
collection of syntax nodes falling into the context should be coerced
to UnknownSyntax.
2017-12-04 15:00:40 -08:00
Rintaro Ishizaki
640a11d11e [libSyntax] Return type-identifier as SyntaxParserResult 2017-11-29 09:58:05 +09:00
Nathan Hawes
7403e779ad [ASTWalker|Refactoring] Walk generic params and requirements in source order for subscript decls
Also handle requirements in non-trailing where clauses (for -swift-version 3)
Resolves rdar://problem/34859742
2017-11-16 16:02:12 -08:00
Slava Pestov
2c7246ec1a Parse: Fix a comment 2017-09-05 21:53:52 -07:00
Slava Pestov
9126d316d8 Parse: Remove parseTypeForInheritance()
We can just use parseType() everywhere instead. We already check
for non-identifier types in inheritance clauses elsewhere, and indeed
we have to anyway because an identifier type might resolve to a
type alias whose underlying type is a non-nominal type.

It doesn't look like this change made any diagnostics worse, but if
we find a case where it did, we could revert it.
2017-09-05 21:53:52 -07:00
Slava Pestov
19fed22872 Parse: Remove redundant diagnostic
We had two slightly different codepaths to diagnose ': class'
in an inheritance clause where it is not supported.

For generic parameters, we would fix the 'class' to 'AnyObject',
but for associated types we didn't do this. Perform the fix in
all cases where it makes sense and remove one of the two
diagnostics.
2017-09-05 21:53:52 -07:00
Ben Langmuir
534c0cc2cb [code-completion] Generic where clauses
Complete generic parameters and their members inside generic where
clauses on structs, classes, enums, extensions, typealiases, funcs,
subscripts and inits.

Still not handled correctly are associatedtypes.

rdar://problem/20582394
2017-07-31 09:57:00 -07:00
Ewa Matejska
fa6e207f62 Updating to have stronger working for warning and review feedback 2017-05-15 18:43:10 -07:00
Ewa Matejska
4553d5ea67 Making the where_inside_brackets warning into an Error for > Swift 3. 2017-05-15 15:12:14 -07:00
Huon Wilson
8c8f35ee78 [Parse] Don't tell CodeCompletion nonsense about protocol/AT where clauses.
This doesn't give particularly useful information yet (i.e. Self isn't
listed, see rdar://problem/31981641 ), but it does stop the completion
code from just directly crashing.

Fixes rdar://problem/31981486.
2017-05-12 16:00:00 +10:00
Doug Gregor
ab7cd7fbe4 Enable associated type where clauses in all language modes
We're ready to start experimenting with and rolling out this feature
in earnest.
2017-04-04 10:58:01 -07:00
Huon Wilson
54f247693c [AST]/[Parse] parse where clauses on protocol declarations. 2017-03-09 16:08:16 -08:00
Slava Pestov
928a74c47e Parse: Support for generic subscripts 2017-02-23 21:14:02 -08:00
Roman Levenstein
e5d5d7d5fd Some LayoutConstraint improvements.
This biggest change is:
- LayoutConstraintInfo is now a FoldingSetNode, which allows for proper canonicalization of LayoutConstraints. This is important for the correctness of type comparisons if types contain layout constraints.

No functionality changes from the client's point of view.
2017-02-07 17:03:11 -08:00
Doug Gregor
392324c252 Set a bogus depth (0xFFFF) on parsed generic type parameters.
Test for the bogus depth when canonicalizing a reference to the
generic parameters, so we don't canonicalize before the depth has been
set. This flushed out various issues where we weren't validating the
context eagerly enough.
2017-02-07 15:22:50 -08:00
Slava Pestov
4f4e6f6ebf Sema: Remove another workaround and fuzz harder
We used to drop the entire generic parameter list if one of the
entries failed to parse. This caused a problem where the generic
parameters were still available for name lookup, so they had
to be special-cased since there's no generic environment set up
in this case.

Now, keep the parts of the generic parameter list around that
parsed successfully.

When I first made the change, almost a hundred crashers regressed;
now all the underlying issues have been fixed.

The result is that in addition to removing a crappy hack we get
some more mileage out of the compiler_crashers, because stuff like
this now builds a generic environment:

class S<T{...}
2017-02-03 17:02:04 -08:00
Slava Pestov
64352a7532 Parser: Don't return valid location from parseGenericWhereClause() if there were no requirements 2017-02-03 17:02:03 -08:00
Roman Levenstein
ed6c0aa34b Parsing of @_specialize
The new `@_specialize` attribute has a syntax like this:

```swift
@_specialize(exported: true, kind: full, where K == Int, V == Int)
@_specialize(exported: false, kind: partial, where K: _Trivial64)
func dictFunction<K, V>(dict: Dictionary<K, V>) {
}
```

If `exported` is set, the corresponding specialization would have a public visibility and can be used by clients.
If `exported` is omitted, it's value is assumed to be `false`.

If `kind` is `full` it means a full specialization.
If `kind` is `partial` it means a partial specialization.
If `kind` is omitted, its value is assumed to be `full`.
2017-01-18 16:42:10 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
David Farler
f450f0ccdf Revert "Preserve whitespace and comments during lexing as Trivia"
This reverts commit d6e2b58382.
2016-11-18 13:23:31 -08:00
David Farler
44f15558d6 Revert "Refactor: Rename Parser::consumeToken, consumeLoc. Add consumeToken API."
This reverts commit 39bfc123a3.
2016-11-18 13:23:31 -08:00
David Farler
39bfc123a3 Refactor: Rename Parser::consumeToken, consumeLoc. Add consumeToken API.
These APIs return SourceLocs, and eventually the Parser should consume
tokens, which now include source trivia such as whitespace and comments,
and package them into a purely syntactic tree.  Just a tiny step. NFC.
2016-11-15 16:11:57 -08:00
David Farler
d6e2b58382 Preserve whitespace and comments during lexing as Trivia
Store leading a trailing "trivia" around a token, such as whitespace,
comments, doc comments, and escaping backticks. These are syntactically
important for preserving formatting when printing ASTs but don't
semantically affect the program.

Tokens take all trailing trivia up to, but not including, the next
newline. This is important to maintain checks that statements without
semicolon separators start on a new line, among other things.

Trivia are now data attached to the ends of tokens, not tokens
themselves.

Create a new Syntax sublibrary for upcoming immutable, persistent,
thread-safe ASTs, which will contain only the syntactic information
about source structure, as well as for generating new source code, and
structural editing. Proactively move swift::Token into there.

Since this patch is getting a bit large, a token fuzzer which checks
for round-trip equivlence with the workflow:

fuzzer => token stream => file1
  => Lexer => token stream => file 2 => diff(file1, file2)

Will arrive in a subsequent commit.

This patch does not change the grammar.
2016-11-15 16:11:57 -08:00
swift-ci
5877db3b6b Merge pull request #5099 from rintaro/rangle-location 2016-10-24 00:16:42 -07:00
Rintaro Ishizaki
2c539c71f0 [Parse] Emit specialized diagnostics if seeing non-IdentTypeRepr in inheritance clause
Current Swift grammer accept only IdentTypeRepr (and protocol
composition in generics) in inheritance clause.
2016-10-19 02:22:23 +09:00