Commit c3cdacb
committed
[SYCL][clang] Emit default template arguments in integration header
For free function kernels support clang forward declares the kernel
itself as well as its parameter types. In case a free function kernel has a
parameter that is templated and has a default template argument, all
template arguments including arguments that match default arguments must
be printed in kernel's forward declarations, for example
```
template <typename T, typename = int> struct Arg {
T val;
};
// For the kernel
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
(ext::oneapi::experimental::nd_range_kernel<1>)) void foo(Arg<int> arg) {
arg.val = 42;
}
// Integration header must contain
void foo(Arg<int, int> arg);
```
Unfortunately, even though integration header emission already has
extensive support for forward declarations priting,
some modifications to clang's type printing are still required.
infrastructure, since neither of existing PrintingPolicy flags help to
reach the correct result.
Using `SuppressDefaultTemplateArgs = true` doesn't help without printing
canonical types, printing canonical types for the case like
```
template <typename T>
SYCL_EXT_ONEAPI_FUNCTION_PROPERTY(
(ext::oneapi::experimental::nd_range_kernel<1>)) void foo(Arg<T> arg) {
arg.val = 42;
}
// Printing canonical types is causing the following integration header
template <typename T>
void foo(Arg<type-parameter-0-0, int> arg);
```
Using `SkipCanonicalizationOfTemplateTypeParms` field of printing policy
doesn't help here since at the one point where it is checked we take
canonical type of `Arg`, not its parameters and it will contain template
argument types in canonical type after that.1 parent 4a274fc commit c3cdacb
File tree
3 files changed
+44
-13
lines changed- clang
- include/clang/AST
- lib
- AST
- Sema
3 files changed
+44
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
240 | 247 | | |
241 | 248 | | |
242 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2397 | 2397 | | |
2398 | 2398 | | |
2399 | 2399 | | |
2400 | | - | |
2401 | | - | |
2402 | | - | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
2403 | 2404 | | |
2404 | | - | |
2405 | | - | |
2406 | | - | |
2407 | | - | |
2408 | | - | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
2409 | 2429 | | |
2410 | 2430 | | |
2411 | 2431 | | |
| |||
2414 | 2434 | | |
2415 | 2435 | | |
2416 | 2436 | | |
2417 | | - | |
| 2437 | + | |
2418 | 2438 | | |
2419 | 2439 | | |
2420 | 2440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6464 | 6464 | | |
6465 | 6465 | | |
6466 | 6466 | | |
| 6467 | + | |
6467 | 6468 | | |
6468 | 6469 | | |
6469 | 6470 | | |
| |||
6476 | 6477 | | |
6477 | 6478 | | |
6478 | 6479 | | |
6479 | | - | |
| 6480 | + | |
6480 | 6481 | | |
6481 | 6482 | | |
6482 | 6483 | | |
6483 | 6484 | | |
| 6485 | + | |
6484 | 6486 | | |
6485 | 6487 | | |
6486 | 6488 | | |
| |||
6509 | 6511 | | |
6510 | 6512 | | |
6511 | 6513 | | |
| 6514 | + | |
| 6515 | + | |
6512 | 6516 | | |
6513 | 6517 | | |
6514 | 6518 | | |
| |||
0 commit comments