aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplateInstantiate.cpp
AgeCommit message (Collapse)Author
2011-01-14Handle substitutions into function parameter packs whose patternsDouglas Gregor
contain multiple parameter packs at different levels. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123488 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14Keep track of the number of expansions to be produced from a type packDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123448 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-14Start implementing support for substitution into pack expansions thatDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123425 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10Work-in-progress implementation of C++0x [temp.arg.explicit]p9, whichDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07When instantiating the arguments to an initializer, use theDouglas Gregor
TreeTransform version of TransformExprs() rather than explicit loop, so that we expand pack expansions properly. Test cast coming soon... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123014 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07Implement substitution of a function parameter pack for its set ofDouglas Gregor
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'); } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123000 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07Factor out the template transformation of a sequence of functionDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122986 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05Initial implementation of function parameter packs. This implementation allows:Douglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122926 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05hasInit() -> hasDefaultArg()Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122905 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-05Implement support for template template parameter packs, e.g.,Douglas Gregor
template<template<class> class ...Metafunctions> struct apply_to_each; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122874 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04Improve our handling of non-type template parameters in partialDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122851 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-04Implement pack expansion of base initializers, so that we canDouglas Gregor
initialize those lovely mixins that come from pack expansions of base specifiers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122793 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-03Implement pack expansions whose pattern is a base-specifier.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122782 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24When instantiating a non-type template parameter pack, be sure toDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122532 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-22Implement template argument deduction for pack expansions whoseDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122439 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21When searching for the instantiation of a locally-scoped tagDouglas Gregor
declaration, also look for an instantiation of its previous declarations. Fixes PR8801. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21Implement instantiation of pack expansions whose pattern is a type-idDouglas Gregor
in an exception specification. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122297 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20Handle instantiation of template type parameter packs that occur asDouglas Gregor
the first qualifier in scope. We can't adequately test this test, unfortunately. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122283 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-20Implement basic support for template instantiation of pack expansionsDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122278 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-14Added missing IgnoreParens().Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-20A bundle of whitespace changes, separated out from the functional changes.Nick Lewycky
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119886 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-18Refactoring of Diagnostic class.Argyrios Kyrtzidis
-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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119730 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-12Replace one hack with a different hack: strip out the ObjectTypeJohn McCall
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118887 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-10Instantiate class member template partial specialization declarationsDouglas Gregor
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118704 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04Use the real keyword location when rebuilding an elaborated type instead ofJohn McCall
making something up. Fixes PR8129. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118258 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04Don't instantiate members not belonging in the semantic context of the template.Argyrios Kyrtzidis
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118235 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-26No really, we don't have a retain/release system for statements/expressionsJohn McCall
anymore. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117357 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-13Teach the warning about unnamed/local types in template arguments toDouglas Gregor
actually walk the template argument type to find any unnamed/local types within it. Fixes PR6784. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116382 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-12Introduce support for emitting diagnostics (warnings + their notes)Douglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116373 91177308-0d34-0410-b5e6-96231b3b80d8
2010-10-12If we end up instantiating a function parameter whose default argumentDouglas Gregor
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116324 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-28Reinstate r114925 and r114929, both steps towardDouglas Gregor
<rdar://problem/8459981>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114984 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-28Temporarily revert 114929 114925 114924 114921. It looked like they (or at leastBill Wendling
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114933 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-28Centralize the management of CXXRecordDecl::DefinitionData'sDouglas Gregor
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114929 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-27Correctly set "explicit template instantiation" kind on inner structs of ↵Nico Weber
templates whose explicit instantiation is first declared and then defined. Fixes http://llvm.org/pr8207 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114874 91177308-0d34-0410-b5e6-96231b3b80d8
2010-09-09Simplify template instantiation for C++ exception declarations,Douglas Gregor
eliminating an unnecessary use of TemporaryBase in the process. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113500 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-26One who seeks knowledge learns something new every day.John McCall
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112244 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall
Clients of Sema don't need to know (for example) the list of diagnostics we support. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112093 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-25Move more stuff out of Sema.h.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112026 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24Struggle mightily against header inclusion in Sema.h.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111904 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-24OwningExprResult -> ExprResult. This patch brought to you byJohn McCall
M-x query-replace-regexp \(Sema::\|Action::\|Parser::\|\)Owning\(Expr\|Stmt\)Result -> \2Result git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111903 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-21DeclPtrTy -> Decl *John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111733 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-20Another step in the process of making the parser depend on Sema:John McCall
- 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111667 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-12Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110945 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11Added locations and type source info for DeclarationName.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110860 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-01Instantiate attributes from the pattern record when instantiatingJohn McCall
a class template. Fixes rdar://problem/8243419. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109967 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-26Add source location information to C++ base specifiers.Nick Lewycky
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109396 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-25Kill off the last Destroy method in the AST libraryDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-19Fix http://llvm.org/PR7660Argyrios Kyrtzidis
A ParmVarDecl instantiated from a FunctionProtoType may have Record as DeclContext, in which case isStaticDataMember() will erroneously return true. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108692 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13Set DeclContext of ParamVarDecl only. No needFariborz Jahanian
to set that of VarDecl for block variables (they are already set). Per Doug's comment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108273 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13More block instantiation stuff. Set variable/param DeclContextFariborz Jahanian
to block context when first instantiating them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108266 91177308-0d34-0410-b5e6-96231b3b80d8