summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Now that ASTMultiPtr is nothing more than a array reference, make it a ↵Benjamin Kramer2012-08-231-4/+2
| | | | | | | | MutableArrayRef. This required changing all get() calls to data() and using the simpler constructors. llvm-svn: 162501
* Remove ASTOwningVector, it doesn't own anything and provides no value over ↵Benjamin Kramer2012-08-231-3/+3
| | | | | | SmallVector. llvm-svn: 162492
* Rip out remnants of move semantic emulation and smart pointers in Sema.Benjamin Kramer2012-08-231-10/+10
| | | | | | | These were nops for quite a while and only lead to confusion. ASTMultiPtr now behaves like a proper dumb array reference. llvm-svn: 162475
* PR13619: Make sure we're not at EOF before looking at NextToken().Richard Smith2012-08-201-4/+5
| | | | llvm-svn: 162212
* PR41111, PR5925, PR13210: Teach tentative parsing to annotate identifiers andRichard Smith2012-08-181-10/+15
| | | | | | | | | | | | | | | | | nested names as id-expressions, using the annot_primary_expr annotation, where possible. This removes some redundant lookups, and also allows us to typo-correct within tentative parsing, and to carry on disambiguating past an identifier which we can determine will fail lookup as both a type and as a non-type, allowing us to disambiguate more declarations (and thus offer improved error recovery for such cases). This also introduces to the parser the notion of a tentatively-declared name, which is an identifier which we *might* have seen a declaration for in a tentative parse (but only if we end up disambiguating the tokens as a declaration). This is necessary to correctly disambiguate cases where a variable is used within its own initializer. llvm-svn: 162159
* In 'delete []', the '[]' never starts a lambda. Update a FIXME with a ↵Richard Smith2012-08-091-4/+8
| | | | | | standard reference and add a test. llvm-svn: 161604
* Tweak code-completion heuristics deciding between a lambdaDouglas Gregor2012-07-311-1/+3
| | | | | | | code-completion and an Objective-C message send, based on Jordan's feedback. llvm-svn: 161049
* When we encounter a code-completion token while parsing an ill-formedDouglas Gregor2012-07-311-1/+5
| | | | | | | | lambda-introducer in Objective-C++11, fall back to treating the tokens as an Objective-C message send to provide those (more likely) completions. Fixes <rdar://problem/11980263>. llvm-svn: 161015
* Improvements to vexing-parse warnings. Make the no-parameters case moreRichard Smith2012-07-301-1/+2
| | | | | | | | | | | | | accurate by asking the parser whether there was an ambiguity rather than trying to reverse-engineer it from the DeclSpec. Make the with-parameters case have better diagnostics by using semantic information to drive the warning, improving the diagnostics and adding a fixit. Patch by Nikola Smiljanic. Some minor changes by me to suppress diagnostics for declarations of the form 'T (*x)(...)', which seem to have a very high false positive rate, and to reduce indentation in 'warnAboutAmbiguousFunction'. llvm-svn: 160998
* Clean up a large number of C++11 attribute parse issues, including parsingAlexis Hunt2012-06-231-0/+5
| | | | | | | | | | | | | | | | | | attributes in more places where we didn't and catching a lot more issues. This implements nearly every aspect of C++11 attribute parsing, except for: - Attributes are permitted on explicit instantiations inside the declarator (but not preceding the decl-spec) - Attributes are permitted on friend declarations of functions. - Multiple instances of the same attribute in an attribute-list (e.g. [[noreturn, noreturn]], not [[noreturn]] [[noreturn]] which is conforming) are allowed. The first two are marked as expected-FIXME in the test file and the latter is probably a defect and is currently untested. Thanks to Richard Smith for providing the lion's share of the testcases. llvm-svn: 159072
* Extend the error recovery for a template-argument-list terminated by '>>' toRichard Smith2012-06-181-3/+3
| | | | | | | | | also deal with '>>>' (in CUDA), '>=', and '>>='. Fix the FixItHints logic to deal with cases where the token is followed by an adjacent '=', '==', '>=', '>>=', or '>>>' token, where a naive fix-it would result in a differing token stream on a re-lex. llvm-svn: 158652
* Move isCXXSimpleTypeSpecifier from Parser to Sema and tweak it for wider use.Kaelyn Uhrain2012-06-151-33/+0
| | | | llvm-svn: 158572
* If parsing a trailing-return-type fails, don't pretend we didn't have one atRichard Smith2012-06-121-4/+4
| | | | | | all. Suppresses follow-on errors mentioned in PR13074. llvm-svn: 158348
* Whenever we have a BalancedDelimiterTracker, we have a 'nested' scopeDouglas Gregor2012-06-061-2/+0
| | | | | | | where '>' is going to behave as an operator (and not as a '>' closing a template argument list). llvm-svn: 158111
* Revert most of r154844, which was disabled in r155975. Keep around theRichard Smith2012-05-021-7/+2
| | | | | | | refactorings in that revision, and some of the subsequent bugfixes, which seem to be relevant even without delayed exception specification parsing. llvm-svn: 156031
* Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor2012-04-161-4/+9
| | | | | | | | | 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. llvm-svn: 154844
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-2/+0
| | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 154799
* Parser: Don't manage TemplateAnnotationIds in a delayed cleanup pool.Benjamin Kramer2012-04-141-1/+1
| | | | | | | | | | 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. llvm-svn: 154743
* Disambiguation of '[[':Richard Smith2012-04-101-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 '[]'. llvm-svn: 154369
* For PR11916: Add support for g++'s __int128 keyword. Unlike __int128_t, this isRichard Smith2012-04-041-0/+4
| | | | | | | | | | 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. llvm-svn: 153999
* Fix parsing of type-specifier-seq's. Types are syntactically allowed to beRichard Smith2012-03-121-16/+1
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 152549
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-15/+15
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* 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. llvm-svn: 152348
* User-defined literals: reject string and character UDLs in all places where theRichard Smith2012-03-061-1/+6
| | | | | | | | | | 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. llvm-svn: 152098
* Implement a new type trait __is_trivially_constructible(T, Args...)Douglas Gregor2012-02-241-0/+60
| | | | | | | | | | | | | | | | that provides the behavior of the C++11 library trait std::is_trivially_constructible<T, Args...>, which can't be implemented purely as a library. Since __is_trivially_constructible can have zero or more arguments, I needed to add Yet Another Type Trait Expression Class, this one handling arbitrary arguments. The next step will be to migrate UnaryTypeTrait and BinaryTypeTrait over to this new, more general TypeTrait class. Fixes the Clang side of <rdar://problem/10895483> / PR12038. llvm-svn: 151352
* Provide the __is_trivially_assignable type trait, which providesDouglas Gregor2012-02-231-0/+1
| | | | | | | compiler support for the std::is_trivially_assignable library type trait. llvm-svn: 151240
* Accept braced-init-lists in conditions, and, in passing, dramatically improveRichard Smith2012-02-221-8/+27
| | | | | | the diagnostic for using a parenthesized direct-initializer in a condition. llvm-svn: 151137
* In the conflict between C++11 [expr.prim.general]p4, which declaresDouglas Gregor2012-02-211-2/+4
| | | | | | | | | | | that 'this' can be used in the brace-or-equal-initializer of a non-static data member, and C++11 [expr.prim.lambda]p9, which says that lambda expressions not in block scope can have no captures, side fully with C++11 [expr.prim.general]p4 by allowing 'this' to be captured within these initializers. This seems to be the intent of non-static data member initializers. llvm-svn: 151101
* Basic support for name mangling of C++11 lambda expressions. BecauseDouglas Gregor2012-02-201-2/+1
| | | | | | | | | | | | | | | name mangling in the Itanium C++ ABI for lambda expressions is so dependent on context, we encode the number used to encode each lambda as part of the lambda closure type, and maintain this value within Sema. Note that there are a several pieces still missing: - We still get the linkage of lambda expressions wrong - We aren't properly numbering or mangling lambda expressions that occur in default function arguments or in data member initializers. - We aren't (de-)serializing the lambda numbering tables llvm-svn: 150982
* Set the location of the template keyword when allocating a new ↵Benjamin Kramer2012-02-191-0/+1
| | | | | | | | TemplateIdAnnotation. Found by valgrind. llvm-svn: 150940
* Reject continue/break statements within members of local functions nested withinRichard Smith2012-02-171-1/+0
| | | | | | | | | | | | | | | loop and switch statements, by teaching Scope that a function scope never has a continue/break parent for the purposes of control flow. Remove the hack in block and lambda expressions which worked around this by pretending that such expressions were continue/break scopes. Remove Scope::ControlParent, since it's unused. In passing, teach default statements to recover properly from a missing ';', and add a fixit for same to both default and case labels (the latter already recovered correctly). llvm-svn: 150776
* Improve recovery for lambda expressions that have 'mutable' or aDouglas Gregor2012-02-161-0/+46
| | | | | | | trailing return type but not a '()'. Recover by inserting the parentheses. Thanks to Xeo on IRC for the example. llvm-svn: 150727
* Revert "Revert "Make CXXNewExpr contain only a single initialier, and not ↵Sebastian Redl2012-02-161-8/+10
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
* Revert "Make CXXNewExpr contain only a single initialier, and not hold the ↵Sebastian Redl2012-02-161-10/+8
| | | | | | | | | | used constructor itself." It leads to a compiler crash in the Bullet benchmark. This reverts commit r12014. llvm-svn: 150684
* Make CXXNewExpr contain only a single initialier, and not hold the used ↵Sebastian Redl2012-02-161-8/+10
| | | | | | | | | | constructor itself. Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities. This breaks the static analysis of new expressions. I've filed PR12014 to track this. llvm-svn: 150682
* Implement code completion support for lambda capture lists.Douglas Gregor2012-02-151-4/+31
| | | | llvm-svn: 150583
* Implement support for lambda capture pack expansions, e.g.,Douglas Gregor2012-02-141-2/+6
| | | | | | [&values...] { print(values...); } llvm-svn: 150497
* Proper initializer list support for new expressions and type construct ↵Sebastian Redl2012-02-121-4/+7
| | | | | | expressions. Array new still missing. llvm-svn: 150346
* Fix parsing new expressions using init lists. Probably still do the wrong ↵Sebastian Redl2012-02-111-2/+4
| | | | | | | | thing in cases involving array new. Show that many cases using initializer list constructors work, in that they parse and pass semantic analysis. llvm-svn: 150316
* Allow implicit capture of 'this' in a lambda even when the captureDouglas Gregor2012-02-101-2/+2
| | | | | | | | | | | | default is '=', and reword the warning about explicitly capturing 'this' in such lambdas to indicate that only explicit capture is banned. Introduce Fix-Its for this and other "save the programmer from themself" rules regarding what can be explicitly captured and what must be implicitly captured. llvm-svn: 150256
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-061-1/+2
| | | | | | process removed some naming ambiguities. llvm-svn: 149870
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-49/+55
| | | | llvm-svn: 149127
* Avoid redundant NNS qualification in constructor/destructor names.Abramo Bagnara2012-01-271-15/+17
| | | | llvm-svn: 149124
* Avoid correcting unknown identifiers to types where types aren't allowed.Kaelyn Uhrain2012-01-251-1/+1
| | | | | | | | Pass a typo correction callback object from ParseCastExpr to Sema::ActOnIdExpression to be a bit more selective about what kinds of corrections will be allowed for unknown identifiers. llvm-svn: 148973
* Support decltype as a simple-type-specifier.David Blaikie2012-01-241-1/+4
| | | | | | | This makes all sorts of fun examples work with decltype. Reviewed by Richard Smith. llvm-svn: 148787
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-1/+1
| | | | llvm-svn: 148577
* Remove PotentiallyPotentiallyEvaluated, and replace it with a much simpler ↵Eli Friedman2012-01-201-4/+4
| | | | | | and less error-prone way of handling the relevant cases. Towards marking of whether a declaration is used more accurately. llvm-svn: 148522
* Extend the error of invalid token after declarations to include fixits for Richard Trieu2012-01-191-5/+1
| | | | | | !=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =. llvm-svn: 148499
* Change the error when a '+=' follows a declaration to suggest a fixit to '=' ↵Richard Trieu2012-01-181-2/+6
| | | | | | | | | | | | | | | | | | | instead of just suggesting a ';'. Old error: plusequaldeclare1.cc:3:8: error: expected ';' at end of declaration int x += 6; ^ ; New error: plusequaldeclare1.cc:3:9: error: invalid '+=' at end of declaration; did you mean '='? int x += 6; ^~ = llvm-svn: 148433
* Remove unnecessary default cases in switches over enums.David Blaikie2012-01-171-2/+0
| | | | | | This allows -Wswitch-enum to find switches that need updating when these enums are modified. llvm-svn: 148281
OpenPOWER on IntegriCloud