summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rework the Parse-Sema interaction for friends to better support friendDouglas Gregor2009-09-261-14/+26
| | | | | | | | | class templates. We now treat friend class templates much more like normal class templates, except that they still get special name lookup rules. Fixes PR5057 and eliminates a bunch of spurious diagnostics in <iostream>. llvm-svn: 82848
* Use Sema::getMostSpecialized to eliminate a redundant implementation of the ↵Douglas Gregor2009-09-261-58/+11
| | | | | | most-specialized function template llvm-svn: 82840
* Use explicitly-specified template argument lists to help namingDouglas Gregor2009-09-251-6/+5
| | | | | | explicit template specializations, when available. llvm-svn: 82824
* Declarators can now properly represent template-ids, e.g., forDouglas Gregor2009-09-251-9/+25
| | | | | | | | | | | template void f<int>(int); ~~~~~~ Previously, we silently dropped the template arguments. With this change, we now use the template arguments (when available) as the explicitly-specified template arguments used to aid template argument deduction for explicit template instantiations. llvm-svn: 82806
* WIP implementation of explicit instantiation of function templates,Douglas Gregor2009-09-251-0/+175
| | | | | | | | member functions of class template specializations, and static data members. The mechanics are (mostly) present, but the semantic analysis is very weak. llvm-svn: 82789
* WIP implementation of explicit function template specialization. ThisDouglas Gregor2009-09-241-0/+160
| | | | | | | | | | | | | | | | | | | | | first implementation recognizes when a function declaration is an explicit function template specialization (based on the presence of a template<> header), performs template argument deduction + ambiguity resolution to determine which template is being specialized, and hooks There are many caveats here: - We completely and totally drop any explicitly-specified template arguments on the floor - We don't diagnose any of the extra semantic things that we should diagnose. - I haven't looked to see that we're getting the right linkage for explicit specializations On a happy note, this silences a bunch of errors that show up in libstdc++'s <iostream>, although Clang still can't get through the entire header. llvm-svn: 82728
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-3/+3
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* Fix a typo in a FIXMEDouglas Gregor2009-09-161-1/+1
| | | | llvm-svn: 81960
* Implement partial ordering of class template partial specializations Douglas Gregor2009-09-151-2/+78
| | | | | | (C++ [temp.class.order]). llvm-svn: 81866
* Skeletal support for friend class templates.John McCall2009-09-141-9/+31
| | | | llvm-svn: 81801
* Refactor MarkDeductedTemplateParameters intoDouglas Gregor2009-09-141-1/+2
| | | | | | | | MarkUsedTemplateParameters, which is able to mark template parameters used within non-deduced contexts as well as deduced contexts. Use this to finish the implementation of [temp.deduct.partial]p11. llvm-svn: 81794
* Slight improvement for extern templates, so that an explicitDouglas Gregor2009-09-111-12/+24
| | | | | | | | | 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/+3
| | | | | | | | | | 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-2/+29
| | | | llvm-svn: 81504
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-364/+362
| | | | llvm-svn: 81346
* Initial stab at implement dependent member references to memberDouglas Gregor2009-09-091-6/+1
| | | | | | | | | | | | | templates, e.g., x.template get<T> We can now parse these, represent them within an UnresolvedMemberExpr expression, then instantiate that expression node in simple cases. This allows us to stumble through parsing LLVM's Casting.h. llvm-svn: 81300
* Support templateids in friend declarations. Fixes bug 4859.John McCall2009-09-081-17/+27
| | | | llvm-svn: 81233
* Improve the AST representation and semantic analysis for externDouglas Gregor2009-09-041-6/+14
| | | | | | | | | | | 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
* Parse extern templates, pass that information all the way to Sema,Douglas Gregor2009-09-041-2/+8
| | | | | | then drop it on the floor. llvm-svn: 80989
* Correctly handle elaborated template ids. Still not handled properly for ↵John McCall2009-09-041-1/+24
| | | | | | friends. llvm-svn: 80977
* Rewrite of our handling of name lookup in C++ member access expressions, e.g.,Douglas Gregor2009-09-021-114/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | x->Base::f We no longer try to "enter" the context of the type that "x" points to. Instead, we drag that object type through the parser and pass it into the Sema routines that need to know how to perform lookup within member access expressions. We now implement most of the crazy name lookup rules in C++ [basic.lookup.classref] for non-templated code, including performing lookup both in the context of the type referred to by the member access and in the scope of the member access itself and then detecting ambiguities when the two lookups collide (p1 and p4; p3 and p7 are still TODO). This change also corrects our handling of name lookup within template arguments of template-ids inside the nested-name-specifier (p6; we used to look into the scope of the object expression for them) and fixes PR4703. I have disabled some tests that involve member access expressions where the object expression has dependent type, because we don't yet have the ability to describe dependent nested-name-specifiers starting with an identifier. llvm-svn: 80843
* Document how we intepret C++ DR 382Douglas Gregor2009-09-021-0/+6
| | | | llvm-svn: 80785
* When parsing typename specifiers (with either the identifier orDouglas Gregor2009-09-021-7/+11
| | | | | | | | | | | | simple-template-id form), check whether the scope specifier is computable as a declaration context rather than checking whether it is dependent, so that we properly cope with members of the current instantiation. Improve testing for typename specifiers that terminate in a simpe-template-id. llvm-svn: 80783
* Preliminary AST representation and semantic analysis forDouglas Gregor2009-09-011-0/+35
| | | | | | | | | explicitly-specified template argument lists in member reference expressions, e.g., x->f<int>() llvm-svn: 80646
* Test instantiation of static data members that live within nestedDouglas Gregor2009-08-281-3/+0
| | | | | | member templates. llvm-svn: 80396
* Tighten up the conversion from a single-level template argument listDouglas Gregor2009-08-281-1/+2
| | | | | | | | | | to a multi-level template argument list by making it explicit. The forced auditing of callers found a bug in the instantiation of member classes inside member templates. I *love* static type systems. llvm-svn: 80391
* Implement template instantiation for member class templates.Douglas Gregor2009-08-281-3/+5
| | | | | | | | | | 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
* Improve support for out-of-line definitions of nested templates andDouglas Gregor2009-08-251-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | their members, including member class template, member function templates, and member classes and functions of member templates. To actually parse the nested-name-specifiers that qualify the name of an out-of-line definition of a member template, e.g., template<typename X> template<typename Y> X Outer<X>::Inner1<Y>::foo(Y) { return X(); } we need to look for the template names (e.g., "Inner1") as a member of the current instantiation (Outer<X>), even before we have entered the scope of the current instantiation. Since we can't do this in general (i.e., we should not be looking into all dependent nested-name-specifiers as if they were the current instantiation), we rely on the parser to tell us when it is parsing a declaration specifier sequence, and, therefore, when we should consider the current scope specifier to be a current instantiation. Printing of complicated, dependent nested-name-specifiers may be somewhat broken by this commit; I'll add tests for this issue and fix the problem (if it still exists) in a subsequent commit. llvm-svn: 80044
* Clarify the difference between substitution and instantiation by renamingJohn McCall2009-08-251-13/+13
| | | | | | functions that don't instantiate definitions. llvm-svn: 80037
* Implement out-of-line definitions of nested class templates. Most ofDouglas Gregor2009-08-251-79/+66
| | | | | | | | | the logic is there for out-of-line definitions with multiple levels of nested templates, but this is still a work-in-progress: we're having trouble determining when we should look into a dependent nested-name-specifier. llvm-svn: 80003
* Use Sema's LocInfoType to pass and preserve type source info through the Parser.Argyrios Kyrtzidis2009-08-191-3/+6
| | | | llvm-svn: 79395
* Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema ↵Argyrios Kyrtzidis2009-08-191-2/+3
| | | | | | | | | | | | interfaces. DeclaratorDecl contains a DeclaratorInfo* to keep type source info. Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl. EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo. Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet. llvm-svn: 79392
* Add newline at end of file.Benjamin Kramer2009-08-111-1/+1
| | | | llvm-svn: 78735
* 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
OpenPOWER on IntegriCloud