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
Showing
- include/clang/Sema/Sema.h 8 additions, 0 deletionsinclude/clang/Sema/Sema.h
- lib/Sema/SemaTemplateVariadic.cpp 58 additions, 1 deletionlib/Sema/SemaTemplateVariadic.cpp
- lib/Sema/TreeTransform.h 47 additions, 0 deletionslib/Sema/TreeTransform.h
- test/SemaTemplate/alias-templates.cpp 17 additions, 0 deletionstest/SemaTemplate/alias-templates.cpp
Loading
Please register or sign in to comment