diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-07 16:43:16 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-07 16:43:16 +0000 |
commit | 12c9c00024a01819e3a70ef6d951d32efaeb9312 (patch) | |
tree | 0c6499b83aab17269756d4e65041d29374506256 /lib/Sema/TreeTransform.h | |
parent | 170464b7c0a2c0c86f2821f14a46f0d540cb5e94 (diff) |
Implement substitution of a function parameter pack for its set of
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
Diffstat (limited to 'lib/Sema/TreeTransform.h')
-rw-r--r-- | lib/Sema/TreeTransform.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 60ec950c12..0624aaa7ee 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -222,6 +222,10 @@ public: return false; } + /// \brief Note to the derived class when a function parameter pack is + /// being expanded. + void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { } + /// \brief Transforms the given type into another type. /// /// By default, this routine transforms a type by creating a @@ -3423,6 +3427,7 @@ bool TreeTransform<Derived>:: if (ShouldExpand) { // Expand the function parameter pack into multiple, separate // parameters. + getDerived().ExpandingFunctionParameterPack(OldParm); for (unsigned I = 0; I != NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); ParmVarDecl *NewParm @@ -6875,6 +6880,7 @@ TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) { llvm::SmallVector<QualType, 4> ParamTypes; // Parameter substitution. + // FIXME: Variadic templates const BlockDecl *BD = E->getBlockDecl(); for (BlockDecl::param_const_iterator P = BD->param_begin(), EN = BD->param_end(); P != EN; ++P) { |