summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improve parsing of template arguments to lay the foundation forDouglas Gregor2009-11-101-20/+37
| | | | | | | | | | | | | | | | | | | | | | 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
* Improve instantiation of default template arguments for nestedDouglas Gregor2009-11-091-31/+110
| | | | | | | | | templates. The instantiation of these default arguments must be (and now, is) delayed until the template argument is actually used, at which point we substitute all levels of template arguments concurrently. llvm-svn: 86578
* Fix a little canonical-types issue with non-type template arguments.Douglas Gregor2009-11-041-1/+1
| | | | | | Fixes PR5349. llvm-svn: 86052
* Implement support for parsing dependent template-ids that refer toDouglas Gregor2009-11-041-0/+4
| | | | | | | | overloaded operators, e.g., p->template operator+<T>() llvm-svn: 85989
* Parsing and semantic analysis for template-ids that name overloadedDouglas Gregor2009-11-031-23/+54
| | | | | | | | | | | | operators, e.g., operator+<int> which now works in declarators, id-expressions, and member access expressions. This commit only implements the non-dependent case, where we can resolve the template-id to an actual declaration. llvm-svn: 85966
* Replace the code that parses member access expressions after "." orDouglas Gregor2009-11-031-35/+0
| | | | | | | | | | | | "->" with a use of ParseUnqualifiedId. Collapse ActOnMemberReferenceExpr, ActOnDestructorReferenceExpr (both of them), ActOnOverloadedOperatorReferenceExpr, ActOnConversionOperatorReferenceExpr, and ActOnMemberTemplateIdReferenceExpr into a single, new action ActOnMemberAccessExpr that does the same thing more cleanly (and can keep more source-location information). llvm-svn: 85930
* Introduce a new class, UnqualifiedId, that provides a parsedDouglas Gregor2009-11-031-3/+3
| | | | | | | | | | | | | | | | representation of a C++ unqualified-id, along with a single parsing function (Parser::ParseUnqualifiedId) that will parse all of the various forms of unqualified-id in C++. Replace the representation of the declarator name in Declarator with the new UnqualifiedId class, simplifying declarator-id parsing considerably and providing more source-location information to Sema. In the future, I hope to migrate all of the other unqualified-id-parsing code over to this single representation, then begin to merge actions that are currently only different because we didn't have a unqualified notion of the name in the parser. llvm-svn: 85851
* When a friend is declared in a dependent context, don't even try toDouglas Gregor2009-10-301-1/+9
| | | | | | match it up with a declaration in the outer scope. llvm-svn: 85628
* A few TemplateArgumentLoc clean-ups. Try to remember the Expr for a ↵John McCall2009-10-291-6/+8
| | | | | | | | declaration. Provide an API for getting the SourceRange of a TAL and use it judiciously. llvm-svn: 85520
* Track source information for template arguments and template specializationJohn McCall2009-10-291-86/+109
| | | | | | | types. Preserve it through template instantiation. Preserve it through PCH, although TSTs themselves aren't serializable, so that's pretty much meaningless. llvm-svn: 85500
* Implement support for semantic checking and template instantiation ofDouglas Gregor2009-10-291-2/+6
| | | | | | | | class template partial specializations of member templates. Also, fixes a silly little bug in the marking of "used" template parameters in member templates. Fixes PR5236. llvm-svn: 85447
* An explicit instantiation definition only instantiations those classDouglas Gregor2009-10-271-36/+44
| | | | | | | | | members that have a definition. Also, use CheckSpecializationInstantiationRedecl as part of this instantiation to make sure that we diagnose the various kinds of problems that can occur with explicit instantiations. llvm-svn: 85270
* Only set the point of instantiation for an implicit or explicitDouglas Gregor2009-10-271-3/+8
| | | | | | | | | | instantiation once we have committed to performing the instantiation. As part of this, make our makeshift template-instantiation location information suck slightly less. Fixes PR5264. llvm-svn: 85209
* Eliminate QualifiedDeclRefExpr, which captured the notion of aDouglas Gregor2009-10-231-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | qualified reference to a declaration that is not a non-static data member or non-static member function, e.g., namespace N { int i; } int j = N::i; Instead, extend DeclRefExpr to optionally store the qualifier. Most clients won't see or care about the difference (since QualifierDeclRefExpr inherited DeclRefExpr). However, this reduces the number of top-level expression types that clients need to cope with, brings the implementation of DeclRefExpr into line with MemberExpr, and simplifies and unifies our handling of declaration references. Extended DeclRefExpr to (optionally) store explicitly-specified template arguments. This occurs when naming a declaration via a template-id (which will be stored in a TemplateIdRefExpr) that, following template argument deduction and (possibly) overload resolution, is replaced with a DeclRefExpr that refers to a template specialization but maintains the template arguments as written. llvm-svn: 84962
* When building and instantiating a template-id reference expression, such asDouglas Gregor2009-10-221-9/+15
| | | | | | | | | | | N::f<int> keep track of the full nested-name-specifier. This is mainly QoI and relatively hard to test; will try to come up with a printing-based test once we also retain the explicit template arguments past overload resolution. llvm-svn: 84869
* When a template-id expression refers to a member function template, turn it ↵Douglas Gregor2009-10-221-0/+18
| | | | | | into an (implicit) member access expression. Fixes PR5220 llvm-svn: 84848
* Change FixOverloadedFunctionReference to return a (possibly new) expression. ↵Anders Carlsson2009-10-211-1/+1
| | | | | | Substitute TemplateIdRefExprs with DeclRefExprs. Doug, plz review :) llvm-svn: 84763
* Rewrite TreeTransform to transform types as DeclaratorInfos rather than as bareJohn McCall2009-10-211-2/+17
| | | | | | QualTypes. Don't actually exploit this yet. llvm-svn: 84716
* Remove default argument for ImpCastExprToType. Add appropriate argument Eli Friedman2009-10-201-11/+14
| | | | | | | | | | | | | to all callers. Switch a few other users of CK_Unknown to proper cast kinds. Note that there are still some situations where we end up with CK_Unknown; they're pretty easy to find with grep. There are still a few missing conversion kinds, specifically pointer/int/float->bool and the various combinations of real/complex float/int->real/complex float/int. llvm-svn: 84623
* Make the remaining explicit-instantiation semantic action useDouglas Gregor2009-10-151-51/+19
| | | | | | | | | CheckSpecializationInstantiationRedecl to check for redeclarations/instantiations. Also fixes a longstanding issue where our explicit-instantiation location information wasn't as good as it could have been. llvm-svn: 84216
* Make sure that we're diagnosing duplicate explicit instantiation definitions.Douglas Gregor2009-10-151-2/+8
| | | | llvm-svn: 84189
* Simplify checking of explicit template specialization/explicitDouglas Gregor2009-10-151-31/+25
| | | | | | | | | instantiation redeclaration semantics for function template specializations and member functions of class template specializations. Also, record the point of instantiation for explicit-instantiated functions and static data members. llvm-svn: 84188
* Check the interactions between explicit instantiations and templateDouglas Gregor2009-10-151-2/+198
| | | | | | | | specializations. Work in progress; there's more cleanup required to actually use the new CheckSpecializationInstantiationRedecl checker uniformly. llvm-svn: 84185
* Diagnose explicit instantiations of function templates and memberDouglas Gregor2009-10-151-4/+5
| | | | | | | | functions/static data members of class template specializations that do not have definitions. This is the latter part of [temp.explicit]p4; the former part still needs more testing. llvm-svn: 84182
* More explicit template instantiation. Now we're checking for moreDouglas Gregor2009-10-151-6/+14
| | | | | | | | cases where an explicit instantiation requires a definition; the remainder of these checks will come with the implementation of paragraph 4 of [temp.explicit]. llvm-svn: 84181
* CheckTemplateSpecializationScope isn't going to be used for explicitDouglas Gregor2009-10-141-46/+34
| | | | | | | instantiations, since the requirements are too different from those for template specializations. Simplify it slightly. llvm-svn: 84156
* Additional semantic checking for explicit template instantiations,Douglas Gregor2009-10-141-14/+128
| | | | | | | focusing on the scope- and qualifier-related semantic requirements in C++ [temp.explicit]p2. llvm-svn: 84154
* Reuse some code for checking the scope of an explicit instantiationDouglas Gregor2009-10-141-15/+10
| | | | llvm-svn: 84148
* Testing and some minor fixes for explicit template instantiation.Douglas Gregor2009-10-141-0/+13
| | | | llvm-svn: 84129
* When mapping from an injected-class-name to its correspondingDouglas Gregor2009-10-141-1/+1
| | | | | | | | template, make sure to get the template that corresponds to *this* declaration of the class template or specialization, rather than the canonical specialization. Fixes PR5187. llvm-svn: 84119
* Unify our diagnostic printing for errors of the form, "we didn't likeDouglas Gregor2009-10-131-8/+2
| | | | | | | | | | what we found when we looked into <blah>", where <blah> is a DeclContext*. We can now format DeclContext*'s in nice ways, e.g., "namespace N", "the global namespace", "'class Foo'". This is part of PR3990, but we're not quite there yet. llvm-svn: 84028
* When explicitly specializing a member that is a template, mark theDouglas Gregor2009-10-131-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | template as a specialization. For example, this occurs with: template<typename T> struct X { template<typename U> struct Inner { /* ... */ }; }; template<> template<typename T> struct X<int>::Inner { T member; }; We need to treat templates that are member specializations as special in two contexts: - When looking for a definition of a member template, we look through the instantiation chain until we hit the primary template *or a member specialization*. This allows us to distinguish between the primary "Inner" definition and the X<int>::Inner definition, above. - When computing all of the levels of template arguments needed to instantiate a member template, don't add template arguments from contexts outside of the instantiation of a member specialization, since the user has already manually substituted those arguments. Fix up the existing test for p18, which was actually wrong (but we didn't diagnose it because of our poor handling of member specializations of templates), and add a new test for member specializations of templates. llvm-svn: 83974
* Improve the internal representation and semantic analysis of friendDouglas Gregor2009-10-131-1/+10
| | | | | | | | | | | | | | | function templates. This commit ensures that friend function templates are constructed as FunctionTemplateDecls rather than partial FunctionDecls (as they previously were). It then implements template instantiation for friend function templates, injecting the friend function template only when no previous declaration exists at the time of instantiation. Oh, and make sure that explicit specialization declarations are not friends. llvm-svn: 83970
* When declaring a class template whose name is qualified, make sureDouglas Gregor2009-10-121-0/+3
| | | | | | | | that the scope in which it is being declared is complete. Also, when instantiating a member class template's ClassTemplateDecl, be sure to delay type creation so that the resulting type is dependent. Ick. llvm-svn: 83923
* Diagnose the declaration of explicit specializations after an implicitDouglas Gregor2009-10-121-11/+61
| | | | | | | instantiation has already been required. To do so, keep track of the point of instantiation for anything that can be instantiated. llvm-svn: 83890
* Qualified lookup through using declarations. Diagnose a new type of ambiguity.John McCall2009-10-101-3/+1
| | | | | | | Split the various ambiguous result enumerators into their own enum. Tests for most of C++ [namespace.qual]. llvm-svn: 83700
* Refactor the LookupResult API to simplify most common operations. Require ↵John McCall2009-10-091-18/+23
| | | | | | | | | users to pass a LookupResult reference to lookup routines. Call out uses which assume a single result. llvm-svn: 83674
* When declaring a friend class template, we may end up finding anDouglas Gregor2009-10-091-0/+16
| | | | | | | | injected-class-name (e.g., when we're referring to other specializations of the current class template). Make sure that we see the template rather than the injected-class-name. Fixes PR4768. llvm-svn: 83672
* Improve checking for specializations of member classes of classDouglas Gregor2009-10-081-10/+31
| | | | | | | | | | | templates, and keep track of how those member classes were instantiated or specialized. Make sure that we don't try to instantiate an explicitly-specialized member class of a class template, when that explicit specialization was a declaration rather than a definition. llvm-svn: 83547
* For instantiations of static data members of class templates, keepDouglas Gregor2009-10-081-29/+62
| | | | | | | | track of the kind of specialization or instantiation. Also, check the scope of the specialization and ensure that a specialization declaration without an initializer is not a definition. llvm-svn: 83533
* Make sure to set the template specialization kind of an explicitDouglas Gregor2009-10-081-5/+0
| | | | | | | template instantiation of a member function of a class template. FIXME -= 2; llvm-svn: 83520
* Keep track of whether a member function instantiated from a memberDouglas Gregor2009-10-071-3/+6
| | | | | | | | | function of a class template was implicitly instantiated, explicitly instantiated (declaration or definition), or explicitly specialized. The same MemberSpecializationInfo structure will be used for static data members and member classes as well. llvm-svn: 83509
* Type checking for specializations of member functions of classDouglas Gregor2009-10-071-8/+89
| | | | | | | | templates. Previously, these weren't handled as specializations at all. The AST for representing these as specializations is still a work in progress. llvm-svn: 83498
* Diagnose explicit instantiations and specializations that occur in class scopeDouglas Gregor2009-10-071-4/+6
| | | | llvm-svn: 83473
* Class template partial specializations can be declared anywhere thatDouglas Gregor2009-10-071-4/+12
| | | | | | | | | | its definition may be defined, including in a class. Also, put in an assertion when trying to instantiate a class template partial specialization of a member template, which is not yet implemented. llvm-svn: 83469
* Refactor checking of the scope of explicit template specializationDouglas Gregor2009-10-071-86/+147
| | | | | | | | | declarations and explicit template instantiations, improving diagnostics and making the code usable for function template specializations (as well as class template specializations and partial specializations). llvm-svn: 83436
* Test explicit specialization for all of the various cases whereDouglas Gregor2009-10-061-1/+1
| | | | | | | explicit specializations can occur. Also, fix a minor recovery bug where we should allow declarations coming from the parser to be NULL. llvm-svn: 83416
* Make sure to free the explicit template arguments provided for anDouglas Gregor2009-10-011-0/+1
| | | | | | | explicit instantiation. Also, tighten up reference-count checking to help catch these issues earlier. Fixes PR5069. llvm-svn: 83225
* Simplify the handling of non-dependent friend class templateDouglas Gregor2009-09-261-13/+32
| | | | | | | | | | | | specializations such as: friend class std::vector<int>; by using the same code path as explicit specializations, customized to reference an existing ClassTemplateSpecializationDecl (or build a new "undeclared" one). llvm-svn: 82875
* Fix name lookup for friend class templates to consider anything in aDouglas Gregor2009-09-261-13/+21
| | | | | | | scope *up to and including* the innermost namespace scope, rather than just searching in the innermost namespace scope. llvm-svn: 82849
OpenPOWER on IntegriCloud