aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseCXXInlineMethods.cpp
AgeCommit message (Collapse)AuthorFilesLines
2014-08-27PR20760: Don't assert (and produce better diagnostics) if a default initializerRichard Smith1-18/+29
contains an unmatched closing bracket token. llvm-svn: 216518
2014-07-27Fix default argument comma disambiguation bug following the 'template' keyword.Richard Smith1-0/+1
llvm-svn: 214051
2014-07-22Avoid crash if default argument parsed with errors.Serge Pavlov1-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
2014-05-29Refactoring. Remove release and take methods from ActionResult. Rename ↵Nikola Smiljanic1-2/+2
takeAs to getAs. llvm-svn: 209800
2014-05-23Emit used/dllexport inline method definitions in nested classes (PR19743, ↵Hans Wennborg1-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
2014-05-21[C++11] Use 'nullptr'. Parser edition.Craig Topper1-5/+6
llvm-svn: 209275
2014-05-16Replace a fake enum class with the real thing.Richard Smith1-6/+6
llvm-svn: 208943
2014-05-10Wrap to 80 columns. No behavior change.Nico Weber1-8/+12
llvm-svn: 208475
2014-01-25Rename getResultType() on function and method declarations to getReturnType()Alp Toker1-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
2014-01-22Introduce and use Decl::getAsFunction() to simplify templated function checksAlp Toker1-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
2014-01-17PR18477: Create a function scope representing the constructor call whenRichard Smith1-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
2014-01-01ExpectAndConsume: Diagnose errors automaticallyAlp Toker1-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
2013-12-24Support and use token kinds as diagnostic argumentsAlp Toker1-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
2013-12-17Refactor and micro-optimize ConsumeToken()Alp Toker1-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
2013-11-23Generate a marker token when entering or leaving a submodule when building aRichard Smith1-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
2013-11-18Replaced bool parameters in SkipUntil function with single bit-based parameter.Alexey Bataev1-1/+1
llvm-svn: 194994
2013-11-01Support return type deduction for templates in -fdelayed-template-parsing ↵Faisal Vali1-2/+4
(microsoft) mode Please see http://llvm-reviews.chandlerc.com/D2053 for discussion and Richard's stamp. llvm-svn: 193849
2013-10-23Parse: Disable delayed template parsing for constexpr functionsDavid Majnemer1-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
2013-10-18Check "late parsed" friend functions for redefinitionAlp Toker1-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
2013-09-14Parse: Template specializations which aren't dependent needn't have their ↵David Majnemer1-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
2013-09-12PR13657 (and duplicates):Richard Smith1-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
2013-08-29Remove Inheritable/NonInheritable flags from ProcessDeclAttributes. They don'tRichard Smith1-2/+1
do anything useful. llvm-svn: 189548
2013-08-07PR9992: Serialize and deserialize the token sequence for a function template inRichard Smith1-9/+4
-fdelayed-template-parsing mode. Patch by Will Wilson! llvm-svn: 187916
2013-08-06Started implementing variable templates. Top level declarations should be ↵Larisse Voufo1-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
2013-07-04PR16480: Reimplement token-caching for constructor initializer lists. ThisRichard Smith1-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
2013-06-23Add null check (resolves PR16423)Stephen Lin1-15/+14
llvm-svn: 184661
2013-04-29Keep the parser's template depth up to date when parsing local templates andRichard Smith1-9/+27
late-parsed templates. Patch by Faisal Vali! llvm-svn: 180708
2013-04-26Implement C++1y decltype(auto).Richard Smith1-2/+1
llvm-svn: 180610
2013-03-27[Parser] Don't code-complete twice.Argyrios Kyrtzidis1-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 llvm-svn: 178199
2013-03-14Flag that friend function definitions are "late parsed" so thatJohn McCall1-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 llvm-svn: 177003
2013-01-28Finish semantic analysis for [[carries_dependency]] attribute.Richard Smith1-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). llvm-svn: 173726
2013-01-08Tighten types a bit. No functionality change.Rafael Espindola1-2/+2
llvm-svn: 171895
2013-01-02s/CPlusPlus0x/CPlusPlus11/gRichard Smith1-4/+4
llvm-svn: 171367
2012-12-04Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth1-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. llvm-svn: 169237
2012-08-23Now that ASTMultiPtr is nothing more than a array reference, make it a ↵Benjamin Kramer1-1/+1
MutableArrayRef. This required changing all get() calls to data() and using the simpler constructors. llvm-svn: 162501
2012-08-23Rip out remnants of move semantic emulation and smart pointers in Sema.Benjamin Kramer1-2/+2
These were nops for quite a while and only lead to confusion. ASTMultiPtr now behaves like a proper dumb array reference. llvm-svn: 162475
2012-06-28Support the use of "=delete" and "=default" with delayed templateDouglas Gregor1-0/+1
parsing. Fixes <rdar://problem/11700604>. llvm-svn: 159380
2012-06-10PR13064: Store whether an in-class initializer uses direct or copyRichard Smith1-2/+2
initialization, and use that information to produce the right kind of initialization during template instantiation. llvm-svn: 158288
2012-05-17CXXThisScopeRAII objects aren't free, don't compute one if it's unused.Benjamin Kramer1-1/+1
llvm-svn: 156987
2012-05-07Refactor DelayedDiagnostics so that it keeps diagnostics inJohn McCall1-0/+1
separate pools owned by the RAII objects that keep pushing decl state. This gives us quite a bit more flexibility. llvm-svn: 156289
2012-05-02Revert most of r154844, which was disabled in r155975. Keep around theRichard Smith1-71/+1
refactorings in that revision, and some of the subsequent bugfixes, which seem to be relevant even without delayed exception specification parsing. llvm-svn: 156031
2012-04-16Implement the last part of C++ [class.mem]p2, delaying the parsing ofDouglas Gregor1-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. llvm-svn: 154844
2012-04-16Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor1-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. llvm-svn: 154799
2012-03-20Fix the other place where C++98 work for initializer lists was necessary.Sebastian Redl1-2/+3
llvm-svn: 153129
2012-03-14Parse brace initializers as default arguments. PR12236.Sebastian Redl1-1/+5
llvm-svn: 152721
2012-03-11Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie1-4/+4
(Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
2012-03-08Streamline BalancedDelimiterTracker, by eliminating the duplicateDouglas Gregor1-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. llvm-svn: 152274
2012-02-22Improve diagnostics a bit for bad member initializers, and fix an obscure ↵Eli Friedman1-23/+40
bug involving packs. Fixes PR12049. llvm-svn: 151130
2012-02-21Implement name mangling for lambda expressions that occur within theDouglas Gregor1-1/+2
initializers of data members (both static and non-static). llvm-svn: 151017
2012-02-21Implement name mangling for lambda expressions that occur within theDouglas Gregor1-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. llvm-svn: 151011