summaryrefslogtreecommitdiffstats
path: root/clang/include
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-10-19 22:18:42 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-10-19 22:18:42 +0000
commitc5452ed941909c04dcae6466677b4dffcf88e09e (patch)
treeedd836cac8a816816126e530a33602ecf45cd0a6 /clang/include
parent01d6b963d2903977fea1950cf6b083d44be0745a (diff)
downloadbcm5719-llvm-c5452ed941909c04dcae6466677b4dffcf88e09e.tar.gz
bcm5719-llvm-c5452ed941909c04dcae6466677b4dffcf88e09e.zip
Add optimization to sizeof...(X) handling: if none of parameter pack X's
corresponding arguments are unexpanded pack expansions, we can compute the result without substituting them. This significantly improves the memory usage and performance of make_integer_sequence implementations that do this kind of thing: using result = integer_sequence<T, Ns ..., sizeof...(Ns) + Ns ...>; ... but note that such an implementation will still perform O(sizeof...(Ns)^2) work while building the second pack expansion (we just have a somewhat lower constant now). In principle we could get this down to linear time by caching whether the number of expansions of a pack is constant, or checking whether we're within an alias template before scanning the pack for pack expansions (since that's the only case in which we do substitutions within a dependent context at the moment), but this patch doesn't attempt that. llvm-svn: 284653
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Sema/Sema.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 78080f5e4a4..78be700ec3a 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6499,6 +6499,14 @@ public:
SourceLocation &Ellipsis,
Optional<unsigned> &NumExpansions) const;
+ /// Given a template argument that contains an unexpanded parameter pack, but
+ /// which has already been substituted, attempt to determine the number of
+ /// elements that will be produced once this argument is fully-expanded.
+ ///
+ /// This is intended for use when transforming 'sizeof...(Arg)' in order to
+ /// avoid actually expanding the pack where possible.
+ Optional<unsigned> getFullyPackExpandedSize(TemplateArgument Arg);
+
//===--------------------------------------------------------------------===//
// C++ Template Argument Deduction (C++ [temp.deduct])
//===--------------------------------------------------------------------===//
OpenPOWER on IntegriCloud