summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* When we encounter a dependent type that was parsed before we know thatDouglas Gregor2009-08-061-0/+119
| | | | | | | | | | | | | | | | | | | | | | we were going to enter into the scope of a class template or class template partial specialization, rebuild that type so that it can refer to members of the current instantiation, as in code like template<typename T> struct X { typedef T* pointer; pointer data(); }; template<typename T> typename X<T>::pointer X<T>::data() { ... } Without rebuilding the return type of this out-of-line definition, the canonical return type of the out-of-line definition (a TypenameType) will not match the canonical return type of the declaration (the canonical type of T*). llvm-svn: 78316
* Canonicalize else.Mike Stump2009-08-041-7/+4
| | | | llvm-svn: 78102
* Refactor template instantiation for types into a generic treeDouglas Gregor2009-08-041-2/+0
| | | | | | | | | transformation template (TreeTransform) that handles the transformation and reconstruction of AST nodes. Template instantiation for types is a (relatively small) customization of the generic tree transformation. llvm-svn: 78071
* Rename Action::TagKind to Action::TagUseKind, which removes both a misnomerJohn McCall2009-07-311-10/+11
| | | | | | and a name collision. llvm-svn: 77658
* Make the check for the linkage of a template handle the case of nested Eli Friedman2009-07-311-6/+5
| | | | | | linkage specifications correctly. llvm-svn: 77653
* Support out-of-line definitions of the members of class templateDouglas Gregor2009-07-301-9/+44
| | | | | | partial specializations. llvm-svn: 77606
* Change uses of:Ted Kremenek2009-07-291-9/+9
| | | | | | | | | | | | | | | | | | | | Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsRecordType() -> Type::getAs<RecordType>() Type::getAsPointerType() -> Type::getAs<PointerType>() Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>() Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>() Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>() Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>() Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsTagType() -> Type::getAs<TagType>() And remove Type::getAsReferenceType(), etc. This change is similar to one I made a couple weeks ago, but that was partly reverted pending some additional design discussion. With Doug's pending smart pointer changes for Types, it seemed natural to take this approach. llvm-svn: 77510
* [llvm up]Douglas Gregor2009-07-291-4/+12
| | | | | | | | | A template name can refer to a set of overloaded function templates. Model this in TemplateName, which can now refer to an OverloadedFunctionDecl that contains function templates. This removes an unspeakable hack in Sema::isTemplateName. llvm-svn: 77488
* When lookup of an identifier preceding a '<' finds a set of overloadedDouglas Gregor2009-07-291-9/+35
| | | | | | | | functions, only return those overloaded functions that are actually function templates. Note that there is still a glaring problem with treating an OverloadedFunctionDecl as a TemplateName. llvm-svn: 77472
* Remove an obsolete kludge based on the previous, completely broken handling ↵Douglas Gregor2009-07-291-7/+2
| | | | | | of function templates llvm-svn: 77464
* Use the new statement/expression profiling code to unique dependentDouglas Gregor2009-07-291-4/+8
| | | | | | | | template arguments, as in template specialization types. This permits matching out-of-line definitions of members for class templates that involve non-type template parameters. llvm-svn: 77462
* Refactor the code that produces a TemplateSpecializationType, so thatDouglas Gregor2009-07-281-76/+7
| | | | | | | | canonicalization for dependent TemplateSpecializationTypes occurs within ASTContext::getTemplateSpecializationType. Also, move template argument canonicalization into ASTContext::getCanonicalTemplateArgument. llvm-svn: 77388
* Clean up the ActOnTag action, so that there is only a single entryDouglas Gregor2009-07-231-2/+2
| | | | | | | | | point that covers templates and non-templates. This should eliminate the flood of warnings I introduced yesterday. Removed the ActOnClassTemplate action, which is no longer used. llvm-svn: 76881
* Implement support for out-of-line definitions of the class members of classDouglas Gregor2009-07-221-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | templates, e.g., template<typename T> struct Outer { struct Inner; }; template<typename T> struct Outer<T>::Inner { // ... }; Implementing this feature required some extensions to ActOnTag, which now takes a set of template parameter lists, and is the precursor to removing the ActOnClassTemplate function from the parser Action interface. The reason for this approach is simple: the parser cannot tell the difference between a class template definition and the definition of a member of a class template; both have template parameter lists, and semantic analysis determines what that template parameter list means. There is still some cleanup to do with ActOnTag and ActOnClassTemplate. This commit provides the basic functionality we need, however. llvm-svn: 76820
* Fix some memory allocation/deallocation issuesDouglas Gregor2009-07-221-0/+1
| | | | llvm-svn: 76783
* Basic parsing and semantic analysis for out-of-line definitions of theDouglas Gregor2009-07-211-4/+121
| | | | | | | | | | | | | member functions of class templates, e.g., template<typename T> struct X { void f(T); }; template<typename T> X<T>::f(T) { /* ... */ } llvm-svn: 76692
* Add the location of the tag keyword into TagDecl. From EneaDouglas Gregor2009-07-211-1/+1
| | | | | | Zaffanella, with tweaks from Abramo Bagnara. llvm-svn: 76576
* Remove ASTContext::getCanonicalDecl() and use Decl::getCanonicalDecl in its ↵Argyrios Kyrtzidis2009-07-181-8/+12
| | | | | | place. llvm-svn: 76274
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-8/+8
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
* Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), ↵Ted Kremenek2009-07-171-2/+2
| | | | | | Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents. llvm-svn: 76139
* Replace Type::getAsReferenceType() with Type::getAs<ReferenceType>().Ted Kremenek2009-07-171-2/+2
| | | | llvm-svn: 76132
* Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.Ted Kremenek2009-07-161-4/+4
| | | | | | | | | | | | | | | | | | | | | This method is intended to eventually replace the individual Type::getAsXXXType<> methods. The motivation behind this change is twofold: 1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of them are basically copy-and-paste. 2) By centralizing the implementation of the getAs<Type> logic we can more smoothly move over to Doug Gregor's proposed canonical type smart pointer scheme. Along with this patch: a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>. b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>. llvm-svn: 76098
* Cope with explicitly-specified function template arguments when thereDouglas Gregor2009-07-011-4/+9
| | | | | | | are fewer template arguments than there are template parameters for that function. llvm-svn: 74578
* Preliminary parsing and ASTs for template-ids that refer to functionDouglas Gregor2009-06-301-0/+36
| | | | | | | templates, such as make<int&>. These template-ids are only barely functional for function calls; much more to come. llvm-svn: 74563
* De-ASTContext-ify DeclContext.Argyrios Kyrtzidis2009-06-301-3/+3
| | | | | | | Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating". Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit. llvm-svn: 74506
* Improved semantic analysis and AST respresentation for functionDouglas Gregor2009-06-251-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | templates. For example, this now type-checks (but does not instantiate the body of deref<int>): template<typename T> T& deref(T* t) { return *t; } void test(int *ip) { int &ir = deref(ip); } Specific changes/additions: * Template argument deduction from a call to a function template. * Instantiation of a function template specializations (just the declarations) from the template arguments deduced from a call. * FunctionTemplateDecls are stored directly in declaration contexts and found via name lookup (all forms), rather than finding the FunctionDecl and then realizing it is a template. This is responsible for most of the churn, since some of the core declaration matching and lookup code assumes that all functions are FunctionDecls. llvm-svn: 74213
* Implement matching of function templates, so that one can declare overloaded ↵Douglas Gregor2009-06-241-7/+9
| | | | | | function templates. C++ [temp.over.link] paragraphs 4-8. llvm-svn: 74079
* Make sure that the template parameter lists get from the parser down to ↵Douglas Gregor2009-06-241-0/+21
| | | | | | ActOnFunctionDeclarator for function template definitions llvm-svn: 74040
* When declaring a function template, create a FunctionTemplateDecl nodeDouglas Gregor2009-06-241-3/+4
| | | | | | and associate it with the FunctionDecl. llvm-svn: 74028
* Start propagating template parameter lists to the right places toDouglas Gregor2009-06-231-0/+7
| | | | | | | handle function templates. There's no actual code for function templates yet, but at least we complain about typedef templates. llvm-svn: 74021
* Check in a new template argument list builder that should work better for ↵Anders Carlsson2009-06-231-47/+45
| | | | | | variadic templates. llvm-svn: 73937
* Diagnose class members that shadow a template parameter. FixesDouglas Gregor2009-06-171-0/+3
| | | | | | | | | | <rdar://problem/6952203>. To do this, we actually remove a not-quite-correct optimization in the C++ name lookup routines. We'll revisit this optimization for the general case once more C++ is working. llvm-svn: 73659
* Support dependent extended vector types and template instantiationDouglas Gregor2009-06-171-1/+1
| | | | | | thereof. Patch by Anders Johnsen! llvm-svn: 73641
* More parameter pack work.Anders Carlsson2009-06-151-3/+3
| | | | llvm-svn: 73395
* Add a new 'Pack' argument kind to TemplateArgument. This is not yet used.Anders Carlsson2009-06-151-0/+13
| | | | llvm-svn: 73391
* Have CheckClassTemplatePartialSpecializationArgs take a ↵Anders Carlsson2009-06-131-8/+11
| | | | | | TemplateArgumentListBuilder. No functionality change. llvm-svn: 73297
* More work on type parameter packs.Anders Carlsson2009-06-131-3/+24
| | | | llvm-svn: 73281
* Move template type argument checking out into a separate function. No ↵Anders Carlsson2009-06-131-21/+29
| | | | | | functionality change. llvm-svn: 73275
* When some template parameters of a class template partialDouglas Gregor2009-06-131-2/+32
| | | | | | | specialization cannot be deduced, produce a warning noting that the affected class template partial specialization will never be used. llvm-svn: 73274
* A parameter pack must always come last in a class template.Anders Carlsson2009-06-121-1/+18
| | | | llvm-svn: 73269
* No need to mark the parameter as invalid, just ignore the default argument.Anders Carlsson2009-06-121-1/+0
| | | | llvm-svn: 73268
* Parameter packs can't have default arguments.Anders Carlsson2009-06-121-0/+9
| | | | llvm-svn: 73262
* Keep track of whether a type parameter is actually a type parameter pack.Anders Carlsson2009-06-121-1/+2
| | | | llvm-svn: 73261
* Finish implementing checking of class template partial specializationsDouglas Gregor2009-06-121-5/+11
| | | | llvm-svn: 73260
* Diagnose C++ [temp.class.spec]p9b3, where a class template partialDouglas Gregor2009-06-121-7/+81
| | | | | | | | | specialization's arguments are identical to the implicit template arguments of the primary template. Typically, this is meant to be a declaration/definition of the primary template, so we give that advice. llvm-svn: 73259
* Diagnose the incorrect use of non-type template arguments for classDouglas Gregor2009-06-121-0/+67
| | | | | | template partial specializations. llvm-svn: 73254
* Parse support for C++0x type parameter packs.Anders Carlsson2009-06-121-1/+2
| | | | llvm-svn: 73247
* Verify that the template parameters of a class template partialDouglas Gregor2009-06-121-4/+42
| | | | | | | specialization do not have default arguments (C++ [temp.class.spec]p10). llvm-svn: 73245
* Once we have deduced the template arguments of a class templateDouglas Gregor2009-06-111-45/+32
| | | | | | | | | | | | partial specialization, substitute those template arguments back into the template arguments of the class template partial specialization to see if the results still match the original template arguments. This code is more general than it needs to be, since we don't yet diagnose C++ [temp.class.spec]p9. However, it's likely to be needed for function templates. llvm-svn: 73196
* Add a null check that fixes the crash in PR4362, and make sure to ↵Anders Carlsson2009-06-111-3/+17
| | | | | | instantiate non-type template arguments. llvm-svn: 73193
OpenPOWER on IntegriCloud