summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseCXXInlineMethods.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge some similar diagnostics using %select.Craig Topper2015-11-141-4/+6
| | | | llvm-svn: 253136
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Rework parsing of pure-specifiers. Perform the grammar matching andRichard Smith2015-06-301-7/+3
| | | | | | disambiguation in the parser rather than trying to do it in Sema. llvm-svn: 241032
* [clang] Refactoring of conditions so they use isOneOf() instead of multiple ↵Daniel Marjamaki2015-06-181-5/+4
| | | | | | is(). llvm-svn: 240008
* Cleanup: no need to pass DefinitionKind into ParseCXXInlineMethodDefEli Bendersky2015-03-231-5/+3
| | | | | | | | | | All ParseCXXInlineMethodDef does with it is assign it on the ParsingDeclarator. Since that is passed in as well, the (single) caller may as well set the DefinitionKind, thus simplifying the code. No change in functionality. llvm-svn: 233043
* Record correct source range for defaulted/deleted members.Eli Bendersky2015-03-231-0/+7
| | | | | | | | | | | | | | | | | | | Fixes https://llvm.org/bugs/show_bug.cgi?id=20744 struct A { A() = default; }; Previously the source range of the declaration of A ended at the ')'. It should include the '= default' part as well. The same for '= delete'. Note: this will break one of the clang-tidy fixers, which is going to be addessed in a follow-up patch. Differential Revision: http://reviews.llvm.org/D8465 llvm-svn: 233028
* Parse: Don't assume tokens have a lengthDavid Majnemer2015-03-191-7/+3
| | | | | | | Don't crash if the last token in a bad inline method body is an annotation token. llvm-svn: 232694
* FIX PR 18432, default args, friends & late-parsed members.Nathan Sidwell2015-02-191-1/+12
| | | | | | | | | | | | Sema::MergeCXXFunctionDecl: propagate hasUnparsedDefaultArg to new decl. Parser::HandleMemberFunctionDeclDelays: check hasUnparsedDefaultArg flag. Parser::ParseLexedMethodDeclaration: handle inherited unparsed default arg case. llvm-svn: 229852
* Code cleanupNathan Sidwell2015-01-301-10/+8
| | | | | | | Parser::ParseLexedMethodDeclaration: Use local var for Param Sema::MergeCXXFunctionDecls: Use hasInheritedDefaultArg llvm-svn: 227577
* Parse: use the EOF token method to lex inline method bodiesDavid Majnemer2015-01-131-20/+23
| | | | | | | | Mark the end of the method body with an EOF token, collect it once we expect to be done with method body parsing. No functionality change intended. llvm-svn: 225765
* Parse: Further simplify ParseLexedMethodDeclarationDavid Majnemer2015-01-131-30/+33
| | | | | | | No functionality change intended, just moving code around to make it simpler. llvm-svn: 225763
* Parse: Get rid of cxx_exceptspec_end, use EOF insteadDavid Majnemer2015-01-121-2/+5
| | | | | | | | Similar to r225619, use a special EOF token to mark the end of the exception specification instead of cxx_exceptspec_end. Use the current scope as the marker. llvm-svn: 225622
* Parse: Just a small tidy-up in ParseLexedMethodDeclarationDavid Majnemer2015-01-121-5/+7
| | | | | | No functional change intended, just tidy up the parse flow. llvm-svn: 225620
* Parse: Get rid of tok::cxx_defaultarg_end, use EOF insteadDavid Majnemer2015-01-121-3/+7
| | | | | | | I added setEofData/getEofData to solve this sort of problem back in r224505. Use the Param's decl to tell us if this is *our* EOF token. llvm-svn: 225619
* Parse: It's cleaner to handle cxx_defaultarg_end in SkipUntil directlyDavid Majnemer2015-01-121-0/+1
| | | | llvm-svn: 225616
* Don't crash on surprising tokens in default parameter template lists.Nico Weber2014-12-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fixes this snippet from SLi's afl fuzzer output: class { i (x = <, enum This parsed i as a function, x as a paramter, and the stuff after < as a template list. This then called TryConsumeDeclarationSpecifier() which called TryAnnotateCXXScopeToken() without checking the preconditions of this function. Check them before calling, like all other callers of TryAnnotateCXXScopeToken() do. A more readable reproducer that causes the same crash is class { void i(int x = MyTemplateClass<int, union int>::foo()); }; The reduced version used an eof token as surprising token, but kw_int works just as well to repro and is easier to insert into a test file. llvm-svn: 224906
* Fix layering violation, Lex shouldn't know about DeclDavid Majnemer2014-12-191-2/+2
| | | | llvm-svn: 224562
* Parse: Don't parse after the eof has been consumedDavid Majnemer2014-12-181-1/+4
| | | | | | | | | | | | | | ParseCXXNonStaticMemberInitializer stashes away all the tokens for the initializer and an additional EOF token to denote where the initializer ends. However, it is possible for ParseLexedMemberInitializer to get its hands on the "real" EOF token; since the two tokens are indistinguishable, we end up consuming the EOF and descend into madness. Instead, make it possible to tell which EOF token we are looking at. This fixes PR21872. llvm-svn: 224505
* PR21565: Further refine the conditions for enabling eager parsing ofRichard Smith2014-11-201-7/+6
| | | | | | | | std::X::swap exception specifications (allowing parsing of non-conforming code in libstdc++). The old conditions also matched the functions in MSVC's STL, which were relying on deferred parsing here. llvm-svn: 222471
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-201-0/+1
| | | | | | | | | 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-0/+70
| | | | | | | is a re-commit of Doug's r154844 (modernized and updated to fit into current Clang). llvm-svn: 221918
* PR20760: Don't assert (and produce better diagnostics) if a default initializerRichard Smith2014-08-271-18/+29
| | | | | | contains an unmatched closing bracket token. llvm-svn: 216518
* Fix default argument comma disambiguation bug following the 'template' keyword.Richard Smith2014-07-271-0/+1
| | | | llvm-svn: 214051
* Avoid crash if default argument parsed with errors.Serge Pavlov2014-07-221-1/+2
| | | | | | | | | | | | | | If function parameters have default values, and that of the second parameter is parsed with errors, function declaration would have a parameter without default value that follows a parameter with that. Such declaration breaks logic of selecting overloaded function. As a solution, put opaque object as default value in such case. This patch fixes PR20055. Differential Revision: http://reviews.llvm.org/D4378 llvm-svn: 213594
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-2/+2
| | | | | | takeAs to getAs. llvm-svn: 209800
* Emit used/dllexport inline method definitions in nested classes (PR19743, ↵Hans Wennborg2014-05-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR11170) The previous code that was supposed to handle this didn't work since parsing of inline method definitions is delayed to the end of the outer class definition. Thus, when HandleTagDeclDefinition() got called for the inner class, the inline functions in that class had not been parsed yet. Richard suggested that the way to do this is by handling inline method definitions through a new ASTConsumer callback. I really wanted to call ASTContext::DeclMustBeEmitted() instead of checking for attributes, but doing that causes us to compute linkage, and then we fail with "error: unsupported: typedef changes linkage of anonymous type, but linkage was already computed" on tests like this: (from SemaCXX/undefined-internal.cpp) :-/ namespace test7 { typedef struct { void bar(); void foo() { bar(); } } A; } Differential Revision: http://reviews.llvm.org/D3809 llvm-svn: 209549
* [C++11] Use 'nullptr'. Parser edition.Craig Topper2014-05-211-5/+6
| | | | llvm-svn: 209275
* Replace a fake enum class with the real thing.Richard Smith2014-05-161-6/+6
| | | | llvm-svn: 208943
* Wrap to 80 columns. No behavior change.Nico Weber2014-05-101-8/+12
| | | | llvm-svn: 208475
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-1/+1
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Introduce and use Decl::getAsFunction() to simplify templated function checksAlp Toker2014-01-221-13/+7
| | | | | | | | | | | | | | Lift the getFunctionDecl() utility out of the parser into a general Decl::getAsFunction() and use it to simplify other parts of the implementation. Reduce isFunctionOrFunctionTemplate() to a simple type check that works the same was as the other is* functions and move unwrapping of shadowed decls to callers so it doesn't get run twice. Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer. There's no need to query when we already know the body can't be skipped. llvm-svn: 199794
* PR18477: Create a function scope representing the constructor call whenRichard Smith2014-01-171-1/+4
| | | | | | | | handling C++11 default initializers. Without this, other parts of Sema (such as lambda capture) would think the default initializer is part of the surrounding function scope. llvm-svn: 199453
* ExpectAndConsume: Diagnose errors automaticallyAlp Toker2014-01-011-3/+3
| | | | | | | | | | | | | | 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-13/+15
| | | | | | | | | | | | | | | | | | | 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-18/+10
| | | | | | | | | | | | 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
* Generate a marker token when entering or leaving a submodule when building aRichard Smith2013-11-231-0/+6
| | | | | | | | | module. Use the marker to diagnose cases where we try to transition between submodules when not at the top level (most likely because a closing brace was missing at the end of a header file, but is also possible if submodule headers attempt to do something fundamentally non-modular, like our .def files). llvm-svn: 195543
* Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev2013-11-181-1/+1
| | | | llvm-svn: 194994
* Support return type deduction for templates in -fdelayed-template-parsing ↵Faisal Vali2013-11-011-2/+4
| | | | | | | | (microsoft) mode Please see http://llvm-reviews.chandlerc.com/D2053 for discussion and Richard's stamp. llvm-svn: 193849
* Parse: Disable delayed template parsing for constexpr functionsDavid Majnemer2013-10-231-0/+1
| | | | | | | | | | | | | | | Commit r191484 treated constexpr function templates as normal function templates with respect to delaying their parsing. However, this is unnecessarily restrictive because there is no compatibility concern with constexpr, MSVC doesn't support it. Instead, simply disable delayed template parsing for constexpr function templates. This largely reverts the changes made in r191484 but keeps it's unit test. This fixes PR17661. llvm-svn: 193274
* Check "late parsed" friend functions for redefinitionAlp Toker2013-10-181-1/+3
| | | | | | | | | | | | | | | r177003 applied the late parsed template technique to friend functions but omitted the corresponding check for redefinitions. This patch adds the same check already in use for templates to the new code path in order to diagnose and reject invalid redefinitions that were being silently accepted. Fixes PR17324. Reviewed by Richard Smith. llvm-svn: 192948
* Parse: Template specializations which aren't dependent needn't have their ↵David Majnemer2013-09-141-4/+5
| | | | | | | | | | | | | | | | parsing be delayed Summary: We should treat a non-dependent template specialization like it wasn't templated at all. Reviewers: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1554 llvm-svn: 190743
* PR13657 (and duplicates):Richard Smith2013-09-121-4/+283
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a comma occurs in a default argument or default initializer within a class, disambiguate whether it is part of the initializer or whether it ends the initializer. The way this works (which I will be proposing for standardization) is to treat the comma as ending the default argument or default initializer if the following token sequence matches the syntactic constraints of a parameter-declaration-clause or init-declarator-list (respectively). This is both consistent with the disambiguation rules elsewhere (where entities are treated as declarations if they can be), and should have no regressions over our old behavior. I think it might also disambiguate all cases correctly, but I don't have a proof of that. There is an annoyance here: because we're performing a tentative parse in a situation where we may not have seen declarations of all relevant entities (if the comma is part of the initializer, lookup may find entites declared later in the class), we need to turn off typo-correction and diagnostics during the tentative parse, and in the rare case that we decide the comma is part of the initializer, we need to revert all token annotations we performed while disambiguating. Any diagnostics that occur outside of the immediate context of the tentative parse (for instance, if we trigger the implicit instantiation of a class template) are *not* suppressed, mirroring the usual rules for a SFINAE context. llvm-svn: 190639
* Remove Inheritable/NonInheritable flags from ProcessDeclAttributes. They don'tRichard Smith2013-08-291-2/+1
| | | | | | do anything useful. llvm-svn: 189548
* PR9992: Serialize and deserialize the token sequence for a function template inRichard Smith2013-08-071-9/+4
| | | | | | -fdelayed-template-parsing mode. Patch by Will Wilson! llvm-svn: 187916
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-3/+3
| | | | | | 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
* PR16480: Reimplement token-caching for constructor initializer lists. ThisRichard Smith2013-07-041-59/+147
| | | | | | | | | | | | | | | previously didn't work if a mem-initializer-id had a template argument which contained parentheses or braces. We now implement a simple rule: just look for a ') {' or '} {' that is not nested. The '{' is assumed to start the function-body. There are still two cases which we misparse, where the ') {' comes from a compound literal or from a lambda. The former case is not valid C++, and the latter will probably not be valid C++ once DR1607 is resolved, so these seem to be of low value, and we do not regress on them with this change. EDG and g++ also misparse both of these cases. llvm-svn: 185598
* Add null check (resolves PR16423)Stephen Lin2013-06-231-15/+14
| | | | llvm-svn: 184661
* Keep the parser's template depth up to date when parsing local templates andRichard Smith2013-04-291-9/+27
| | | | | | late-parsed templates. Patch by Faisal Vali! llvm-svn: 180708
* Implement C++1y decltype(auto).Richard Smith2013-04-261-2/+1
| | | | llvm-svn: 180610
OpenPOWER on IntegriCloud