summaryrefslogtreecommitdiffstats
path: root/lib/Parse/ParseCXXInlineMethods.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic2014-05-291-2/+2
| | | | | | takeAs to getAs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209800 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209549 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'. Parser edition.Craig Topper2014-05-211-5/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209275 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace a fake enum class with the real thing.Richard Smith2014-05-161-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208943 91177308-0d34-0410-b5e6-96231b3b80d8
* Wrap to 80 columns. No behavior change.Nico Weber2014-05-101-8/+12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208475 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199794 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199453 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198270 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197972 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197497 91177308-0d34-0410-b5e6-96231b3b80d8
* 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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195543 91177308-0d34-0410-b5e6-96231b3b80d8
* Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev2013-11-181-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194994 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193849 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193274 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192948 91177308-0d34-0410-b5e6-96231b3b80d8
* 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190743 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190639 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove Inheritable/NonInheritable flags from ProcessDeclAttributes. They don'tRichard Smith2013-08-291-2/+1
| | | | | | | do anything useful. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189548 91177308-0d34-0410-b5e6-96231b3b80d8
* 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187916 91177308-0d34-0410-b5e6-96231b3b80d8
* 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... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187762 91177308-0d34-0410-b5e6-96231b3b80d8
* 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185598 91177308-0d34-0410-b5e6-96231b3b80d8
* Add null check (resolves PR16423)Stephen Lin2013-06-231-15/+14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184661 91177308-0d34-0410-b5e6-96231b3b80d8
* 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180708 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement C++1y decltype(auto).Richard Smith2013-04-261-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180610 91177308-0d34-0410-b5e6-96231b3b80d8
* [Parser] Don't code-complete twice.Argyrios Kyrtzidis2013-03-271-2/+2
| | | | | | | | | | | | | | | When we are consuming the current token just to enter a new token stream, we push the current token in the back of the stream so that we get it again. Unfortunately this had the effect where if the current token is a code-completion one, we would code-complete once during consuming it and another time after the stream ended. Fix this by making sure that, in this case, ConsumeAnyToken() will consume a code-completion token without invoking code-completion. rdar://12842503 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178199 91177308-0d34-0410-b5e6-96231b3b80d8
* Flag that friend function definitions are "late parsed" so thatJohn McCall2013-03-141-5/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | template instantiation will still consider them to be definitions if we instantiate the containing class before we get around to parsing the friend. This seems like a legitimate use of "late template parsed" to me, but I'd appreciate it if someone responsible for the MS feature would look over this. This file already appears to access AST nodes directly, which is arguably not kosher in the parser, but the performance of this path matters enough that perpetuating the sin is justifiable. Probably we ought to reconsider this policy for very simple manipulations like this. The reason this entire thing is necessary is that function template instantiation plays some very gross games in order to not associate an instantiated function template with the class it came from unless it's a definition, and the reason *that's* necessary is that the AST currently cannot represent the instantiation history of individual function template declarations, but instead tracks it in common for the entire function template. That probably prevents us from correctly reporting ill-formed calls to ambiguously instantiated friend function templates. rdar://12350696 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177003 91177308-0d34-0410-b5e6-96231b3b80d8
* Finish semantic analysis for [[carries_dependency]] attribute.Richard Smith2013-01-281-2/+2
| | | | | | | | | | | This required plumbing through a new flag to determine whether a ParmVarDecl is actually a parameter of a function declaration (as opposed to a function typedef etc, where the attribute is prohibited). Weirdly, this attribute (just like [[noreturn]]) cannot be applied to a function type, just to a function declaration (and its parameters). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173726 91177308-0d34-0410-b5e6-96231b3b80d8
* Tighten types a bit. No functionality change.Rafael Espindola2013-01-081-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171895 91177308-0d34-0410-b5e6-96231b3b80d8
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-4/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171367 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-3/+3
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
* Now that ASTMultiPtr is nothing more than a array reference, make it a ↵Benjamin Kramer2012-08-231-1/+1
| | | | | | | | MutableArrayRef. This required changing all get() calls to data() and using the simpler constructors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162501 91177308-0d34-0410-b5e6-96231b3b80d8
* Rip out remnants of move semantic emulation and smart pointers in Sema.Benjamin Kramer2012-08-231-2/+2
| | | | | | | These were nops for quite a while and only lead to confusion. ASTMultiPtr now behaves like a proper dumb array reference. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162475 91177308-0d34-0410-b5e6-96231b3b80d8
* Support the use of "=delete" and "=default" with delayed templateDouglas Gregor2012-06-281-0/+1
| | | | | | | parsing. Fixes <rdar://problem/11700604>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159380 91177308-0d34-0410-b5e6-96231b3b80d8
* PR13064: Store whether an in-class initializer uses direct or copyRichard Smith2012-06-101-2/+2
| | | | | | | | initialization, and use that information to produce the right kind of initialization during template instantiation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158288 91177308-0d34-0410-b5e6-96231b3b80d8
* CXXThisScopeRAII objects aren't free, don't compute one if it's unused.Benjamin Kramer2012-05-171-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156987 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor DelayedDiagnostics so that it keeps diagnostics inJohn McCall2012-05-071-0/+1
| | | | | | | separate pools owned by the RAII objects that keep pushing decl state. This gives us quite a bit more flexibility. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156289 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert most of r154844, which was disabled in r155975. Keep around theRichard Smith2012-05-021-71/+1
| | | | | | | | refactorings in that revision, and some of the subsequent bugfixes, which seem to be relevant even without delayed exception specification parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156031 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor2012-04-161-1/+72
| | | | | | | | | | 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-161-5/+16
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* Parse brace initializers as default arguments. PR12236.Sebastian Redl2012-03-141-1/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152721 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-4/+4
| | | | | | | | | | (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
* Streamline BalancedDelimiterTracker, by eliminating the duplicateDouglas Gregor2012-03-081-1/+1
| | | | | | | | | 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
* Improve diagnostics a bit for bad member initializers, and fix an obscure ↵Eli Friedman2012-02-221-23/+40
| | | | | | bug involving packs. Fixes PR12049. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151130 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-1/+2
| | | | | | | initializers of data members (both static and non-static). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151017 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-2/+4
| | | | | | | | | | | | | | | | | | default arguments of function parameters. This simple-sounding task is complicated greatly by two issues: (1) Default arguments aren't actually a real context, so we need to maintain extra state within lambda expressions to track when a lambda was actually in a default argument. (2) At the time that we parse a default argument, the FunctionDecl doesn't exist yet, so lambda closure types end up in the enclosing context. It's not clear that we ever want to change that, so instead we introduce the notion of the "effective" context of a declaration for the purposes of name mangling. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151011 91177308-0d34-0410-b5e6-96231b3b80d8
* Change the diagnostics which said 'accepted as an extension' to instead sayRichard Smith2011-12-291-2/+2
| | | | | | | | 'is an extension'. The former is inappropriate and confusing when building with -Werror/-pedantic-errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147357 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove unused parameter from the LateParsedTemplatedFunction constructor.Francois Pichet2011-12-081-2/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146145 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable delayed template parsing for friend functions declared at template ↵Francois Pichet2011-11-181-2/+1
| | | | | | class scope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144980 91177308-0d34-0410-b5e6-96231b3b80d8