summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor how we collect attributes during parsing, and add slots for attributesJohn McCall2010-12-241-6/+4
| | | | | | | on array and function declarators. This is pretty far from complete, and I'll revisit it later if someone doesn't beat me to it. llvm-svn: 122535
* Introduce a new type, PackExpansionType, to capture types that areDouglas Gregor2010-12-201-0/+5
| | | | | | | | | | | | | | | | | | | | pack expansions, e.g. given template<typename... Types> struct tuple; template<typename... Types> struct tuple_of_refs { typedef tuple<Types&...> types; }; the type of the "types" typedef is a PackExpansionType whose pattern is Types&. This commit introduces support for creating pack expansions for template type arguments, as above, but not for any other kind of pack expansion, nor for any form of instantiation. llvm-svn: 122223
* Diagnose attempst to template using declarations and using directives.John McCall2010-11-101-2/+21
| | | | | | Recover from the latter and fail early for the former. Fixes PR8022. llvm-svn: 118669
* Diagnose the declaration of template template parameters thatDouglas Gregor2010-10-211-1/+1
| | | | | | | | themselves have no template parameters. This is actually a restriction due to the grammar of template template parameters, but we choose to diagnose it in Sema to provide better recovery. llvm-svn: 117032
* When we are missing the ',' or '>' to terminate a template parameterDouglas Gregor2010-10-151-1/+1
| | | | | | list, complain about it! Fixes PR7053. llvm-svn: 116551
* One who seeks knowledge learns something new every day.John McCall2010-08-261-2/+2
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-2/+2
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* Abstract out passing around types and kill off ActionBase.John McCall2010-08-241-9/+11
| | | | llvm-svn: 111901
* Kill off ExprArg (now just Expr*) and StmtArg (now just Stmt*).John McCall2010-08-231-1/+1
| | | | llvm-svn: 111863
* Push DeclGroupRefs and TemplateNames in an opaque but type-safe wayJohn McCall2010-08-231-2/+2
| | | | | | through the parser. llvm-svn: 111800
* Kill off Parser::TemplateParameterList to avoid misparses.John McCall2010-08-231-4/+4
| | | | llvm-svn: 111796
* Sundry incremental steps towards killing off Action.John McCall2010-08-231-1/+1
| | | | llvm-svn: 111795
* DeclPtrTy -> Decl *John McCall2010-08-211-27/+25
| | | | llvm-svn: 111733
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-3/+3
| | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
* Template keyword should not be ignored building a QualifiedTemplateName.Abramo Bagnara2010-08-061-1/+3
| | | | llvm-svn: 110441
* Treat template parameters as part of the declaration-specifiers for theJohn McCall2010-07-161-3/+14
| | | | | | | | purpose of access control. Fixes PR7644. I can't actually find anything directly justifying this, but it seems obvious. llvm-svn: 108521
* Fix PR7617 by not entering ParseFunctionDefinition whenChris Lattner2010-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | a function prototype is followed by a declarator if we aren't parsing a K&R style identifier list. Also, avoid skipping randomly after a declaration if a semicolon is missing. Before we'd get: t.c:3:1: error: expected function body after function declarator void bar(); ^ Now we get: t.c:1:11: error: invalid token after top level declarator void foo() ^ ; llvm-svn: 108105
* Move the "current scope" state from the Parser into Action. ThisDouglas Gregor2010-07-021-6/+6
| | | | | | | | | | | | | | allows Sema some limited access to the current scope, which we only use in one way: when Sema is performing some kind of declaration that is not directly driven by the parser (e.g., due to template instantiatio or lazy declaration of a member), we can find the Scope associated with a DeclContext, if that DeclContext is still in the process of being parsed. Use this to make the implicit declaration of special member functions in a C++ class more "scope-less", rather than using the NULL Scope hack. llvm-svn: 107491
* Implement C++ DR481, which clarifies that the scope of templateDouglas Gregor2010-07-011-45/+35
| | | | | | | | | | | | | | | | | parameters starts at the end of the template-parameter rather than at the point where the template parameter name is encounted. For example, given: typedef unsigned char T; template<typename T = T> struct X0 { }; The "T" in the default argument refers to the typedef of "unsigned char", rather than referring to the newly-introduced template type parameter 'T'. Addresses <rdar://problem/8122812>. llvm-svn: 107354
* When we see a 'template' disambiguator that marks the next identifierDouglas Gregor2010-06-161-9/+8
| | | | | | | | | | | (or operator-function-id) as a template, but the context is actually non-dependent or the current instantiation, allow us to use knowledge of what kind of template it is, e.g., type template vs. function template, for further syntactic disambiguation. This allows us to parse properly in the presence of stray "template" keywords, which is necessary in C++0x and it's good recovery in C++98/03. llvm-svn: 106167
* Fix the recently-added warning about 'typename' and 'template'Douglas Gregor2010-06-161-3/+3
| | | | | | | | | disambiguation keywords outside of templates in C++98/03. Previously, the warning would fire when the associated nested-name-specifier was not dependent, but that was a misreading of the C++98/03 standard: now, we complain only when we're outside of any template. llvm-svn: 106161
* Properly disambiguate between an elaborated-type-specifier and aDouglas Gregor2010-06-041-2/+31
| | | | | | type-parameter within a template parameter list. Found by inspection. llvm-svn: 105462
* Improve recovery when we see a dependent template name that is missingDouglas Gregor2010-05-211-1/+6
| | | | | | | | | | | | | | | the required "template" keyword, using the same heuristics we do for dependent template names in member access expressions, e.g., test/SemaTemplate/dependent-template-recover.cpp:11:8: error: use 'template' keyword to treat 'getAs' as a dependent template name T::getAs<U>(); ^ template Fixes PR5404. llvm-svn: 104409
* Improve parser recovery when we encounter a dependent template nameDouglas Gregor2010-05-211-1/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is missing the 'template' keyword, e.g., t->getAs<T>() where getAs is a member of an unknown specialization. C++ requires that we treat "getAs" as a value, but that would fail to parse since T is the name of a type. We would then fail at the '>', since a type cannot be followed by a '>'. This is a very common error for C++ programmers to make, especially since GCC occasionally allows it when it shouldn't (as does Visual C++). So, when we are in this case, we use tentative parsing to see if the tokens starting at "<" can only be parsed as a template argument list. If so, we produce a diagnostic with a fix-it that states that the 'template' keyword is needed: test/SemaTemplate/dependent-template-recover.cpp:5:8: error: 'template' keyword is required to treat 'getAs' as a dependent template name t->getAs<T>(); ^ template This is just a start of this patch; I'd like to apply the same approach to everywhere that a template-id with dependent template name can be parsed. llvm-svn: 104406
* Propagate access specifiers to anonymous union members nested within classes.John McCall2010-05-211-1/+1
| | | | | | Fixes <rdar://problem/7987650>. llvm-svn: 104376
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-1/+1
| | | | | | the C-only "optimization". llvm-svn: 100022
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-1/+1
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-1/+1
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* When placing an annotation token over an existing annotation token, make ↵Sebastian Redl2010-02-081-1/+1
| | | | | | sure that the new token's range extends to the end of the old token. Assert that in AnnotateCachedTokens. Fixes PR6248. llvm-svn: 95555
* Reimplement constructor declarator parsing to cope with template-idsDouglas Gregor2010-01-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that name constructors, the endless joys of out-of-line constructor definitions, and various other corner cases that the previous hack never imagined. Fixes PR5688 and tightens up semantic analysis for constructor names. Additionally, fixed a problem where we wouldn't properly enter the declarator scope of a parenthesized declarator. We were entering the scope, then leaving it when we saw the ")"; now, we re-enter the declarator scope before parsing the parameter list. Note that we are forced to perform some tentative parsing within a class (call it C) to tell the difference between C(int); // constructor and C (f)(int); // member function which is rather unfortunate. And, although it isn't necessary for correctness, we use the same tentative-parsing mechanism for out-of-line constructors to improve diagnostics in icky cases like: C::C C::f(int); // error: C::C refers to the constructor name, but // we complain nicely and recover by treating it as // a type. llvm-svn: 93322
* Make sure to give an error for template argument lists followed by junk.Eli Friedman2009-12-271-2/+4
| | | | llvm-svn: 92177
* Second half of r91023, saving files is good.Chris Lattner2009-12-101-0/+1
| | | | llvm-svn: 91024
* spread 'const' love to some variables. this considerably reduces the amount ↵Nuno Lopes2009-12-101-1/+1
| | | | | | of dirty data around. llvm-svn: 91002
* Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.Benjamin Kramer2009-11-281-2/+1
| | | | llvm-svn: 90044
* Added rudimentary C++0x attribute support.Alexis Hunt2009-11-211-0/+4
| | | | | | | | | | | | | | The following attributes are currently supported in C++0x attribute lists (and in GNU ones as well): - align() - semantics believed to be conformant to n3000, except for redeclarations and what entities it may apply to - final - semantics believed to be conformant to CWG issue 817's proposed wording, except for redeclarations - noreturn - semantics believed to be conformant to n3000, except for redeclarations - carries_dependency - currently ignored (this is an optimization hint) llvm-svn: 89543
* Implement C++ [temp.param]p2 correctly, looking ahead when we see aDouglas Gregor2009-11-211-5/+35
| | | | | | | "typename" parameter to distinguish between non-type and type template parameters. Fixes the actual bug in PR5559. llvm-svn: 89532
* Cope with extraneous "template" keyword when providing an out-of-lineDouglas Gregor2009-11-201-1/+2
| | | | | | definition of a member template (or a member thereof). Fixes PR5566. llvm-svn: 89512
* Remove an overly-eager assertion when replacing tokens with anDouglas Gregor2009-11-121-16/+17
| | | | | | | | | | | annotation token, because some of the tokens we're annotating might not be in the set of cached tokens (we could have consumed them unconditionally). Also, move the tentative parsing from ParseTemplateTemplateArgument into the one caller that needs it, improving recovery. llvm-svn: 86904
* Introduce a new representation for template templateDouglas Gregor2009-11-111-73/+90
| | | | | | | | | | | | | | | | | | | | | | | | | parameters. Rather than storing them as either declarations (for the non-dependent case) or expressions (for the dependent case), we now (always) store them as TemplateNames. The primary change here is to add a new kind of TemplateArgument, which stores a TemplateName. However, making that change ripples to every switch on a TemplateArgument's kind, also affecting TemplateArgumentLocInfo/TemplateArgumentLoc, default template arguments for template template parameters, type-checking of template template arguments, etc. This change is light on testing. It should fix several pre-existing problems with template template parameters, such as: - the inability to use dependent template names as template template arguments - template template parameter default arguments cannot be instantiation However, there are enough pieces missing that more implementation is required before we can adequately test template template parameters. llvm-svn: 86777
* Silence warning.Benjamin Kramer2009-11-101-1/+1
| | | | llvm-svn: 86719
* Improve parsing of template arguments to lay the foundation forDouglas Gregor2009-11-101-38/+97
| | | | | | | | | | | | | | | | | | | | | | handling template template parameters properly. This refactoring: - Parses template template arguments as id-expressions, representing the result of the parse as a template name (Action::TemplateTy) rather than as an expression (lame!). - Represents all parsed template arguments via a new parser-specific type, ParsedTemplateArgument, which stores the kind of template argument (type, non-type, template) along with all of the source information about the template argument. This replaces an ad hoc set of 3 vectors (one for a void*, which was either a type or an expression; one for a bit telling whether the first was a type or an expression; and one for a single source location pointing at the template argument). - Moves TemplateIdAnnotation into the new Parse/Template.h. It never belonged in the Basic library anyway. llvm-svn: 86708
* Properly replace (cxxscope, template-id) annotation tokens with aDouglas Gregor2009-11-041-5/+4
| | | | | | single typename annotation token when backtracing. Fixes PR5350. llvm-svn: 86034
* Change our basic strategy for avoiding deprecation warnings when the decl useJohn McCall2009-11-041-3/+6
| | | | | | | | | | | | appears in a deprecated context. In the new strategy, we emit the warnings as usual unless we're currently parsing a declaration, where "declaration" is restricted to mean a decl group or a few special cases in Objective C. If we *are* parsing a declaration, we queue up the deprecation warnings until the declaration has been completely parsed, and then emit them only if the decl is not deprecated. We also standardize the bookkeeping for deprecation so as to avoid special cases. llvm-svn: 85998
* Implement support for parsing dependent template-ids that refer toDouglas Gregor2009-11-041-5/+12
| | | | | | | | overloaded operators, e.g., p->template operator+<T>() llvm-svn: 85989
* Improved fix for PR3844, which recovers better for class templateDouglas Gregor2009-10-301-1/+5
| | | | | | partial specializations and explicit instantiations of non-templates. llvm-svn: 85620
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-81/+81
| | | | llvm-svn: 81346
* Parse extern templates, pass that information all the way to Sema,Douglas Gregor2009-09-041-5/+9
| | | | | | then drop it on the floor. llvm-svn: 80989
* Keep track of the template parameter depth properly when we haveDouglas Gregor2009-08-241-5/+32
| | | | | | | | | | member templates declared inside other templates. This allows us to match out-of-line definitions of member function templates within class templates to the declarations within the class template. We still can't handle out-of-line definitions for member class templates, however. llvm-svn: 79955
* Initial support for parsing and representation of member function templates.Douglas Gregor2009-08-201-0/+6
| | | | llvm-svn: 79570
* Fix a typo in a variable nameDouglas Gregor2009-08-201-3/+3
| | | | llvm-svn: 79558
OpenPOWER on IntegriCloud