summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateDeduction.cpp
Commit message (Collapse)AuthorAgeFilesLines
* After dyn_cast'ing, it generally makes sense to check the *output* ofDouglas Gregor2010-01-141-1/+1
| | | | | | the dyn_cast against NULL rather than the *input*. Fixes PR6025. llvm-svn: 93435
* When resolving a single function template specialization to aDouglas Gregor2010-01-111-1/+4
| | | | | | | function, be sure to adjust the resulting argument type to a pointer (if necessary). Fixes PR5910 and PR5949. llvm-svn: 93178
* Implement name lookup for conversion function template specializationsDouglas Gregor2010-01-111-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | (C++ [temp.mem]p5-6), which involves template argument deduction based on the type named, e.g., given struct X { template<typename T> operator T*(); } x; when we call x.operator int*(); we perform template argument deduction to determine that T=int. This template argument deduction is needed for template specialization and explicit instantiation, e.g., template<> X::operator float*() { /* ... */ } and when calling or otherwise naming a conversion function (as in the first example). This fixes PR5742 and PR5762, although there's some remaining ugliness that's causing out-of-line definitions of conversion function templates to fail. I'll look into that separately. llvm-svn: 93162
* Make sure to use ASTContext::getAs*ArrayType() when decomposing arrayDouglas Gregor2010-01-041-2/+2
| | | | | | types. Fixes APFloat.cpp compilation failure. llvm-svn: 92523
* More fixes to the handling of CVR-comparisons on array types. Adds a method toChandler Carruth2009-12-301-3/+5
| | | | | | | | | | | | QualType to get CVR-qualifiers through array types, and switches the primary comparison methods to use it. This may allow simplifying some of the callers of getUnqualifiedArrayType. Also fix the normalizing of CV-qualification during template deduction to normalize through arrays and allow a more qualified deduced array type. This fixes PR5911. llvm-svn: 92289
* Correctly refer to element CVR qualifications when determining if a type isChandler Carruth2009-12-291-53/+1
| | | | | | | | | | more or less cv-qualified than another during implicit conversion and overload resolution ([basic.type.qualifier] p5). Factors the logic out of template deduction and into the ASTContext so it can be shared. This fixes several aspects of PR5542, but not all of them. llvm-svn: 92248
* Get rid of FixedWidthIntType, as suggested by Chris and Eli.Anders Carlsson2009-12-291-1/+0
| | | | llvm-svn: 92246
* When a template-id refers to a single function template, and theDouglas Gregor2009-12-211-22/+69
| | | | | | | | | | explicitly-specified template arguments are enough to determine the instantiation, and either template argument deduction fails or is not performed in that context, we can resolve the template-id down to a function template specialization (so sayeth C++0x [temp.arg.explicit]p3). Fixes PR5811. llvm-svn: 91852
* Introduce an assertion to ensure that template argument deduction doesDouglas Gregor2009-12-211-1/+1
| | | | | | | | | not deduce an "overload" type. Such a deduction indicates a failure in semantic analysis (e.g., PR5811) that currently isn't caught until code-generation time. This assertions makes it clearer that this particular issue is a semantic-analysis problem, not a code-gen problem. llvm-svn: 91844
* Fix "using typename" and the instantiation of non-dependent using declarations.John McCall2009-12-041-0/+1
| | | | llvm-svn: 90614
* Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.Benjamin Kramer2009-11-281-1/+0
| | | | llvm-svn: 90044
* Implement support for default template arguments of function templates.Douglas Gregor2009-11-251-15/+41
| | | | llvm-svn: 89874
* Encapsulate "an array of TemplateArgumentLocs and two angle bracket ↵John McCall2009-11-231-32/+19
| | | | | | | | | | locations" into a new class. Use it pervasively throughout Sema. My fingers hurt. llvm-svn: 89638
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sugared types. The basic problem is that our qualifier accessors (getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at the current QualType and not at any qualifiers that come from sugared types, meaning that we won't see these qualifiers through, e.g., typedefs: typedef const int CInt; typedef CInt Self; Self.isConstQualified() currently returns false! Various bugs (e.g., PR5383) have cropped up all over the front end due to such problems. I'm addressing this problem by splitting each qualifier accessor into two versions: - the "local" version only returns qualifiers on this particular QualType instance - the "normal" version that will eventually combine qualifiers from this QualType instance with the qualifiers on the canonical type to produce the full set of qualifiers. This commit adds the local versions and switches a few callers from the "normal" version (e.g., isConstQualified) over to the "local" version (e.g., isLocalConstQualified) when that is the right thing to do, e.g., because we're printing or serializing the qualifiers. Also, switch a bunch of Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType() expressions over to Context.hasSameUnqualifiedType(T1, T2) llvm-svn: 88969
* Revert r88718, which does NOT solve the ↵Douglas Gregor2009-11-131-1/+1
| | | | | | constructor-template-as-copy-constructor issue. Big thanks to John for finding this llvm-svn: 88724
* Template argument deduction of a non-type template parameter from aDouglas Gregor2009-11-131-2/+41
| | | | | | template argument. llvm-svn: 88722
* A constructor template cannot be instantiated to a copyDouglas Gregor2009-11-131-1/+1
| | | | | | constructor. Make sure that such declarations can never be formed. llvm-svn: 88718
* Template argument deduction for template template parameters. ThisDouglas Gregor2009-11-111-43/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | permits, among other things, ripping apart and reconstructing templates via partial specialization: template<typename T> struct DeepRemoveConst { typedef T type; }; template<typename T> struct DeepRemoveConst<const T> { typedef typename DeepRemoveConst<T>::type type; }; template<template<typename> class TT, typename T> struct DeepRemoveConst<TT<T> > { typedef TT<typename DeepRemoveConst<T>::type> type; }; Also, fix a longstanding thinko in the code handling partial ordering of class template partial specializations. We were performing the second deduction without clearing out the results of the first deduction. It's amazing we got through so much code with such a horrendous error :( llvm-svn: 86893
* Introduce a new representation for template templateDouglas Gregor2009-11-111-25/+44
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
OpenPOWER on IntegriCloud