summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Parse: Don't crash when trailing return type is missingDavid Majnemer2015-01-091-5/+4
| | | | | | | | | Sema::CheckParmsForFunctionDef can't cope with a null TypeSourceInfo. Don't let the AST contain the malformed lambda. This fixes PR22122. llvm-svn: 225505
* Fix build breakageDavid Majnemer2014-12-291-1/+2
| | | | | | That's what I get for last second changes... llvm-svn: 224967
* Parse: Recover more gracefully from extra :: tokens before a {David Majnemer2014-12-291-1/+11
| | | | | | | Instead of crashing, recover by eating the extra trailing scope qualifier. This means we will treat 'struct A:: {' as 'struct A {'. llvm-svn: 224966
* Parse: Ignore '::' in 'struct :: {'David Majnemer2014-12-291-5/+11
| | | | | | | Let's pretend that we didn't see the '::' instead of go on believing that we've got some anonymous, but globally qualified, struct. llvm-svn: 224945
* Parse: Consume tokens more carefully in CheckForLParenAfterColonColonDavid Majnemer2014-12-171-27/+29
| | | | | | | | | We would consume the lparen even if it wasn't followed by an identifier or a star-identifier pair. This fixes PR21815. llvm-svn: 224403
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-201-18/+33
| | | | | | | | | Sema::ActOnIdExpression to use the new functionality. Among other things, this allows recovery in several cases where it wasn't possible before (e.g. correcting a mistyped static_cast<>). llvm-svn: 222464
* PR21437, final part of DR1330: delay-parsing of exception-specifications. ThisRichard Smith2014-11-131-2/+7
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* Remove the last couple uses of the ExprArg(just Expr*) typedef in Parser.Craig Topper2014-10-301-1/+1
| | | | llvm-svn: 220897
* Add RestrictQualifierLoc to DeclaratorChunk::FunctionTypeInfoHal Finkel2014-10-201-0/+2
| | | | | | | | | | | | | | Clang supports __restrict__ as a function qualifier, but DeclaratorChunk::FunctionTypeInfo lacked a field to track the qualifier's source location (as we do with volatile, etc.). This was the subject of a FIXME in GetFullTypeForDeclarator (in SemaType.cpp). This should also prove useful as we add more warnings regarding questionable uses of the restrict qualifier. There is no significant functional change (except for an improved source range associated with the err_invalid_qualified_function_type diagnostic fixit generated by GetFullTypeForDeclarator). llvm-svn: 220215
* PR20991: ::decltype is not valid.Richard Smith2014-10-041-1/+2
| | | | llvm-svn: 219043
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-1/+11
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Add error, recovery and fixit for "~A::A() {...}".Richard Smith2014-09-061-2/+21
| | | | llvm-svn: 217302
* Wrap to 80 columns, no functionality change.Nico Weber2014-07-261-2/+2
| | | | llvm-svn: 214036
* PR19751: (T())++ is not a cast-expression.Richard Smith2014-07-151-1/+0
| | | | llvm-svn: 213022
* Convert StringLiteralParser constructor to use ArrayRef instead of a pointer ↵Craig Topper2014-06-261-1/+1
| | | | | | and count. llvm-svn: 211763
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-13/+13
| | | | | | takeAs to getAs. llvm-svn: 209800
* [C++11] Use 'nullptr'. Parser edition.Craig Topper2014-05-211-19/+19
| | | | llvm-svn: 209275
* Replace completely bogus ambiguous-compound-literal-in-C++ code with somethingRichard Smith2014-05-151-2/+4
| | | | | | that isn't always wrong. llvm-svn: 208844
* PR19748: Make sure we don't lose colon protection after the parenthesized ↵Richard Smith2014-05-151-4/+11
| | | | | | type-id in a cast-expression. llvm-svn: 208843
* Cut off parsing early during code completionAlp Toker2014-05-021-3/+3
| | | | | | | | | These calls to ConsumeCodeCompletionToken() caused parsing to continue needlessly when an immediate cutOffParsing() would do. Document the function to clarify its correct usage. llvm-svn: 207823
* Improve error recovery around colon.Serge Pavlov2014-04-131-9/+36
| | | | | | | | | | Parse of nested name spacifier is modified so that it properly recovers if colon is mistyped as double colon in case statement. This patch fixes PR15133. Differential Revision: http://llvm-reviews.chandlerc.com/D2870 llvm-svn: 206135
* PR19339: Disambiguate lambdas with init-captures from designated initializersRichard Smith2014-04-131-2/+2
| | | | | | properly. llvm-svn: 206128
* Allow GNU-style attributes on lambda expressions.Aaron Ballman2014-03-121-3/+12
| | | | llvm-svn: 203628
* Gracefully handle an attribute specifier following a lambda introducer when ↵Aaron Ballman2014-03-111-6/+18
| | | | | | the parameter list wasn't present. llvm-svn: 203565
* [cleanup] Re-sort includes with llvm/utils/sort_includes.py and fixChandler Carruth2014-03-041-1/+1
| | | | | | | | | | | | a missing include from CLog.h. CLog.h referenced most of the core libclang types but never directly included Index.h that provides them. Previously it got lucky and other headers were always included first but with the sorting it ended up first in one case and stopped compiling. Adding the Index.h include fixes it right up. llvm-svn: 202810
* Fix for PR9812: warn about bool instead of _Bool.Erik Verbruggen2014-01-151-20/+23
| | | | llvm-svn: 199311
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-071-1/+1
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* Bring back magic constants in the digraph diagnosticAlp Toker2014-01-071-3/+18
| | | | | | | | This backs out changes in commit r198605 and part of r198604, replacing the original tok::kw_template with a slightly more obvious placeholder tok::unknown. llvm-svn: 198666
* Don't use magic constants in the digraph diagnosticAlp Toker2014-01-061-16/+3
| | | | llvm-svn: 198605
* Parse: Token consumption modernization and loop de-nestingAlp Toker2014-01-051-3/+1
| | | | | | Cleanup only. llvm-svn: 198539
* Eliminate UnaryTypeTraitExprAlp Toker2014-01-011-13/+2
| | | | | | | | | | | | | Remove UnaryTypeTraitExpr and switch all remaining type trait related handling over to TypeTraitExpr. The UTT/BTT/TT enum prefix and evaluation code is retained pending further cleanup. This is part of the ongoing work to unify type traits following the removal of BinaryTypeTraitExpr in r197273. llvm-svn: 198271
* ExpectAndConsume: Diagnose errors automaticallyAlp Toker2014-01-011-5/+5
| | | | | | | | | | | | | | 1) Teach ExpectAndConsume() to emit expected and expected-after diagnostics using the generic diagnostic descriptions added in r197972, eliminating another set of trivial err_expected_* variations while maintaining existing behaviour. 2) Lift SkipUntil() recovery out of ExpectAndConsume(). The Expect/Consume family of functions are primitive parser operations that now have the well-defined property of operating on single tokens. Factoring out recovery exposes opportunities for more consistent and tailored error recover at the call sites instead of just relying on a bottled SkipUntil formula. llvm-svn: 198270
* Support and use token kinds as diagnostic argumentsAlp Toker2013-12-241-2/+2
| | | | | | | | | | | | | | | | | | | Introduce proper facilities to render token spellings using the diagnostic formatter. Replaces most of the hard-coded diagnostic messages related to expected tokens, which all shared the same semantics but had to be multiply defined due to variations in token order or quote marks. The associated parser changes are largely mechanical but they expose commonality in whole chunks of the parser that can now be factored away. This commit uses C++11 typed enums along with a speculative legacy fallback until the transition is complete. Requires corresponding changes in LLVM r197895. llvm-svn: 197972
* Refactor and micro-optimize ConsumeToken()Alp Toker2013-12-171-16/+9
| | | | | | | | | | | | 1) Introduce TryConsumeToken() to handle the common test-and-consume pattern. This brings about readability improvements in the parser and optimizes to avoid redundant checks in the common case. 2) Eliminate the ConsumeCodeCompletionTok special case from ConsumeToken(). This was used by only one caller which has been switched over to the more appropriate ConsumeCodeCompletionToken() function. llvm-svn: 197497
* Remove an unused parameter and include after r197273Alp Toker2013-12-131-2/+1
| | | | llvm-svn: 197274
* Eliminate BinaryTypeTraitExprAlp Toker2013-12-131-18/+6
| | | | | | | | | | | | | | | | | There's nothing special about type traits accepting two arguments. This commit eliminates BinaryTypeTraitExpr and switches all related handling over to TypeTraitExpr. Also fixes a CodeGen failure with variadic type traits appearing in a non-constant expression. The BTT/TT prefix and evaluation code is retained as-is for now but will soon be further cleaned up. This is part of the ongoing work to unify type traits. llvm-svn: 197273
* Unify type trait parsingAlp Toker2013-12-121-124/+46
| | | | | | | | | | | | | | | | | Type trait parsing is all over the place at the moment with unary, binary and n-ary C++11 type traits that were developed independently at different points in clang's history. There's no good reason to handle them separately -- there are three parsers, three AST nodes and lots of duplicated handling code with slightly different implementations and diags for each kind. This commit unifies parsing of type traits and sets the stage for further consolidation. No change in behaviour other than more consistent error recovery. llvm-svn: 197179
* Fix init-captures for generic lambdas.Faisal Vali2013-12-051-6/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For an init capture, process the initialization expression right away. For lambda init-captures such as the following: const int x = 10; auto L = [i = x+1](int a) { return [j = x+2, &k = x](char b) { }; }; keep in mind that each lambda init-capture has to have: - its initialization expression executed in the context of the enclosing/parent decl-context. - but the variable itself has to be 'injected' into the decl-context of its lambda's call-operator (which has not yet been created). Each init-expression is a full-expression that has to get Sema-analyzed (for capturing etc.) before its lambda's call-operator's decl-context, scope & scopeinfo are pushed on their respective stacks. Thus if any variable is odr-used in the init-capture it will correctly get captured in the enclosing lambda, if one exists. The init-variables above are created later once the lambdascope and call-operators decl-context is pushed onto its respective stack. Since the lambda init-capture's initializer expression occurs in the context of the enclosing function or lambda, therefore we can not wait till a lambda scope has been pushed on before deciding whether the variable needs to be captured. We also need to process all lvalue-to-rvalue conversions and discarded-value conversions, so that we can avoid capturing certain constant variables. For e.g., void test() { const int x = 10; auto L = [&z = x](char a) { <-- don't capture by the current lambda return [y = x](int i) { <-- don't capture by enclosing lambda return y; } }; If x was not const, the second use would require 'L' to capture, and that would be an error. Make sure TranformLambdaExpr is also aware of this. Patch approved by Richard (Thanks!!) http://llvm-reviews.chandlerc.com/D2092 llvm-svn: 196454
* Reject template-ids containing literal-operator-ids that have a dependentRichard Smith2013-12-051-5/+10
| | | | | | | | | nested-name-specifier, rather than crashing. (In fact, reject all literal-operator-ids that have a non-namespace nested-name-specifier). The grammar doesn't allow these in some cases, and in other cases does allow them but instantiation will always fail. llvm-svn: 196443
* Fix several crash-on-invalids when using template-ids that aren'tRichard Smith2013-12-041-3/+4
| | | | | | simple-template-ids (eg, 'operator+<int>') in weird places. llvm-svn: 196333
* Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev2013-11-181-21/+21
| | | | llvm-svn: 194994
* [-fms-extensions] Permit 'override' in C++98 and 'sealed' as a synonym for ↵David Majnemer2013-10-181-0/+1
| | | | | | | | | | | | | | 'final' Summary: Some MS headers use these features. Reviewers: rnk, rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1948 llvm-svn: 192936
* Remove an unused variable - thanks to Nick Lewycky for pointing this out!Faisal Vali2013-09-261-1/+0
| | | | llvm-svn: 191462
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-09-261-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - generic lambdas within template functions and nested within other generic lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware (Although I have gotten some useful feedback on my patches of the above and will be incorporating that as I submit those patches for commit) As an example of what compiles through this commit: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. This patch has been reviewed by Doug and Richard. Minor changes (non-functionality affecting) have been made since both of them formally looked at it, but the changes involve removal of supernumerary return type deduction changes (since they are now redundant, with richard having committed a recent patch to address return type deduction for C++11 lambdas using C++14 semantics). Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that SemaType.cpp::ConvertDeclSpecToType may use it to immediately generate a template-parameter-type when 'auto' is parsed in a generic lambda parameter context. (i.e we do NOT use AutoType deduced to a template parameter type - Richard seemed ok with this approach). We encode that this template type was generated from an auto by simply adding $auto to the name which can be used for better diagnostics if needed. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - various tests were added - but much more will be needed. There is obviously more work to be done, and both Richard (weakly) and Doug (strongly) have requested that LambdaExpr be removed form the CXXRecordDecl LambdaDefinitionaData in a future patch which is forthcoming. A greatful thanks to all reviewers including Eli Friedman, James Dennett, and especially the two gracious wizards (Richard Smith and Doug Gregor) who spent hours providing feedback (in person in Chicago and on the mailing lists). And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 191453
* Revert "Implement a rudimentary form of generic lambdas."Manuel Klimek2013-08-221-15/+2
| | | | | | This reverts commit 606f5d7a99b11957e057e4cd1f55f931f66a42c7. llvm-svn: 189004
* Revert "Remove some unused variables identified by Juergen Ributzka *I need ↵Manuel Klimek2013-08-221-0/+1
| | | | | | | | to turn on this warning in Visual C++ - sorry!*" This reverts commit d01d0b63d87ac465f15ce1d6b56bf3faf4525769. llvm-svn: 189003
* Remove some unused variables identified by Juergen Ributzka *I need to turn ↵Faisal Vali2013-08-221-1/+0
| | | | | | on this warning in Visual C++ - sorry!* llvm-svn: 188979
* Implement a rudimentary form of generic lambdas.Faisal Vali2013-08-221-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifically, the following features are not included in this commit: - any sort of capturing within generic lambdas - nested lambdas - conversion operator for captureless lambdas - ensuring all visitors are generic lambda aware As an example of what compiles: template <class F1, class F2> struct overload : F1, F2 { using F1::operator(); using F2::operator(); overload(F1 f1, F2 f2) : F1(f1), F2(f2) { } }; auto Recursive = [](auto Self, auto h, auto ... rest) { return 1 + Self(Self, rest...); }; auto Base = [](auto Self, auto h) { return 1; }; overload<decltype(Base), decltype(Recursive)> O(Base, Recursive); int num_params = O(O, 5, 3, "abc", 3.14, 'a'); Please see attached tests for more examples. Some implementation notes: - Add a new Declarator context => LambdaExprParameterContext to clang::Declarator to allow the use of 'auto' in declaring generic lambda parameters - Augment AutoType's constructor (similar to how variadic template-type-parameters ala TemplateTypeParmDecl are implemented) to accept an IsParameterPack to encode a generic lambda parameter pack. - Add various helpers to CXXRecordDecl to facilitate identifying and querying a closure class - LambdaScopeInfo (which maintains the current lambda's Sema state) was augmented to house the current depth of the template being parsed (id est the Parser calls Sema::RecordParsingTemplateParameterDepth) so that Sema::ActOnLambdaAutoParameter may use it to create the appropriate list of corresponding TemplateTypeParmDecl for each auto parameter identified within the generic lambda (also stored within the current LambdaScopeInfo). Additionally, a TemplateParameterList data-member was added to hold the invented TemplateParameterList AST node which will be much more useful once we teach TreeTransform how to transform generic lambdas. - SemaLambda.h was added to hold some common lambda utility functions (this file is likely to grow ...) - Teach Sema::ActOnStartOfFunctionDef to check whether it is being called to instantiate a generic lambda's call operator, and if so, push an appropriately prepared LambdaScopeInfo object on the stack. - Teach Sema::ActOnStartOfLambdaDefinition to set the return type of a lambda without a trailing return type to 'auto' in C++1y mode, and teach the return type deduction machinery in SemaStmt.cpp to process either C++11 and C++14 lambda's correctly depending on the flag. - various tests were added - but much more will be needed. A greatful thanks to all reviewers including Eli Friedman, James Dennett and the ever illuminating Richard Smith. And yet I am certain that I have allowed unidentified bugs to creep in; bugs, that I will do my best to slay, once identified! Thanks! llvm-svn: 188977
* Removed hack that was used to properly restore the nested name specifier of ↵Larisse Voufo2013-08-061-6/+7
| | | | | | qualified variable template ids. It turns out that the current implementation was just not logical setup for it. This commit has made it so. llvm-svn: 187776
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-2/+8
| | | | | | fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
OpenPOWER on IntegriCloud