summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/Parser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor how we collect attributes during parsing, and add slots for attributesJohn McCall2010-12-241-32/+24
| | | | | | | on array and function declarators. This is pretty far from complete, and I'll revisit it later if someone doesn't beat me to it. llvm-svn: 122535
* Added ParenType type node.Abramo Bagnara2010-12-101-9/+5
| | | | llvm-svn: 121488
* Not content to implement just "extern" explicit templateDouglas Gregor2010-12-011-4/+30
| | | | | | | | | instantiations, GCC also supports "inline" and "static" explicit template instantiations. Parse and warn about such constructs, but don't implement the semantics of either "inline" or "static". They don't seem to be widely used. llvm-svn: 120599
* Refactoring.Argyrios Kyrtzidis2010-11-191-2/+1
| | | | | | Move ErrorTrap from clang/Sema to clang/Basic as DiagnosticErrorTrap and use it in Scope. llvm-svn: 119763
* Refactoring of Diagnostic class.Argyrios Kyrtzidis2010-11-181-1/+1
| | | | | | | | | | | -Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class. -DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units. -The rest of the state in Diagnostic object is considered related and tied to one translation unit. -Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a SourceLocation instead of a FullSourceLoc. -Reflect the changes to various interfaces. llvm-svn: 119730
* Add parsing support for Microsoft attributes. MS attributes will just be ↵Francois Pichet2010-10-111-0/+3
| | | | | | skipped and not inserted into the AST for now. llvm-svn: 116203
* When we encounter a '==' in a context expecting a '=', assume the user made ↵Argyrios Kyrtzidis2010-10-081-0/+14
| | | | | | | | | | | | | a typo: t.c:1:7: error: invalid '==' at end of declaration; did you mean '='? int x == 0; ^~ = Implements rdar://8488464. llvm-svn: 116035
* vla expressions used in __typeof__ must be evaluated.Fariborz Jahanian2010-09-281-2/+4
| | | | | | Fixes rdar://8476159. llvm-svn: 114982
* Implement bracket insertion for Objective-C instance message sends asDouglas Gregor2010-09-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | part of parser recovery. For example, given: a method1:arg]; we detect after parsing the expression "a" that we have the start of a message send expression. We pretend we've seen a '[' prior to the a, then parse the remainder as a message send. We'll then give a diagnostic+fix-it such as: fixit-objc-message.m:17:3: error: missing '[' at start of message send expression a method1:arg]; ^ [ The algorithm here is very simple, and always assumes that the open bracket goes at the beginning of the message send. It also only works for non-super instance message sends at this time. llvm-svn: 113968
* Improve error recovery when we see ':' and expect a ';'.John McCall2010-09-071-0/+20
| | | | | | I, at least, make this typo all the time. llvm-svn: 113243
* Improve recovery when there is a stray ']' or ')' before the ';' atDouglas Gregor2010-09-071-0/+19
| | | | | | the end of a statement. Fixes <rdar://problem/6896493>. llvm-svn: 113202
* Enable inline namespaces in C++03 as an extension.Sebastian Redl2010-08-311-2/+2
| | | | llvm-svn: 112566
* Parser support for inline namespacesSebastian Redl2010-08-271-3/+11
| | | | llvm-svn: 112320
* One who seeks knowledge learns something new every day.John McCall2010-08-261-7/+7
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* Initialize the translation-unit scope before lexing the firstDouglas Gregor2010-08-251-4/+4
| | | | | | | token. The first token might be something that ends up triggering code completion, which in turn requires a valid Scope. Test case forthcoming. llvm-svn: 112066
* Introduce a preprocessor code-completion hook for contexts where weDouglas Gregor2010-08-251-0/+4
| | | | | | | expect "natural" language and should not provide any completions, e.g., comments, string literals, #error. llvm-svn: 112054
* Implement code completion for preprocessor expressions and in macroDouglas Gregor2010-08-241-2/+13
| | | | | | arguments. llvm-svn: 111976
* Implement preprocessor code completion where a macro name is expected,Douglas Gregor2010-08-241-0/+4
| | | | | | | e.g., after #ifdef/#ifndef or #undef, or inside a defined <macroname> expression in a preprocessor conditional. llvm-svn: 111954
* Introduce basic code-completion support for preprocessor directives,Douglas Gregor2010-08-241-0/+13
| | | | | | e.g., after a "#" we'll suggest #if, #ifdef, etc. llvm-svn: 111943
* Parse all kinds of declarations as part of a linkage-specification,Douglas Gregor2010-08-241-2/+6
| | | | | | from Francois Pichet! Fixes PR7754. llvm-svn: 111912
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-5/+5
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Abstract out passing around types and kill off ActionBase.John McCall2010-08-241-9/+11
| | | | llvm-svn: 111901
* Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall2010-08-231-2/+2
| | | | llvm-svn: 111863
* DeclPtrTy -> Decl *John McCall2010-08-211-9/+9
| | | | llvm-svn: 111733
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-3/+3
| | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
* Once code completion has completed, pass a "completion context" on toDouglas Gregor2010-08-111-5/+5
| | | | | | | the code-completion consumer. The consumer can use this information to augument, filter, or display the code-completion results. llvm-svn: 110858
* Template keyword should not be ignored building a QualifiedTemplateName.Abramo Bagnara2010-08-061-3/+4
| | | | llvm-svn: 110441
* Implement #pragma GCC visibility.Eli Friedman2010-08-051-0/+5
| | | | llvm-svn: 110315
* Parser: Add support for #pragma align, which is just another spelling of #pragmaDaniel Dunbar2010-07-311-0/+5
| | | | | | options align. llvm-svn: 109952
* Modify the pragma handlers to accept and use StringRefs instead of ↵Argyrios Kyrtzidis2010-07-131-21/+15
| | | | | | | | | | | IdentifierInfos. When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded). We can avoid this if we just use StringRefs for the pragmas. As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified. llvm-svn: 108237
* revert a hunk of code that Argiris added in r106213, which is theChris Lattner2010-07-121-10/+1
| | | | | | | root cause of PR7481 and probably more, and has no apparent testcases. I don't understand the logic here so I can't repair it. llvm-svn: 108119
* Fix PR7617 by not entering ParseFunctionDefinition whenChris Lattner2010-07-111-4/+9
| | | | | | | | | | | | | | | | | | | | | a function prototype is followed by a declarator if we aren't parsing a K&R style identifier list. Also, avoid skipping randomly after a declaration if a semicolon is missing. Before we'd get: t.c:3:1: error: expected function body after function declarator void bar(); ^ Now we get: t.c:1:11: error: invalid token after top level declarator void foo() ^ ; llvm-svn: 108105
* add a const qualifier, refactor some code.Chris Lattner2010-07-111-1/+1
| | | | llvm-svn: 108104
* Move the "current scope" state from the Parser into Action. ThisDouglas Gregor2010-07-021-29/+30
| | | | | | | | | | | | | | allows Sema some limited access to the current scope, which we only use in one way: when Sema is performing some kind of declaration that is not directly driven by the parser (e.g., due to template instantiatio or lazy declaration of a member), we can find the Scope associated with a DeclContext, if that DeclContext is still in the process of being parsed. Use this to make the implicit declaration of special member functions in a C++ class more "scope-less", rather than using the NULL Scope hack. llvm-svn: 107491
* Make sure parens/braces/brackets are correctly balanced.Argyrios Kyrtzidis2010-06-171-1/+12
| | | | | | | | | | | In a line like: (; the semicolon leaves Parser:ParenCount unbalanced (it's 1 even though we stopped looking for a right paren). This may affect later parsing and result in bad recovery for parsing errors. llvm-svn: 106213
* Fix the recently-added warning about 'typename' and 'template'Douglas Gregor2010-06-161-2/+4
| | | | | | | | | disambiguation keywords outside of templates in C++98/03. Previously, the warning would fire when the associated nested-name-specifier was not dependent, but that was a misreading of the C++98/03 standard: now, we complain only when we're outside of any template. llvm-svn: 106161
* Parse: Add support for '#pragma options align'.Daniel Dunbar2010-05-261-0/+7
| | | | | | Also, fix a source location bug with the rparen in #pragma pack. llvm-svn: 104784
* Improve code completion in failure cases in two ways:Douglas Gregor2010-05-251-3/+23
| | | | | | | | | | | 1) Suppress diagnostics as soon as we form the code-completion token, so we don't get any error/warning spew from the early end-of-file. 2) If we consume a code-completion token when we weren't expecting one, go into a code-completion recovery path that produces the best results it can based on the context that the parser is in. llvm-svn: 104585
* Improve parser recovery when we encounter a dependent template nameDouglas Gregor2010-05-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is missing the 'template' keyword, e.g., t->getAs<T>() where getAs is a member of an unknown specialization. C++ requires that we treat "getAs" as a value, but that would fail to parse since T is the name of a type. We would then fail at the '>', since a type cannot be followed by a '>'. This is a very common error for C++ programmers to make, especially since GCC occasionally allows it when it shouldn't (as does Visual C++). So, when we are in this case, we use tentative parsing to see if the tokens starting at "<" can only be parsed as a template argument list. If so, we produce a diagnostic with a fix-it that states that the 'template' keyword is needed: test/SemaTemplate/dependent-template-recover.cpp:5:8: error: 'template' keyword is required to treat 'getAs' as a dependent template name t->getAs<T>(); ^ template This is just a start of this patch; I'd like to apply the same approach to everywhere that a template-id with dependent template name can be parsed. llvm-svn: 104406
* Propagate access specifiers to anonymous union members nested within classes.John McCall2010-05-211-1/+1
| | | | | | Fixes <rdar://problem/7987650>. llvm-svn: 104376
* Diagnose misordered initializers in constructor templates immediately instead ofJohn McCall2010-04-101-2/+8
| | | | | | | | | | when they're instantiated. Merge the note into the -Wreorder warning; it doesn't really contribute much, and it was splitting a thought across diagnostics anyway. Don't crash in the parser when a constructor's initializers end in a comma and there's no body; the recovery here is still terrible, but anything's better than a crash. llvm-svn: 100922
* Fix some redundant errors by changing CXXScopeSpec::isSet calls intoJeffrey Yasskin2010-04-071-1/+1
| | | | | | isNotEmpty calls. llvm-svn: 100722
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-5/+5
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-5/+5
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-5/+5
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Remove the capture, serialization, and deserialization of commentDouglas Gregor2010-03-191-18/+0
| | | | | | | | ranges as part of the ASTContext. This code is not and was never used, but contributes ~250k to the size of the Cocoa.h precompiled header. llvm-svn: 99007
* Unbreak the buildDouglas Gregor2010-03-011-1/+1
| | | | llvm-svn: 97519
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-0/+1
| | | | | | | | | | | | | | | | | | | | which has the label map, switch statement stack, etc. Previously, we had a single set of maps in Sema (for the function) along with a stack of block scopes. However, this lead to funky behavior with nested functions, e.g., in the member functions of local classes. The explicit-stack approach is far cleaner, and we retain a 1-element cache so that we're not malloc/free'ing every time we enter a function. Fixes PR6382. Also, tweaked the unused-variable warning suppression logic to look at errors within a given Scope rather than within a given function. The prior code wasn't looking at the right number-of-errors count when dealing with blocks, since the block's count would be deallocated before we got to ActOnPopScope. This approach works with nested blocks/functions, and gives tighter error recovery. llvm-svn: 97518
* Fix an assertion-on-error during tentative constructor parsing byJohn McCall2010-02-261-20/+20
| | | | | | | | | | propagating error conditions out of the various annotate-me-a-snowflake routines. Generally (but not universally) removes redundant diagnostics as well as, you know, not crashing on bad code. On the other hand, I have just signed myself up to fix fiddly parser errors for the next week. Again. llvm-svn: 97221
* Retain attributes for K&R style parameter declarations.Richard Pennington2010-02-231-4/+5
| | | | llvm-svn: 96941
OpenPOWER on IntegriCloud