]> granicus.if.org Git - clang/commit
Add optimization to sizeof...(X) handling: if none of parameter pack X's
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 19 Oct 2016 22:18:42 +0000 (22:18 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 19 Oct 2016 22:18:42 +0000 (22:18 +0000)
commiteff4af405363ef21e9ad401062e177f793e2abd9
tree0d8c33ccd9a8396637ce4212a07569c5baaae024
parenta32fe9277c81f89fbba89ff025cca07d83498bc1
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284653 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Sema/Sema.h
lib/Sema/SemaTemplateVariadic.cpp
lib/Sema/TreeTransform.h
test/SemaTemplate/alias-templates.cpp