summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rip out TemplateIdRefExpr and make UnresolvedLookupExpr and John McCall2009-11-241-47/+1
| | | | | | | | | | | | DependentScopeDeclRefExpr support storing templateids. Unite the common code paths between ActOnDeclarationNameExpr and ActOnTemplateIdExpr. This gets us to a point where we don't need to store function templates in the AST using TemplateNames, which is critical to ripping out OverloadedFunction. Also resolves a few FIXMEs. llvm-svn: 89785
* Centralize and complete the computation of value- and type-dependence for ↵Douglas Gregor2009-11-231-3/+1
| | | | | | DeclRefExprs llvm-svn: 89649
* Reorganize the intermediate BuildDeclarationNameExpr routines again.John McCall2009-11-221-6/+10
| | | | llvm-svn: 89575
* Consider a FunctionTemplate to be an overload all on its lonesome. TrackJohn McCall2009-11-221-16/+7
| | | | | | this information through lookup rather than rederiving it. llvm-svn: 89570
* "Incremental" progress on using expressions, by which I mean totally rippingJohn McCall2009-11-211-44/+54
| | | | | | | | | | | | | | | | | | | | | | into pretty much everything about overload resolution in order to wean BuildDeclarationNameExpr off LookupResult::getAsSingleDecl(). Replace UnresolvedFunctionNameExpr with UnresolvedLookupExpr, which generalizes the idea of a non-member lookup that we haven't totally resolved yet, whether by overloading, argument-dependent lookup, or (eventually) the presence of a function template in the lookup results. Incidentally fixes a problem with argument-dependent lookup where we were still performing ADL even when the lookup results contained something from a block scope. Incidentally improves a diagnostic when using an ObjC ivar from a class method. This just fell out from rewriting BuildDeclarationNameExpr's interaction with lookup, and I'm too apathetic to break it out. The only remaining uses of OverloadedFunctionDecl that I know of are in TemplateName and MemberExpr. llvm-svn: 89544
* Instead of hanging a using declaration's target decls directly off the using John McCall2009-11-171-4/+40
| | | | | | | decl, create shadow declarations and put them in scope like normal. Work in progress. llvm-svn: 89048
* When instantiating a reference to a non-type template parameter of pointer toDouglas Gregor2009-11-121-2/+32
| | | | | | | | | member type (e.g., T Class::*Member), build a pointer-to-member constant expression. Previously, we we just building a simple declaration reference expression, which meant that the expression was not treated as a pointer to member. llvm-svn: 87000
* Improve diagnostics when a default template argument does not matchDouglas Gregor2009-11-111-46/+105
| | | | | | | | | | | | | | | | | | | | | | | | with its corresponding template parameter. This can happen when we performed some substitution into the default template argument and what we had doesn't match any more, e.g., template<int> struct A; template<typename T, template<T> class X = A> class B; B<long> b; Previously, we'd emit a pretty but disembodied diagnostic showing how the default argument didn't match the template parameter. The diagnostic was good, but nothing tied it to the *use* of the default argument in "B<long>". This commit fixes that. Also, tweak the counting of active template instantiations to avoid counting non-instantiation records, such as those we create for (surprise!) checking default arguments, instantiating default arguments, and performing substitutions as part of template argument deduction. llvm-svn: 86884
* Before checking a template template argument against its correspondingDouglas Gregor2009-11-111-8/+70
| | | | | | | | | | | | | | | | | | | | | | | template template parameter, substitute any prior template arguments into the template template parameter. This, for example, allows us to properly check the template template argument for a class such as: template<typename T, template<T Value> class X> struct Foo; The actual implementation of this feature was trivial; most of the change is dedicated to giving decent diagnostics when this substitution goes horribly wrong. We now get a note like: note: while substituting prior template arguments into template template parameter 'X' [with T = float] As part of this change, enabled some very pedantic checking when comparing template template parameter lists, which shook out a bug in our overly-eager checking of default arguments of template template parameters. We now perform only minimal checking of such default arguments when they are initially parsed. llvm-svn: 86864
* Introduce a new representation for template templateDouglas Gregor2009-11-111-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Improve instantiation of default template arguments for nestedDouglas Gregor2009-11-091-1/+10
| | | | | | | | | 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
* Special-case default argument expression in instantiation. This should fix ↵Sebastian Redl2009-11-081-0/+12
| | | | | | PR4301. Doug, please double-check my assumptions. Read the PR for more details. llvm-svn: 86465
* When performing template instantiation (transformation) ofDouglas Gregor2009-11-041-6/+10
| | | | | | | | | expressions, keep track of whether we are immediately taking the address of the expression. Pass this flag when building a declaration name expression so that we handle pointer-to-member constants properly. llvm-svn: 86017
* Implement "incremental" template instantiation for non-type templateDouglas Gregor2009-10-311-49/+50
| | | | | | | | | | | | | | | parameters and template type parameters, which occurs when substituting into the declarations of member templates inside class templates. This eliminates errors about our inability to "reduce non-type template parameter depth", fixing PR5311. Also fixes a bug when instantiating a template type parameter declaration in a member template, where we weren't properly reducing the template parameter's depth. LLVM's StringSwitch header now parses. llvm-svn: 85669
* Track source information for template arguments and template specializationJohn McCall2009-10-291-3/+4
| | | | | | | 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-47/+58
| | | | | | | | 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-34/+88
| | | | | | | | | 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-12/+19
| | | | | | | | | | 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-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Clone Sema::SubstType for DeclaratorInfos.John McCall2009-10-211-0/+16
| | | | llvm-svn: 84724
* Rewrite TreeTransform to transform types as DeclaratorInfos rather than as bareJohn McCall2009-10-211-11/+26
| | | | | | QualTypes. Don't actually exploit this yet. llvm-svn: 84716
* Handle substitutions into the "first qualifier in scope" of aDouglas Gregor2009-10-201-0/+29
| | | | | | | qualified member access expression (e.g., t->U::member) when that first qualifier refers to a template parameters. llvm-svn: 84612
* When performing template-substitution into a type, don't just replace theJohn McCall2009-10-181-1/+5
| | | | | | | | | | | | | | | | | | TemplateTypeParmType with the substituted type directly; instead, replace it with a SubstTemplateTypeParmType which will note that the type was originally written as a template type parameter. This makes it reasonable to preserve source information even through template substitution. Also define the new SubstTemplateTypeParmType class, obviously. For consistency with current behavior, we stringize these types as if they were the underlying type. I'm not sure this is the right thing to do. At any rate, I paled at adding yet another clause to the don't-desugar 'if' statement, so I extracted a function to do it. The new function also does The Right Thing more often, I think: e.g. if we have a chain of typedefs leading to a vector type, we will now desugar all but the last one. llvm-svn: 84412
* Improve point-of-instantiation location information for members of class ↵Douglas Gregor2009-10-151-2/+2
| | | | | | templates llvm-svn: 84217
* Check the interactions between explicit instantiations and templateDouglas Gregor2009-10-151-0/+7
| | | | | | | | specializations. Work in progress; there's more cleanup required to actually use the new CheckSpecializationInstantiationRedecl checker uniformly. llvm-svn: 84185
* Testing and some minor fixes for explicit template instantiation.Douglas Gregor2009-10-141-2/+5
| | | | llvm-svn: 84129
* When explicitly specializing a member that is a template, mark theDouglas Gregor2009-10-131-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 checking for specializations of member classes of classDouglas Gregor2009-10-081-4/+19
| | | | | | | | | | | 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-3/+6
| | | | | | | | 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-3/+3
| | | | | | | 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-4/+11
| | | | | | | | | 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
* Slightly improve the semantics of extern templates for member functions of ↵Douglas Gregor2009-09-291-2/+3
| | | | | | class templates llvm-svn: 83063
* Refactor the representation of qualifiers to bring ExtQualType out of theJohn McCall2009-09-241-1/+1
| | | | | | | | Type hierarchy. Demote 'volatile' to extended-qualifier status. Audit our use of qualifiers and fix a few places that weren't dealing with qualifiers quite right; many more remain. llvm-svn: 82705
* Teach Sema::FindInstantiatedDecl to find instantiated RecordDecls evenDouglas Gregor2009-09-161-3/+4
| | | | | | | | | | when we are not instantiating the corresponding "current instantiation." This happens, e.g., when we are instantiating a declaration reference that refers into the "current instantiation" but occurs in a default function argument. The libstdc++ vector default constructor now instantiates properly. llvm-svn: 82069
* Slightly improved template argument deduction for use in partialDouglas Gregor2009-09-151-0/+3
| | | | | | | ordering, along with another test case for partial ordering of partial specializations. llvm-svn: 81869
* Implement partial ordering of class template partial specializations Douglas Gregor2009-09-151-10/+43
| | | | | | (C++ [temp.class.order]). llvm-svn: 81866
* Slight improvement for extern templates, so that an explicitDouglas Gregor2009-09-111-4/+21
| | | | | | | | | instantiation definition can follow an explicit instantiation declaration. This is as far as I want to go with extern templates now, but they will still need quite a bit more work to get all of the C++0x semantics right. llvm-svn: 81573
* Track a class template specialization's point of instantiation separatelyJohn McCall2009-09-111-1/+1
| | | | | | | | | | from its location. Initialize appropriately. When implicitly creating a declaration of a class template specialization after encountering the first reference to it, use the pattern class's location instead of the location of the first reference. llvm-svn: 81515
* Support elaborated dependent types and diagnose tag mismatches.John McCall2009-09-111-1/+31
| | | | llvm-svn: 81504
* Instantiate PredefinedExprs correctly. Patch by Sam Weinig!Anders Carlsson2009-09-111-0/+24
| | | | llvm-svn: 81498
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-110/+109
| | | | llvm-svn: 81346
* Report errors for member functions correctly.Anders Carlsson2009-09-051-2/+1
| | | | llvm-svn: 81063
* Use a separate diagnostic for default function argument expressions.Anders Carlsson2009-09-051-0/+43
| | | | llvm-svn: 81062
* Improve the AST representation and semantic analysis for externDouglas Gregor2009-09-041-17/+21
| | | | | | | | | | | templates. We now distinguish between an explicit instantiation declaration and an explicit instantiation definition, and know not to instantiate explicit instantiation declarations. Unfortunately, there is some remaining confusion w.r.t. instantiation of out-of-line member function definitions that causes trouble here. llvm-svn: 81053
* Improve template instantiation for member access expressions thatDouglas Gregor2009-09-031-3/+5
| | | | | | | | | involve qualified names, e.g., x->Base::f. We now maintain enough information in the AST to compare the results of the name lookup of "Base" in the scope of the postfix-expression (determined at template definition time) and in the type of the object expression. llvm-svn: 80953
* Implement proper substitution for OverloadedFunctionDecls, but substituting ↵Douglas Gregor2009-09-011-8/+0
| | | | | | each of the functions in the overload set llvm-svn: 80692
* Improve instantiation of UnresolvedUsingDecls.Anders Carlsson2009-08-291-0/+7
| | | | llvm-svn: 80434
* Ensure code generation for friend declarations in class templates.John McCall2009-08-291-5/+13
| | | | llvm-svn: 80418
* Implement template instantiation for member class templates.Douglas Gregor2009-08-281-102/+87
| | | | | | | | | | When performing template instantiation of the definitions of member templates (or members thereof), we build a data structure containing the template arguments from each "level" of template instantiation. During template instantiation, we substitute all levels of template arguments simultaneously. llvm-svn: 80389
* Collect multiple levels of template arguments into a new type,Douglas Gregor2009-08-281-21/+30
| | | | | | | MultiLevelTemplateArgumentList. This is a baby step toward instantiating member templates; no intended functionality change yet. llvm-svn: 80380
OpenPOWER on IntegriCloud