Commit Graph

2438 Commits

Author SHA1 Message Date
Ted Kremenek
8f5b8ccb02 Rename "This" to "Self" and "this" to "self".
This was not likely an error-free change.  Where you see problems
please correct them.  This went through a fairly tedious audit
before committing, but comments might have been changed incorrectly,
not changed at all, etc.

Swift SVN r7631
2013-08-27 21:58:27 +00:00
Dmitri Hrybenko
db44574605 parseBraceItemList(): use ParserResult
Now we propagate error bits better, which decreases noise in diagnostics in one
case.


Swift SVN r7628
2013-08-27 19:01:15 +00:00
Dmitri Hrybenko
b1d08912c2 Code completion: complete types in extension declarations
Swift SVN r7552
2013-08-24 01:58:13 +00:00
Dmitri Hrybenko
45c4cc334f Brush up comments in Parser: no need to describe the return value of functions
that return ParserResult; use Doxygen syntax.


Swift SVN r7550
2013-08-24 01:25:19 +00:00
Dmitri Hrybenko
c7c67e0130 Code completion: complete types in the union inheritance clause
Swift SVN r7549
2013-08-24 01:04:53 +00:00
Dmitri Hrybenko
610d2b75cb Code completion: complete types in the protocol inheritance clause
Swift SVN r7545
2013-08-23 23:40:09 +00:00
Dmitri Hrybenko
b7bdb2b134 Remove redundant return
Swift SVN r7544
2013-08-23 23:37:49 +00:00
Dmitri Hrybenko
117d1516ea Parser: propagate code completion bits to the result
No testcase because we can not do code completion in nested types now.


Swift SVN r7542
2013-08-23 23:30:39 +00:00
Dmitri Hrybenko
7a02b7afd5 Code completion: complete types in the class inheritance clause
Swift SVN r7538
2013-08-23 22:52:46 +00:00
Dmitri Hrybenko
0cf6ba54fb Code completion: complete types in the struct inheritance clause
Swift SVN r7534
2013-08-23 22:13:35 +00:00
Dmitri Hrybenko
4bc13e6cd2 Code completion: complete types in the typealias inheritance clause
Swift SVN r7524
2013-08-23 21:10:53 +00:00
Dmitri Hrybenko
4980cb8217 parseTypeTupleBody(): propagate CodeCompletion bits from parsing individual
elements to the tuple ParserResult

Allows us to complete types in tuples (located in other places than the
function parameter lists).


Swift SVN r7484
2013-08-22 22:44:44 +00:00
Chris Lattner
69d0afb658 rename [force_inlining] to [transparent].
Swift SVN r7448
2013-08-22 16:05:41 +00:00
Dmitri Hrybenko
a56893dec2 parseDecl(): use ParserResult
Now we make the desicion to delay parsing if the parsed production contained a
code completion token, not if we just stopped at the code completion token.


Swift SVN r7442
2013-08-22 00:39:45 +00:00
Dmitri Hrybenko
ec7b2eb3db Parser: use ParserResult in the interface of parseExpr()
But the implementation of expression parsing still does not propagate the code
completion bits because it uses NullablePtr for results.


Swift SVN r7425
2013-08-21 21:10:09 +00:00
Dmitri Hrybenko
f7ad1c9b03 parseDeclVar(): use ParserStatus
Swift SVN r7421
2013-08-21 20:15:01 +00:00
Dmitri Hrybenko
ad2ca67858 parseDeclSubscript(): use ParserStatus
Swift SVN r7415
2013-08-21 19:15:55 +00:00
Dmitri Hrybenko
255aeae1f9 parseDeclUnionElement(): use ParserResult because this function returns at most
one Decl, no need to pass in a vector


Swift SVN r7414
2013-08-21 19:04:12 +00:00
Dmitri Hrybenko
76d11315b0 parseDeclImport(): use ParserResult because this function returns at most one
Decl, no need to pass in a vector


Swift SVN r7413
2013-08-21 18:49:24 +00:00
Dmitri Hrybenko
ecf4cc44b1 parseDeclClass(): use ParserResult because this function returns at most one
Decl, no need to pass in a vector


Swift SVN r7410
2013-08-21 18:26:23 +00:00
Dmitri Hrybenko
e392e1a551 parseStruct(): use ParserResult because this function returns at most one Decl,
no need to pass in a vector


Swift SVN r7407
2013-08-21 18:10:16 +00:00
Dmitri Hrybenko
53685fe05f parseUnion(): use ParserResult because; it returns at most one Decl, no need to
pass in a vector

