Skip to content

Commit 0cdfaee

Browse files
[SYCL][clang] Apply default arg suppression for template of templates (#20880)
The SuppressDefaultTemplateArguments is a printing policy argument local to intel/llvm, but is currently only applied to basic templates. This commit applies the suppression of default arguments to template of templates cases as well. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 7c3530f commit 0cdfaee

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

clang/lib/AST/DeclPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,8 @@ void DeclPrinter::VisitNonTypeTemplateParmDecl(
19271927
void DeclPrinter::VisitTemplateTemplateParmDecl(
19281928
const TemplateTemplateParmDecl *TTPD) {
19291929
VisitTemplateDecl(TTPD);
1930-
if (TTPD->hasDefaultArgument() && !TTPD->defaultArgumentWasInherited()) {
1930+
if (TTPD->hasDefaultArgument() && !Policy.SuppressDefaultTemplateArguments &&
1931+
!TTPD->defaultArgumentWasInherited()) {
19311932
Out << " = ";
19321933
TTPD->getDefaultArgument().getArgument().print(Policy, Out,
19331934
/*IncludeType=*/false);

clang/test/CodeGenSYCL/integration_header.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
//
66
// CHECK: // Forward declarations of templated kernel function types:
77
// CHECK: class first_kernel;
8+
// CHECK-NEXT: template <typename T> struct point;
89
// CHECK-NEXT: namespace second_namespace {
9-
// CHECK-NEXT: template <typename T> class second_kernel;
10+
// CHECK-NEXT: template <typename T, template <typename> typename U> class second_kernel;
1011
// CHECK-NEXT: }
1112
// CHECK-NEXT: namespace template_arg_ns {
1213
// CHECK-NEXT: template <int DimX> struct namespaced_arg;
@@ -17,7 +18,7 @@
1718
// CHECK: static constexpr
1819
// CHECK-NEXT: const char* const kernel_names[] = {
1920
// CHECK-NEXT: "_ZTSZ4mainE12first_kernel",
20-
// CHECK-NEXT: "_ZTSN16second_namespace13second_kernelIcEE",
21+
// CHECK-NEXT: "_ZTSN16second_namespace13second_kernelIc5pointEE",
2122
// CHECK-NEXT: "_ZTS13fourth_kernelIJN15template_arg_ns14namespaced_argILi1EEEEE"
2223
// CHECK-NEXT: "_ZTSZ4mainE16accessor_in_base"
2324
// CHECK-NEXT: "_ZTSZ4mainE15annotated_types"
@@ -36,7 +37,7 @@
3637
// CHECK-NEXT: { kernel_param_kind_t::kind_accessor, 6112, 24 },
3738
// CHECK-NEXT: { kernel_param_kind_t::kind_sampler, 8, 40 },
3839
// CHECK-EMPTY:
39-
// CHECK-NEXT: //--- _ZTSN16second_namespace13second_kernelIcEE
40+
// CHECK-NEXT: //--- _ZTSN16second_namespace13second_kernelIc5pointEE
4041
// CHECK-NEXT: { kernel_param_kind_t::kind_std_layout, 4, 0 },
4142
// CHECK-NEXT: { kernel_param_kind_t::kind_accessor, 6112, 4 },
4243
// CHECK-NEXT: { kernel_param_kind_t::kind_sampler, 8, 16 },
@@ -66,7 +67,7 @@
6667
// CHECK-NEXT: };
6768
//
6869
// CHECK: template <> struct KernelInfo<first_kernel> {
69-
// CHECK: template <> struct KernelInfo<::second_namespace::second_kernel<char>> {
70+
// CHECK: template <> struct KernelInfo<::second_namespace::second_kernel<char, point>> {
7071
// CHECK: template <> struct KernelInfo<::fourth_kernel<::template_arg_ns::namespaced_arg<1>>> {
7172

7273
#include "Inputs/sycl.hpp"
@@ -79,7 +80,7 @@ struct x {};
7980
template <typename T>
8081
struct point {};
8182
namespace second_namespace {
82-
template <typename T = int>
83+
template <typename T = int, template <typename> typename U = point>
8384
class second_kernel;
8485
}
8586

0 commit comments

Comments
 (0)