summaryrefslogtreecommitdiffstats
path: root/lib/Parse
Commit message (Collapse)AuthorAgeFilesLines
* Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor2012-04-165-27/+181
| | | | | | | | | | exception specifications on member functions until after the closing '}' for the containing class. This allows, for example, a member function to throw an instance of its own class. Fixes PR12564 and a fairly embarassing oversight in our C++98/03 support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154844 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-163-13/+44
| | | | | | | | | | | | | | | | | | | | | | | | | in the declaration of a non-static member function after the (optional) cv-qualifier-seq, which in practice means in the exception specification and late-specified return type. The new scheme here used to manage 'this' outside of a member function scope is more general than the Scope-based mechanism previously used for non-static data member initializers and late-parsesd attributes, because it can also handle the cv-qualifiers on the member function. Note, however, that a separate pass is required for static member functions to determine whether 'this' was used, because we might not know that we have a static function until after declaration matching. Finally, this introduces name mangling for 'this' and for the implicit 'this', which is intended to match GCC's mangling. Independent verification for the new mangling test case would be appreciated. Fixes PR10036 and PR12450. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154799 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete late parsed attributes instead of leaking them.Benjamin Kramer2012-04-141-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154746 91177308-0d34-0410-b5e6-96231b3b80d8
* Parser: Don't manage TemplateAnnotationIds in a delayed cleanup pool.Benjamin Kramer2012-04-143-6/+26
| | | | | | | | | | Instead, make it the allocation function's responsibility to add them to a list and clear it when a top-level decl is finished. This plugs leakage of TemplateAnnotationIds. DelayedCleanupPool is ugly and unused, remove it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154743 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an AttributedStmt type to represent a statement with C++11 attributesRichard Smith2012-04-143-101/+86
| | | | | | | | | | attached. Since we do not support any attributes which appertain to a statement (yet), testing of this is necessarily quite minimal. Patch by Alexander Kornienko! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154723 91177308-0d34-0410-b5e6-96231b3b80d8
* Added a flag to the parser to skip method bodies.Erik Verbruggen2012-04-124-27/+24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154584 91177308-0d34-0410-b5e6-96231b3b80d8
* Part of PR10101: after a parse error in a declaration, try harder to find theRichard Smith2012-04-111-4/+62
| | | | | | | | right place to pick up parsing. In C++, this had a tendency to skip everything declared within headers if the TU starts with garbage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154530 91177308-0d34-0410-b5e6-96231b3b80d8
* Support C++11 attributes at the start of a parameter-declaration.Richard Smith2012-04-112-10/+20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154476 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix GCC's pedantic return-type warning -- this enum is fully covered.Chandler Carruth2012-04-101-0/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154399 91177308-0d34-0410-b5e6-96231b3b80d8
* Parsing of C++11 attributes:Richard Smith2012-04-103-33/+74
| | | | | | | | | | | * Alternative tokens (such as 'compl') are treated as identifiers in attribute names. * An attribute-list can start with a comma. * An ellipsis may not be used with either of our currently-supported C++11 attributes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154381 91177308-0d34-0410-b5e6-96231b3b80d8
* Disambiguation of '[[':Richard Smith2012-04-107-122/+280
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * In C++11, '[[' is ill-formed unless it starts an attribute-specifier. Reject array sizes and array indexes which begin with a lambda-expression. Recover by parsing the lambda as a lambda. * In Objective-C++11, either '[' could be the start of a message-send. Fully disambiguate this case: it turns out that the grammars of message-sends, lambdas and attributes do not actually overlap. Accept any occurrence of '[[' where either '[' starts a message send, but reject a lambda in an array index just like in C++11 mode. Implement a couple of changes to the attribute wording which occurred after our attributes implementation landed: * In a function-declaration, the attributes go after the exception specification, not after the right paren. * A reference type can have attributes applied. * An 'identifier' in an attribute can also be a keyword. Support for alternative tokens (iso646 keywords) in attributes to follow. And some bug fixes: * Parse attributes after declarator-ids, even if they are not simple identifiers. * Do not accept attributes after a parenthesized declarator. * Accept attributes after an array size in a new-type-id. * Partially disamiguate 'delete' followed by a lambda. More work is required here for the case where the lambda-introducer is '[]'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154369 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix bugs found by -Wconstant-conversion improvements currently under review.David Blaikie2012-04-093-24/+19
| | | | | | | | | | | | | | | | | | Specifically, using a an integer outside [0, 1] as a boolean constant seems to be an easy mistake to make with things like "x == a || b" where the author intended "x == a || x == b". The bug caused by calling SkipUntil with three token kinds was also identified by a VC diagnostic & reported by Francois Pichet as review feedback for my commit r154163. I've included test cases to verify the error recovery that was broken/poorly implemented due to this bug. The other fix (lib/Sema/SemaExpr.cpp) seems like that code was never actually reached in any of Clang's tests & is related to Objective C features I'm not familiar with, so I've not been able to construct a test case for it. Perhaps someone else can. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154325 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove "parse error" in favor of more descriptive diagnostics.David Blaikie2012-04-062-9/+4
| | | | | | | | | | | In a few cases clang emitted a rather content-free diagnostic: 'parse error'. This change replaces two actual cases (template parameter parsing and K&R parameter declaration parsing) with more specific diagnostics and removes a third dead case of this in the BalancedDelimiterTracker (the ctor already checked the invariant necessary to ensure that the diag::parse_error was never actually used). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154224 91177308-0d34-0410-b5e6-96231b3b80d8
* Added a new attribute, objc_root_class, which informs the compiler when a ↵Patrick Beard2012-04-061-0/+1
| | | | | | | | | | root class is intentionally declared. The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154187 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed scoping error for late parsed attributes in nested classes.DeLesley Hutchins2012-04-061-0/+9
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154173 91177308-0d34-0410-b5e6-96231b3b80d8
* Restrict fixit for missing 'class' in template template parameters.David Blaikie2012-04-061-15/+29
| | | | | | | | | | | Based on Doug's feedback to r153887 this omits the FixIt if the following token isn't syntactically valid for the context. (not a comma, '...', identifier, '>', or '>>') There's a bunch of work to handle the '>>' case, but it makes for a much more pleasant diagnostic in this case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154163 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve & simplify diagnostic for missing 'class' in template template ↵David Blaikie2012-04-051-5/+3
| | | | | | | | parameter. Change suggested by Sebastian Redl on review feedback from r153887. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154102 91177308-0d34-0410-b5e6-96231b3b80d8
* For PR11916: Add support for g++'s __int128 keyword. Unlike __int128_t, this isRichard Smith2012-04-044-4/+19
| | | | | | | | | | | a type specifier and can be combined with unsigned. This allows libstdc++4.7 to be used with clang in c++98 mode. Several other changes are still required for libstdc++4.7 to work with clang in c++11 mode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153999 91177308-0d34-0410-b5e6-96231b3b80d8
* Enter an expression evaluation context when parsingJohn McCall2012-04-041-1/+7
| | | | | | | statement-expressions. Prevents cleanups and such from being claimed by the first full-expression in the block. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153989 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove windows line endings.David Blaikie2012-04-021-105/+105
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153895 91177308-0d34-0410-b5e6-96231b3b80d8
* Correct error recovery when missing 'class' in a template template parameter.David Blaikie2012-04-021-6/+11
| | | | | | | | | | | | | | | | | The diagnostic message correctly informs the user that they have omitted the 'class' keyword, but neither suggests this insertion as a fixit, nor attempts to recover as if they had provided the keyword. This fixes the recovery, adds the fixit, and adds a separate diagnostic and corresponding replacement fixit for cases where the user wrote 'struct' or 'typename' instead of 'class' (suggested by Richard Smith as a possible common mistake). I'm not sure the diagnostic message for either the original or new cases feel very Clang-esque, so I'm open to suggestions there. The fixit hints make it fairly easy to see what's required, though. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153887 91177308-0d34-0410-b5e6-96231b3b80d8
* Reject 'template<typename...Ts> void f(Ts ...(x));'. Add a special-caseRichard Smith2012-03-291-11/+52
| | | | | | | | diagnostic and a fix-it to explain to the user where the ellipsis is supposed to go. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153622 91177308-0d34-0410-b5e6-96231b3b80d8
* If we see '(...' where we're expecting an abstract-declarator, that doesn'tRichard Smith2012-03-272-7/+17
| | | | | | | | necessarily mean we've found a function declarator. If the next token is not a ')', this is actually a parenthesized pack expansion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153544 91177308-0d34-0410-b5e6-96231b3b80d8
* Add cross-referencing comments to ParseDirectDeclarator to note thatRichard Smith2012-03-271-2/+6
| | | | | | | | isConstructorDeclaration also needs updating for any extension to the grammar of a direct-declarator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153490 91177308-0d34-0410-b5e6-96231b3b80d8
* When we see 'Class(X' or 'Class::Class(X' and we suspect that it names aRichard Smith2012-03-271-1/+36
| | | | | | | | | | | | | | constructor, but X is not a known typename, check whether the tokens could possibly match the syntax of a declarator before concluding that it isn't a constructor. If it's definitely ill-formed, assume it is a constructor. Empirical evidence suggests that this pattern is much more often a constructor with a typoed (or not-yet-declared) type name than any of the other possibilities, so the extra cost of the check is not expected to be problematic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153488 91177308-0d34-0410-b5e6-96231b3b80d8
* [parser] If there are unmatched braces in a function definition, try toArgyrios Kyrtzidis2012-03-241-5/+8
| | | | | | | | | recover by returning the statements that we parsed so far, instead of dropping the whole function body. rdar://10967343 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153367 91177308-0d34-0410-b5e6-96231b3b80d8
* Support for definitions of member enumerations of class templates outside theRichard Smith2012-03-232-34/+52
| | | | | | | | class template's definition, and for explicit specializations of such enum members. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153304 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the other place where C++98 work for initializer lists was necessary.Sebastian Redl2012-03-201-2/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153129 91177308-0d34-0410-b5e6-96231b3b80d8
* Add the missing compatibility warning for braced initializers as default ↵Sebastian Redl2012-03-181-2/+3
| | | | | | arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153026 91177308-0d34-0410-b5e6-96231b3b80d8
* From Vassil Vassilev:Axel Naumann2012-03-161-2/+9
| | | | | | | | | | | | | | | Enable incremental parsing by the Preprocessor, where more code can be provided after an EOF. It mainly prevents the tearing down of the topmost lexer. To be used like this: PP.enableIncrementalProcessing(); while (getMoreSource()) { while (Parser.ParseTopLevelDecl(ADecl)) {...} } PP.enableIncrementalProcessing(false); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152914 91177308-0d34-0410-b5e6-96231b3b80d8
* Small cleanup: move trailing-return-type special-casing intoRichard Smith2012-03-151-3/+3
| | | | | | | getDeclSpecContextFromDeclaratorContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152766 91177308-0d34-0410-b5e6-96231b3b80d8
* Parse brace initializers as default arguments. PR12236.Sebastian Redl2012-03-142-2/+11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152721 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a crash-on-invalid found by -Wlogical-op-parentheses.David Blaikie2012-03-121-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152559 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix parsing of trailing-return-type. Types are syntactically prohibited fromRichard Smith2012-03-122-23/+33
| | | | | | | | | being defined here: [] () -> struct S {} does not define struct S. In passing, implement DR1318 (syntactic disambiguation of 'final'). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152551 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix parsing of type-specifier-seq's. Types are syntactically allowed to beRichard Smith2012-03-123-344/+49
| | | | | | | | | | | | | | | | | | | defined here, but not semantically, so new struct S {}; is always ill-formed, even if there is a struct S in scope. We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being under-loved (due to it only being used in a few places) so merge it into ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this required improving ParseDeclarationSpecifiers' diagnostics in some cases. This also required teaching ParseSpecifierQualifierList about constexpr... which incidentally fixes an issue where we'd allow the constexpr specifier in other bad places. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152549 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-1112-231/+231
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
* Document the availability attributeDouglas Gregor2012-03-111-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152531 91177308-0d34-0410-b5e6-96231b3b80d8
* Support for raw and template forms of numeric user-defined literals,Richard Smith2012-03-093-12/+5
| | | | | | | and lots of tidying up. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152392 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a couple of issues with literal-operator-id parsing, and provide recoveryRichard Smith2012-03-081-11/+56
| | | | | | | | | | | | | for a few kinds of error. Specifically: Since we're after translation phase 6, the "" token might be formed by multiple source-level string literals. Checking the token width is not a correct way of detecting empty string literals, due to escaped newlines. Diagnose and recover from a missing space between "" and suffix, and from string literals other than "", which are followed by a suffix. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152348 91177308-0d34-0410-b5e6-96231b3b80d8
* Streamline BalancedDelimiterTracker, by eliminating the duplicateDouglas Gregor2012-03-085-59/+39
| | | | | | | | | paren/brace/bracket tracking (the Consume* functions already did it), removing the use of ConsumeAnyToken(), and moving the hot paths inline with the error paths out-of-line. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152274 91177308-0d34-0410-b5e6-96231b3b80d8
* Silence unused variable warnings.Benjamin Kramer2012-03-071-3/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152170 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor Clang sema attribute handling.Michael Han2012-03-071-1/+1
| | | | | | | | | | | | | | | | | | | This submission improves Clang sema handling by using Clang tablegen to generate common boilerplate code. As a start, it implements AttributeList enumerator generation and case statements for AttributeList::getKind. A new field "SemaHandler" is introduced in Attr.td and by default set to 1 as most of attributes in Attr.td have semantic checking in Sema. For a small number of attributes that don't appear in Sema, the value is set to 0. Also there are a small number of attributes that only appear in Sema but not in Attr.td. Currently these attributes are still hardcoded in Sema AttributeList. Reviewed by Delesley Hutchins. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152169 91177308-0d34-0410-b5e6-96231b3b80d8
* Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,Ted Kremenek2012-03-062-0/+194
| | | | | | | | | | | | | NSNumber, and boolean literals. This includes both Sema and Codegen support. Included is also support for new Objective-C container subscripting. My apologies for the large patch. It was very difficult to break apart. The patch introduces changes to the driver as well to cause clang to link in additional runtime support when needed to support the new language features. Docs are forthcoming to document the implementation and behavior of these features. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152137 91177308-0d34-0410-b5e6-96231b3b80d8
* User-defined literals: reject string and character UDLs in all places where theRichard Smith2012-03-066-18/+38
| | | | | | | | | | | grammar requires a string-literal and not a user-defined-string-literal. The two constructs are still represented by the same TokenKind, in order to prevent a combinatorial explosion of different kinds of token. A flag on Token tracks whether a ud-suffix is present, in order to prevent clients from needing to look at the token's spelling. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152098 91177308-0d34-0410-b5e6-96231b3b80d8
* static_assert: Allow any string-literal as the message, not just a characterRichard Smith2012-03-051-1/+1
| | | | | | | | string literal, and adjust the diagnostic code to match. This also causes us to escape any control characters in the message. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152069 91177308-0d34-0410-b5e6-96231b3b80d8
* AST/stats: Don't effectively use an out-of-line function to return a staticDaniel Dunbar2012-03-051-2/+2
| | | | | | bool. Ugh. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152062 91177308-0d34-0410-b5e6-96231b3b80d8
* Issue warning when late-parsed attributes have no declaration.DeLesley Hutchins2012-03-021-5/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151947 91177308-0d34-0410-b5e6-96231b3b80d8
* Make late-parsed attributes follow the conventions of ordinaryDeLesley Hutchins2012-03-022-28/+49
| | | | | | | GNU attributes to a better extent, by allowing them in more places on a declator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151945 91177308-0d34-0410-b5e6-96231b3b80d8
* Change @import to @__experimental_modules_import. We are not ready to ↵Ted Kremenek2012-03-012-2/+2
| | | | | | | | commit to a particular syntax for modules, and don't have time to push it forward in the near future. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151841 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid examining the AST from the parser, and simplify somewhat.Richard Smith2012-03-011-15/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151805 91177308-0d34-0410-b5e6-96231b3b80d8