This a bit of noise to the diagnostics (see test change); this issue will be
fixed uniformly for all nominal decls in future commits.


Swift SVN r7399
2013-08-21 02:23:38 +00:00
Dmitri Hrybenko
354c5f4a18 Parser: replace diagnose(Tok.getLoc(), ...) -> diagnose(Tok, ...)
We already had the Parser::diagnose(Token, ...) overload, but it was not used
in all these cases.


Swift SVN r7395
2013-08-21 00:26:30 +00:00
Dmitri Hrybenko
581db767bf Use ParserResult and ParserStatus in tuple and function argument parsing
This finally fixes a few code completion test cases.

This also regresses the error message in one parsing testcase because
previously we would just happily skip those tokens, but now error handling path
is a little bit different and these tokens hit different error handling code.
This can be fixed by parsing a tuple for the selector argument and complaining
if the tuple had more than one element.


Swift SVN r7389
2013-08-20 23:55:00 +00:00
Dmitri Hrybenko
73353d9e48 Remove an unused variable
Swift SVN r7386
2013-08-20 23:20:49 +00:00
John McCall
329a5e47db Permit attribute lists to be split into multiple clauses.
This is particularly convenient for dealing with generated
code (e.g. as produced by the SIL printer), but it's also
quite defensible as a way for users to logically group
related attributes and split unrelated ones out, should
users find themselves using a lot of verbose attributes
(and prior experience with e.g. user-defined attributes
is that they definitely do sometimes turn into walls of
text...).

Swift SVN r7376
2013-08-20 22:37:38 +00:00
Dmitri Hrybenko
c3954987d6 Parser: use ParserResult in parseTypeSimple() and everything that uses it/
is used in it


Swift SVN r7355
2013-08-20 02:12:31 +00:00
Dmitri Hrybenko
b0dd877454 Use ParserResult in type parsing
Swift SVN r7353
2013-08-20 01:19:31 +00:00
Doug Gregor
1ddb34fb71 Factor generic parameters and associated types into their own decl nodes.
Previously, TypeAliasDecl was used for typealiases, generic
parameters, and assocaited types, which is hideous and the source of
much confusion. Factor the latter two out into their own decl nodes,
with a common abstract base for "type parameters", and push these
nodes throughout the frontend.

No real functionality change, but this is a step toward uniquing
polymorphic types, among other things.


Swift SVN r7345
2013-08-19 23:36:58 +00:00
Dmitri Hrybenko
deff836592 Parser: use ParserResult in parseDeclFunc
Swift SVN r7341
2013-08-19 23:02:06 +00:00
Dmitri Hrybenko
c098cd1476 Parser: convert some pattern parsing functions to ParserResult
Swift SVN r7336
2013-08-19 22:38:34 +00:00
Dmitri Hrybenko
19a90b69f7 Parser: add ParserResult<T> -- a wrapper around the AST node plus extra bits
This allows the parser to recover, create an AST node, return it to the caller
*and* signal the caller that there was an error to trigger recovery in the
caller.  Until now the error was signalled with a nullptr result (any non-null
result was considered a success and no recovery was done in that case).

This also allows us to signal the caller if there was a code completion token
inside the production we tried to parse to trigger delayed parsing in the
caller while doing recovery in the callee.  Until now we could not do recovery
in the callee so that the caller could find the code completion token.

Right now we don't take any advantage of these features.  This commit just
replaces some uses of NullablePtr with ParserResult.


