3 Commits

Author SHA1 Message Date
Qizhi Hu
752c172bc7
[Clang][Sema] fix outline member function template with default align crash (#80288)
Try to fix [issue](https://github.com/llvm/llvm-project/issues/68490 )
and some extented problem. Root cause of current issue is that error
handling in instantiation of function parameter with default
initialization on sizeof or align expression. When instance an
out-of-line template member function, depth of `TemplateTypeParmDecl` in
default initialization doesn't change while depth of other template
parameter does and this will lead to some template parameter
uninstanced. Also, sometime it will leader to wrong instantiation when
it uses the template parameter of the template class.
Fix it by add template args of context. This will make
MultiLevelTemplateArgumentList::getNumLevels matching the depth of
template parameter. Testcase with some static_assert demonstrates the
template parameter has been instanced correctly.
But, the default initialization of lambda expression compiles failed
when only checking if the member function is out-of-line. We should
check the `PrimaryFunctionTemplateDecl` of the funtion if it's
out-of-line.

Co-authored-by: huqizhi <836744285@qq.com>
2024-02-03 21:49:09 +08:00
Erich Keane
6e6aa44c7d
Revert "[Clang][Sema] fix outline member function template with defau… (#80144)
…lt align crash (#78400)"

This reverts commit 7b3389980ddbd84f72ccc4776889c67519cc2c14.

A regression was discovered here:
https://github.com/llvm/llvm-project/pull/78400

and the author requested a revert to give time to review.
2024-01-31 06:58:58 -08:00
Qizhi Hu
7b3389980d
[Clang][Sema] fix outline member function template with default align crash (#78400)
Try to fix [issue](https://github.com/llvm/llvm-project/issues/68490)
and some extented problem. Root cause of current issue is that error
handling in instantiation of function parameter with default
initialization on sizeof or align expression. When instance an
out-of-line template member function, depth of `TemplateTypeParmDecl` in
default initialization doesn't change while depth of other template
parameter does and this will lead to some template parameter
uninstanced. Also, sometime it will leader to wrong instantiation when
it uses the template parameter of class.
Fix it by add template args of context when it's out-of-line. This will
make `MultiLevelTemplateArgumentList::getNumLevels` matching the depth
of template parameter. Testcase with some `static_assert` demonstrates
the template parameter has been instanced correctly.

Co-authored-by: huqizhi <836744285@qq.com>
2024-01-26 14:46:42 +08:00