Skip to content

Commit 185db16

Browse files
committed
[clang][SYCL] Emit canonical types in integration footer
A recent change to sycl headers revealed a bug in integration footer - missing nns in case of an explicit template specialization in some of device_globa's template arguments.
1 parent 1e1ffc0 commit 185db16

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6969,6 +6969,7 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
69696969
Policy.adjustForCPlusPlusFwdDecl();
69706970
Policy.SuppressTypedefs = true;
69716971
Policy.SuppressUnwrittenScope = true;
6972+
Policy.PrintCanonicalTypes = true;
69726973

69736974
llvm::SmallSet<const VarDecl *, 8> Visited;
69746975
bool EmittedFirstSpecConstant = false;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -triple spir64-unknown-unknown -fsycl-int-footer=%t.footer.h -emit-llvm %s -o -
2+
// RUN: FileCheck -input-file=%t.footer.h %s --check-prefix=CHECK-FOOTER
3+
4+
#include "sycl.hpp"
5+
6+
namespace sycl {
7+
template <typename T> struct X {};
8+
template <> struct X<int> {};
9+
namespace detail {
10+
struct Y {};
11+
} // namespace detail
12+
template <> struct X<detail::Y> {};
13+
} // namespace sycl
14+
15+
using namespace sycl;
16+
template <typename T, typename = X<detail::Y>> struct Arg1 { T val; };
17+
18+
using namespace sycl::ext::oneapi;
19+
template <typename properties_t>
20+
device_global<properties_t> dev_global;
21+
22+
SYCL_EXTERNAL auto foo() {
23+
(void)dev_global<Arg1<int>>;
24+
}
25+
26+
// CHECK-FOOTER: __sycl_device_global_registration::__sycl_device_global_registration() noexcept {
27+
// CHECK-FOOTER-NEXT: device_global_map::add((void *)&::dev_global<Arg1<int, sycl::X<sycl::detail::Y>>>, "_Z10dev_globalI4Arg1IiN4sycl1XINS1_6detail1YEEEEE");
28+
// CHECK-FOOTER-NEXT: }
29+
// CHECK-FOOTER-NEXT: } // namespace (unnamed)

0 commit comments

Comments
 (0)