Swift SVN r7332
2013-08-19 22:11:23 +00:00
Dmitri Hrybenko
cdb1df51a3 Code completion: completion of type-ident in type contexts (like Foo.#^A^#)
This introduces the required code completion callbacks which pass partially
parsed TypeReprs to code completion.  These types can refer to generic function
parameters.  Because we need to typecheck these types, we need to typecheck
generic parameters first.  Because exposing fine-grained typechecker interface
just for code completion is bad, we create a function declaration based on the
limited information we have (i.e., just the function name and generic
parameters) and pass that to the typechecker.  This approach (in theory) should
work uniformly for function decls and nominal type decls, but the nominal type
decl case is not tested yet.  Eventually we will also want to use a similar
approach for normal parser recovery as well.


Swift SVN r7313
2013-08-17 02:35:32 +00:00
Dmitri Hrybenko
5b952b080a Rename OOD and OOED variables that used to stand for OneOfDecl and
OneOfElementDecl


Swift SVN r7283
2013-08-16 18:11:28 +00:00
Dmitri Hrybenko
4dbac4ee42 Parser: improve recovery and diagnostics for "extension <type> {}" where <type>
is not a type-identifier

Just parse type-simple instead and let the type checker diagnose the invalid
cases.  The only exception is when a tuple becomes a ParenType: it is
canonically equivalent to the wrapped type, and thus the parser uses the
TypeRepr to diagnose that case.


Swift SVN r7275
2013-08-16 01:52:59 +00:00
Dmitri Hrybenko
23d48b6b3b Use NullablePtr in more decl parser functions
Swift SVN r7274
2013-08-16 00:46:26 +00:00
Dmitri Hrybenko
f49852e875 Parser: don't drop the extension from the AST if any declarations inside had
a parse error


Swift SVN r7273
2013-08-16 00:16:53 +00:00
Dmitri Hrybenko
0fdb8acf09 Parser: don't drop the whole nominal decl from the AST if any member had a
syntax error

Will be tested by code completion.


Swift SVN r7272
2013-08-15 22:33:23 +00:00
Dmitri Hrybenko
2786c30dd8 Code completion: add a parser hook to inform code completion about generic
parameters while parsing the function signature.  Generic parameters are not
accessible at that time through the AST node, because the FuncDecl AST node was
not constructed yet.


Swift SVN r7222
2013-08-14 02:16:55 +00:00
Dmitri Hrybenko
536723eca4 Code completion: implement delayed parsing of all (?) declarations
This allows us to show generic parameters in:
struct S<T> {
  func f(a: #^A^#
}

And show the type Z in:
struct S {
  func f(a: #^A^#
  typealias Z = Int
}


Swift SVN r7216
2013-08-13 23:53:39 +00:00
Dmitri Hrybenko
70f2b64ad9 Add CharSourceRange -- a half-open character range, which will be used in IDE
integration

Motivation: libIDE clients should be simple, and they should not have to
translate token-based SourceRanges to character locations.

This also allows us to remove the dependency of DiagnosticConsumer on the
Lexer.  Now the DiagnosticEngine translates the diagnostics to CharSourceRanges
and passes character-based ranges to the DiagnosticConsumer.


Swift SVN r7173
2013-08-12 20:15:51 +00:00
Dmitri Hrybenko
ca5351e4b6 Fix bad recovery in Parser::parseList() and Parser::parseDeclUnionElement()
Now parseList() always sets RBLoc, which fixes the crash.
parseDeclUnionElement() now skips to the next decl, instead of ":", which may
not appear in the file at all.


Swift SVN r7117
2013-08-10 00:44:09 +00:00
Dmitri Hrybenko
dc655eb1cb Remove more abuse of SourceLoc::Value::getPointer()
Swift SVN r7109
2013-08-09 22:35:33 +00:00
Chris Lattner
03c9ade9b4 Fix rdar://14690497, diagnosing precedence declarations that are
outside the allowed range.




Swift SVN r7106
2013-08-09 21:58:43 +00:00
Dmitri Hrybenko
48faba29f3 Simplify parser constructors
Constructor delegation in parser was useless, because the code was split
between the constructors arbitrarily.

There was no need to pass down IsMainModule because the parser could figure
that out on its own.  Also rename it to allowTopLevelCode() to better describe
what it actually affects.


Swift SVN r7098
2013-08-09 20:43:21 +00:00
Dmitri Hrybenko
de59d8dcd4 Remove unneeded llvm:: qualifier for llvm::StringRef and llvm::SmallVector
Swift SVN r7089
2013-08-09 18:41:46 +00:00
Dmitri Hrybenko
49e15b33e7 Remove the public Lexer::getBufferEnd() function which breaks encapsulation
of the source buffer


Swift SVN r7084
2013-08-09 18:10:29 +00:00
Dmitri Hrybenko
02cf73dc30 Lexer: remove redundant parameters from the sublexer constructor
Swift SVN r7073
2013-08-09 00:15:01 +00:00
Dmitri Hrybenko
41723aeb30 Code completion: correctly delay parsing of the function body that did not have
a closing brace.

Fixes two bugs:
* delayed parsing was not correctly skipping over the function body because it
  stopped at the 'var' decl;
* parser was not creating a BraceStmt for the function body if it could not
  find the closing brace.


Swift SVN r7062
2013-08-08 22:57:25 +00:00
Jordan Rose
093a428ca9 Add parsing support for the [exported] attribute.
As discussed, this is an interim syntax for re-exports:
  import [exported] Foundation
In the long run, we're probably going to use the same syntax as access
control for this, but that hasn't been designed yet.

Swift SVN r7050
2013-08-08 19:09:10 +00:00