summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Track source information for template arguments and template specializationJohn McCall2009-10-291-20/+43
| | | | | | | 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-32/+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
* Audit the code for places where it is assumed that every base specifier ↵Sebastian Redl2009-10-251-1/+1
| | | | | | refers to a RecordType. Add assertions or conditions as appropriate. This fixes another crash in the Apache stdlib vector. llvm-svn: 85055
* Store the builtin types as CanQualTypes. Expand a bit on the CanQual API,John McCall2009-10-231-3/+3
| | | | | | | but also remove some methods that cause ambiguities, and generally make CanQual<blah> more analogous to QualType. llvm-svn: 84976
* Canonicality is a property of qualified types, not unqualified types.John McCall2009-10-221-2/+2
| | | | llvm-svn: 84891
* Improve template argument deduction in the case where the parameterDouglas Gregor2009-09-301-7/+1
| | | | | | | | | type is a template-id (e.g., basic_ostream<CharT, Traits>) and the argument type is a class that has a derived class matching the parameter type. Previously, we were giving up on template argument deduction too early. llvm-svn: 83177
* WIP implementation of explicit instantiation of function templates,Douglas Gregor2009-09-251-0/+118
| | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Refactor the representation of qualifiers to bring ExtQualType out of theJohn McCall2009-09-241-24/+19
| | | | | | | | 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
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-5/+5
| | | | | | | | | | | 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
* Make the construction of the code-completion string for a functionDouglas Gregor2009-09-181-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | template smarter, by taking into account which function template parameters are deducible from the call arguments. For example, template<typename RandomAccessIterator> void sort(RandomAccessIterator first, RandomAccessIterator last); will have a code-completion string like sort({RandomAccessIterator first}, {RandomAccessIterator last}) since the template argument for its template parameter is deducible. On the other hand, template<class X, class Y> X* dyn_cast(Y *Val); will have a code-completion string like dyn_cast<{class X}>({Y *Val}) since the template type parameter X is not deducible from the function call. llvm-svn: 82306
* Add an assertion and a test case, in a fruitless attempt to track down an ↵Douglas Gregor2009-09-151-0/+3
| | | | | | existing bug llvm-svn: 81885
* Slightly improved template argument deduction for use in partialDouglas Gregor2009-09-151-1/+12
| | | | | | | 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-6/+70
| | | | | | (C++ [temp.class.order]). llvm-svn: 81866
* Refactor MarkDeductedTemplateParameters intoDouglas Gregor2009-09-141-67/+136
| | | | | | | | 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
* Tighten up checking of non-dependent arguments as part of templateDouglas Gregor2009-09-141-3/+13
| | | | | | | | | argument deduction. This fixes the new test case (since partial ordering does not have a "verify the results of deduction" step), and will allow failed template argument deductions to return more quickly for, e.g., matching class template partial specializations. llvm-svn: 81779
* Implement partial ordering of function template specializations Douglas Gregor2009-09-141-13/+258
| | | | | | (C++ [temp.func.order]). llvm-svn: 81777
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-272/+272
| | | | llvm-svn: 81346
* Tighten up the conversion from a single-level template argument listDouglas Gregor2009-08-281-11/+13
| | | | | | | | | | 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
* Clarify the difference between substitution and instantiation by renamingJohn McCall2009-08-251-13/+13
| | | | | | functions that don't instantiate definitions. llvm-svn: 80037
* Implement conversion function templates, along with the ability to useDouglas Gregor2009-08-211-1/+139
| | | | | | | template argument deduction from a conversion function (C++ [temp.deduct.conv]) with implicit conversions. llvm-svn: 79693
* Get rid of Stmt::Clone now that we can reference count statements instead.Anders Carlsson2009-08-081-2/+1
| | | | llvm-svn: 78452
* Change uses of:Ted Kremenek2009-07-291-6/+6
| | | | | | | | | | | | | | | | | | | | 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
* Fix the problems with template argument deduction and array types forDouglas Gregor2009-07-221-8/+65
| | | | | | | | real. It turns out that we need to actually move all of the qualifiers up to the array type itself, then recanonicalize the deduced template argument type. llvm-svn: 76788
* Canonicalize the types produced by template argument deduction.Douglas Gregor2009-07-221-1/+2
| | | | llvm-svn: 76777
* Improve template argument deduction for array types, so that a parameterDouglas Gregor2009-07-221-0/+8
| | | | | | | | | | const T can be matched with, e.g., volatile int [5] llvm-svn: 76773
* Remove ObjCQualifiedInterfaceType:-)Steve Naroff2009-07-181-1/+0
| | | | llvm-svn: 76321
* Remove ASTContext::getCanonicalDecl() and use Decl::getCanonicalDecl in its ↵Argyrios Kyrtzidis2009-07-181-4/+4
| | | | | | place. llvm-svn: 76274
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-6/+6
| | | | | | | | | 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-3/+3
| | | | | | 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-1/+1
| | | | llvm-svn: 76132
* Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.Ted Kremenek2009-07-161-2/+2
| | | | | | | | | | | | | | | | | | | | | 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
* Implement template argument deduction when taking the address of aDouglas Gregor2009-07-081-119/+295
| | | | | | | | function template. Most of the change here is in factoring out the common bits used for template argument deduction from a function call and when taking the address of a function template. llvm-svn: 75044
* Template argument deduction from a call has improved a bitDouglas Gregor2009-07-071-1/+1
| | | | llvm-svn: 74966
* Improve template argument deduction from a call. In particular,Douglas Gregor2009-07-071-76/+171
| | | | | | | | implement C++ [temp.deduct.call]p3b3, which allows a template-id parameter to match a derived class of the argument, while deducing template arguments. llvm-svn: 74965
* Keep track of more information within the template instantiation stack, e.g.,Douglas Gregor2009-07-011-2/+4
| | | | | | | | | | | | | | by distinguishing between substitution that occurs for template argument deduction vs. explicitly-specifiad template arguments. This is used both to improve diagnostics and to make sure we only provide SFINAE in those cases where SFINAE should apply. In addition, deal with the sticky issue where SFINAE only considers substitution of template arguments into the *type* of a function template; we need to issue hard errors beyond this point, as test/SemaTemplate/operator-template.cpp illustrates. llvm-svn: 74651
* Cope with explicitly-specified function template arguments when thereDouglas Gregor2009-07-011-7/+10
| | | | | | | are fewer template arguments than there are template parameters for that function. llvm-svn: 74578
* When explicit template arguments are provided for a function call,Douglas Gregor2009-06-301-16/+93
| | | | | | | | | substitute those template arguments into the function parameter types prior to template argument deduction. There's still a bit of work to do to make this work properly when only some of the template arguments are specified. llvm-svn: 74576
* Keep track of function template specializations, to eliminateDouglas Gregor2009-06-291-6/+14
| | | | | | | redundant, implicit instantiations of function templates and provide a place where we can hang function template specializations. llvm-svn: 74454
* Set the rest of the flags we need to perform template argumentDouglas Gregor2009-06-261-5/+28
| | | | | | | deduction using a base class of the argument type. No actual functionality change; this is just a hook. llvm-svn: 74356
* During template argument deduction from a function call, allowDouglas Gregor2009-06-261-28/+69
| | | | | | | | deduction from pointer and pointer-to-member types to work even in the presence of a qualification conversion (C++ [temp.deduct.type]p3 bullet 2). llvm-svn: 74354
* Template argument deduction is no longer responsible for checkingDouglas Gregor2009-06-261-32/+100
| | | | | | | | | | | | | non-dependent parameter types. Instead, class template partial specializations perform a final check of all of the instantiated arguments. This model is cleaner, and works better for function templates where the "final check" occurs during overload resolution. Also, cope with cv-qualifiers when the parameter type was originally a reference type, so that the deduced argument can be more qualified than the transformed argument. llvm-svn: 74323
* Improve template argument deduction for reference parameters whenDouglas Gregor2009-06-261-4/+42
| | | | | | | deducing template arguments from a function call. Plus, add a bunch of tests. llvm-svn: 74301
* Implicit instantiation for function template specializations.Douglas Gregor2009-06-261-0/+4
| | | | | | | | | For a FunctionDecl that has been instantiated due to template argument deduction, we now store the primary template from which it was instantiated and the deduced template arguments. From this information, we can instantiate the body of the function template. llvm-svn: 74232
* Improved semantic analysis and AST respresentation for functionDouglas Gregor2009-06-251-0/+156
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Check in a new template argument list builder that should work better for ↵Anders Carlsson2009-06-231-4/+4
| | | | | | variadic templates. llvm-svn: 73937
* Some cleanups suggested by ChrisDouglas Gregor2009-06-181-15/+15
| | | | llvm-svn: 73713
* First step toward fixing <rdar://problem/6613046> refactor clang objc type ↵Steve Naroff2009-06-171-1/+1
| | | | | | | | | | | | representation. Add a type (ObjCObjectPointerType) and remove a type (ObjCQualifiedIdType). This large/tedious patch is just a first step. Next step is to remove ObjCQualifiedInterfaceType. After that, I will remove the magic TypedefType for 'id' (installed by Sema). This work will enable various simplifications throughout clang (when dealing with ObjC types). No functionality change. llvm-svn: 73649
* Support dependent extended vector types and template instantiationDouglas Gregor2009-06-171-0/+8
| | | | | | thereof. Patch by Anders Johnsen! llvm-svn: 73641
* Since integral template arguments can't have dependent types we don't need ↵Anders Carlsson2009-06-161-32/+9
| | | | | | an extra pass to set the right APSInt bit width/signedness. llvm-svn: 73580
OpenPOWER on IntegriCloud