summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Use attributes for all the override control specifiers.Anders Carlsson2011-01-241-3/+0
| | | | llvm-svn: 124122
* Mark classes final and/or explicit during class template instantiation.Anders Carlsson2011-01-221-0/+3
| | | | llvm-svn: 124040
* Implement support for non-type template parameter packs whose type isDouglas Gregor2011-01-191-6/+29
| | | | | | | | | | | | | | | | | | | | | a pack expansion, e.g., the parameter pack Values in: template<typename ...Types> struct Outer { template<Types ...Values> struct Inner; }; This new implementation approach introduces the notion of an "expanded" non-type template parameter pack, for which we have already expanded the types of the parameter pack (to, say, "int*, float*", for Outer<int*, float*>) but have not yet expanded the values. Aside from creating these expanded non-type template parameter packs, this patch updates template argument checking and non-type template parameter pack instantiation to make use of the appropriate types in the parameter pack. llvm-svn: 123845
* Change QualType::getTypePtr() to return a const pointer, then change aJohn McCall2011-01-191-1/+1
| | | | | | thousand other things which were (generally inadvertantly) relying on that. llvm-svn: 123814
* Introduce a new kind of TemplateName that captures a substitutedDouglas Gregor2011-01-151-6/+59
| | | | | | | | | | | | | | | template template parameter pack that cannot be fully expanded because its enclosing pack expansion could not be expanded. This form of TemplateName plays the same role as SubstTemplateTypeParmPackType and SubstNonTypeTemplateParmPackExpr do for template type parameter packs and non-type template parameter packs, respectively. We should now handle these multi-level pack expansion substitutions anywhere. The largest remaining gap in our variadic-templates support is that we cannot cope with non-type template parameter packs whose type is a pack expansion. llvm-svn: 123521
* Introduce a new expression kind, SubstNonTypeTemplateParmPackExpr,Douglas Gregor2011-01-151-4/+52
| | | | | | | | | that captures the substitution of a non-type template argument pack for a non-type template parameter pack within a pack expansion that cannot be fully expanded. This follows the approach taken by SubstTemplateTypeParmPackType. llvm-svn: 123506
* Teach template template argument pack expansions to keep track of theDouglas Gregor2011-01-141-4/+1
| | | | | | | number of expansions, when we know it, and propagate that information through Sema. llvm-svn: 123493
* Handle substitutions into function parameter packs whose patternsDouglas Gregor2011-01-141-6/+9
| | | | | | contain multiple parameter packs at different levels. llvm-svn: 123488
* Keep track of the number of expansions to be produced from a type packDouglas Gregor2011-01-141-4/+6
| | | | | | | | | | | | | | | | | | | | | | | expansion, when it is known due to the substitution of an out parameter pack. This allows us to properly handle substitution into pack expansions that involve multiple parameter packs at different template parameter levels, even when this substitution happens one level at a time (as with partial specializations of member class templates and the signatures of member function templates). Note that the diagnostic we provide when there is an arity mismatch between an outer parameter pack and an inner parameter pack in this case isn't as clear as the normal diagnostic for an arity mismatch. However, this doesn't matter because these cases are very, very rare and (even then) only typically occur in a SFINAE context. The other kinds of pack expansions (expression, template, etc.) still need to support optional tracking of the number of expansions, and we need the moral equivalent of SubstTemplateTypeParmPackType for substituted argument packs of template template and non-type template parameters. llvm-svn: 123448
* Start implementing support for substitution into pack expansions thatDouglas Gregor2011-01-141-4/+41
| | | | | | | | | | | | | | | | | involve template parameter packs at multiple template levels that occur within the signatures members of class templates (and partial specializations thereof). This is a work-in-progress that is deficient in several ways, notably: - It only works for template type parameter packs, but we need to also support non-type template parameter packs and template template parameter packs. - It doesn't keep track of the lengths of the substituted argument packs in the expansion, so it can't properly diagnose length mismatches. However, this is a concrete step in the right direction. llvm-svn: 123425
* Work-in-progress implementation of C++0x [temp.arg.explicit]p9, whichDouglas Gregor2011-01-101-3/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | allows an argument pack determines via explicit specification of function template arguments to be extended by further, deduced arguments. For example: template<class ... Types> void f(Types ... values); void g() { f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int } There are a number of FIXMEs in here that indicate places where we need to implement + test retained expansions, plus a number of other places in deduction where we need to correctly cope with the explicitly-specified arguments when deducing an argument pack. Furthermore, it appears that the RecursiveASTVisitor needs to be auditied; it's missing some traversals (especially w.r.t. template arguments) that cause it not to find unexpanded parameter packs when it should. The good news, however, is that the tr1::tuple implementation now works fully, and the tr1::bind example (both from N2080) is actually working now. llvm-svn: 123163
* When instantiating the arguments to an initializer, use theDouglas Gregor2011-01-071-0/+12
| | | | | | | TreeTransform version of TransformExprs() rather than explicit loop, so that we expand pack expansions properly. Test cast coming soon... llvm-svn: 123014
* Implement substitution of a function parameter pack for its set ofDouglas Gregor2011-01-071-12/+46
| | | | | | | | | | | | | | | | | | | | | | | | instantiated function parameters, enabling instantiation of arbitrary pack expansions involving function parameter packs. At this point, we can now correctly compile a simple, variadic print() example: #include <iostream> #include <string> void print() {} template<typename Head, typename ...Tail> void print(const Head &head, const Tail &...tail) { std::cout << head; print(tail...); } int main() { std::string hello = "Hello"; print(hello, ", world!", " ", 2011, '\n'); } llvm-svn: 123000
* Factor out the template transformation of a sequence of functionDouglas Gregor2011-01-071-0/+17
| | | | | | | | | parameters into parameter types, so that substitution of explicitly-specified function template arguments uses the same path. This enables the use of explicitly-specified function template arguments with variadic templates. llvm-svn: 122986
* Initial implementation of function parameter packs. This implementation allows:Douglas Gregor2011-01-051-3/+63
| | | | | | | | | | | | | | 1) Declaration of function parameter packs 2) Instantiation of function parameter packs within function types. 3) Template argument deduction of function parameter packs when matching two function types. We're missing all of the important template-instantiation logic for function template definitions, along with template argument deduction from the argument list of a function call, so don't even think of trying to use these for real yet. llvm-svn: 122926
* hasInit() -> hasDefaultArg()Douglas Gregor2011-01-051-1/+1
| | | | llvm-svn: 122905
* Implement support for template template parameter packs, e.g.,Douglas Gregor2011-01-051-3/+16
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* Improve our handling of non-type template parameters in partialDouglas Gregor2011-01-041-7/+20
| | | | | | | | | | | | | specializations. We weren't dealing with any of the cases where the type of the non-type template argument differs from the type of the corresponding template parameter in the primary template. We would think that the template parameter in the partial specialization was not deducible (and warn about it, incorrectly), then fail to convert a deduced parameter to the type of the template parameter in the partial specialization (which may involve truncation, among other things). Fixes PR8905. llvm-svn: 122851
* Implement pack expansion of base initializers, so that we canDouglas Gregor2011-01-041-1/+1
| | | | | | | initialize those lovely mixins that come from pack expansions of base specifiers. llvm-svn: 122793
* Implement pack expansions whose pattern is a base-specifier.Douglas Gregor2011-01-031-1/+54
| | | | llvm-svn: 122782
* When instantiating a non-type template parameter pack, be sure toDouglas Gregor2010-12-241-4/+14
| | | | | | | | extract the appropriate argument from the argument pack (based on the current substitution index, of course). Simple instantiation of pack expansions involving non-type template parameter packs now works. llvm-svn: 122532
* Implement template argument deduction for pack expansions whoseDouglas Gregor2010-12-221-3/+4
| | | | | | | | | | | pattern is a template argument, which involves repeatedly deducing template arguments using the pattern of the pack expansion, then bundling the resulting deductions into an argument pack. We can now handle a variety of simple list-handling metaprograms using variadic templates. See, e.g., the new "count" metaprogram. llvm-svn: 122439
* When searching for the instantiation of a locally-scoped tagDouglas Gregor2010-12-211-5/+15
| | | | | | | declaration, also look for an instantiation of its previous declarations. Fixes PR8801. llvm-svn: 122361
* Implement instantiation of pack expansions whose pattern is a type-idDouglas Gregor2010-12-211-74/+8
| | | | | | in an exception specification. llvm-svn: 122297
* Handle instantiation of template type parameter packs that occur asDouglas Gregor2010-12-201-2/+18
| | | | | | | the first qualifier in scope. We can't adequately test this test, unfortunately. llvm-svn: 122283
* Implement basic support for template instantiation of pack expansionsDouglas Gregor2010-12-201-5/+102
| | | | | | | | | | | | | | | | | whose patterns are template arguments. We can now instantiate, e.g., typedef tuple<pair<OuterTypes, InnerTypes>...> type; where OuterTypes and InnerTypes are template type parameter packs. There is a horrible inefficiency in TemplateArgumentLoc::getPackExpansionPattern(), where we need to create copies of TypeLoc data because our interfaces traffic in TypeSourceInfo pointers where they should traffic in TypeLocs instead. I've isolated in efficiency in this one routine; once we refactor our interfaces to traffic in TypeLocs, we can eliminate it. llvm-svn: 122278
* Added missing IgnoreParens().Abramo Bagnara2010-12-141-1/+1
| | | | llvm-svn: 121795
* A bundle of whitespace changes, separated out from the functional changes.Nick Lewycky2010-11-201-1/+1
| | | | llvm-svn: 119886
* Refactoring of Diagnostic class.Argyrios Kyrtzidis2010-11-181-13/+11
| | | | | | | | | | | -Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class. -DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units. -The rest of the state in Diagnostic object is considered related and tied to one translation unit. -Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a SourceLocation instead of a FullSourceLoc. -Reflect the changes to various interfaces. llvm-svn: 119730
* Replace one hack with a different hack: strip out the ObjectTypeJohn McCall2010-11-121-10/+6
| | | | | | | | | parameters to the Transform*Type functions and instead call out the specific cases where an object type and the unqualified lookup results are important. Fixes an assert and failed compile on a testcase from PR7248. llvm-svn: 118887
* Instantiate class member template partial specialization declarationsDouglas Gregor2010-11-101-2/+23
| | | | | | | | | in the order they occur within the class template, delaying out-of-line member template partial specializations until after the class has been fully instantiated. This fixes a regression introduced by r118454 (itself a fix for PR8001). llvm-svn: 118704
* Use the real keyword location when rebuilding an elaborated type instead ofJohn McCall2010-11-041-5/+7
| | | | | | making something up. Fixes PR8129. llvm-svn: 118258
* Don't instantiate members not belonging in the semantic context of the template.Argyrios Kyrtzidis2010-11-041-0/+12
| | | | | | | | | | | | | | | e.g. for: template <int i> class A { class B *g; }; 'class B' has the template as lexical context but semantically it is introduced in namespace scope. Fixes rdar://8611125 & http://llvm.org/PR8505 llvm-svn: 118235
* No really, we don't have a retain/release system for statements/expressionsJohn McCall2010-10-261-3/+3
| | | | | | anymore. llvm-svn: 117357
* Teach the warning about unnamed/local types in template arguments toDouglas Gregor2010-10-131-6/+0
| | | | | | | actually walk the template argument type to find any unnamed/local types within it. Fixes PR6784. llvm-svn: 116382
* Introduce support for emitting diagnostics (warnings + their notes)Douglas Gregor2010-10-121-17/+38
| | | | | | | | | | | | | | | that are suppressed during template argument deduction. This change queues diagnostics computed during template argument deduction. Then, if the resulting function template specialization or partial specialization is chosen by overload resolution or partial ordering (respectively), we will emit the queued diagnostics at that point. This addresses most of PR6784. However, the check for unnamed/local template arguments (which existed before this change) is still only skin-deep, and needs to be extended to look deeper into types. It must be improved to finish PR6784. llvm-svn: 116373
* If we end up instantiating a function parameter whose default argumentDouglas Gregor2010-10-121-0/+3
| | | | | | | | | has not yet been parsed, note that the default argument hasn't been parsed and keep track of all of the instantiations of that function parameter. When its default argument does get parsed, imbue the instantiations with that default argument. Fixes PR8245. llvm-svn: 116324
* Reinstate r114925 and r114929, both steps towardDouglas Gregor2010-09-281-7/+0
| | | | | | <rdar://problem/8459981>. llvm-svn: 114984
* Temporarily revert 114929 114925 114924 114921. It looked like they (or at leastBill Wendling2010-09-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | one of them) was causing a series of failures: http://google1.osuosl.org:8011/builders/clang-x86_64-darwin10-selfhost/builds/4518 svn merge -c -114929 https://llvm.org/svn/llvm-project/cfe/trunk --- Reverse-merging r114929 into '.': U include/clang/Sema/Sema.h U include/clang/AST/DeclCXX.h U lib/Sema/SemaDeclCXX.cpp U lib/Sema/SemaTemplateInstantiateDecl.cpp U lib/Sema/SemaDecl.cpp U lib/Sema/SemaTemplateInstantiate.cpp U lib/AST/DeclCXX.cpp svn merge -c -114925 https://llvm.org/svn/llvm-project/cfe/trunk --- Reverse-merging r114925 into '.': G include/clang/AST/DeclCXX.h G lib/Sema/SemaDeclCXX.cpp G lib/AST/DeclCXX.cpp svn merge -c -114924 https://llvm.org/svn/llvm-project/cfe/trunk --- Reverse-merging r114924 into '.': G include/clang/AST/DeclCXX.h G lib/Sema/SemaDeclCXX.cpp G lib/Sema/SemaDecl.cpp G lib/AST/DeclCXX.cpp U lib/AST/ASTContext.cpp svn merge -c -114921 https://llvm.org/svn/llvm-project/cfe/trunk --- Reverse-merging r114921 into '.': G include/clang/AST/DeclCXX.h G lib/Sema/SemaDeclCXX.cpp G lib/Sema/SemaDecl.cpp G lib/AST/DeclCXX.cpp llvm-svn: 114933
* Centralize the management of CXXRecordDecl::DefinitionData'sDouglas Gregor2010-09-281-7/+0
| | | | | | | | | | | HasTrivialConstructor, HasTrivialCopyConstructor, HasTrivialCopyAssignment, and HasTrivialDestructor bits in CXXRecordDecl's methods. This completes all but the Abstract bit and the set of conversion functions, both of which will require a bit of extra work. The majority of <rdar://problem/8459981> is now implemented (but not all of it). llvm-svn: 114929
* Correctly set "explicit template instantiation" kind on inner structs of ↵Nico Weber2010-09-271-4/+11
| | | | | | | | templates whose explicit instantiation is first declared and then defined. Fixes http://llvm.org/pr8207 llvm-svn: 114874
* Simplify template instantiation for C++ exception declarations,Douglas Gregor2010-09-091-7/+5
| | | | | | eliminating an unnecessary use of TemporaryBase in the process. llvm-svn: 113500
* One who seeks knowledge learns something new every day.John McCall2010-08-261-2/+2
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall2010-08-251-1/+1
| | | | | | | Clients of Sema don't need to know (for example) the list of diagnostics we support. llvm-svn: 112093
* Move more stuff out of Sema.h.John McCall2010-08-251-5/+6
| | | | llvm-svn: 112026
* Struggle mightily against header inclusion in Sema.h.John McCall2010-08-241-0/+1
| | | | llvm-svn: 111904
* OwningExprResult -> ExprResult. This patch brought to you byJohn McCall2010-08-241-12/+12
| | | | | | | M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result llvm-svn: 111903
* DeclPtrTy -> Decl *John McCall2010-08-211-3/+3
| | | | llvm-svn: 111733
* Another step in the process of making the parser depend on Sema:John McCall2010-08-201-1/+1
| | | | | | | | | - move DeclSpec &c into the Sema library - move ParseAST into the Parse library Reflect this change in a thousand different includes. Reflect this change in the link orders. llvm-svn: 111667
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-2/+2
| | | | llvm-svn: 110945
OpenPOWER on IntegriCloud