Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,11 @@ static ExprResult TransformUniqueStableName(TemplateInstantiator &TI,
TI.getSema(), Sema::ExpressionEvaluationContext::Unevaluated);
ExprResult SubExpr = TI.getDerived().TransformExpr(E->getExpr());

if (SubExpr.isInvalid())
return ExprError();

SubExpr = TI.getSema().CheckPlaceholderExpr(SubExpr.get());

if (SubExpr.isInvalid())
return ExprError();

Expand Down
29 changes: 29 additions & 0 deletions clang/test/CodeGenSYCL/unique-stable-name-placeholder-crash.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// RUN: %clang_cc1 -triple spir64-unknown-unknown-sycldevice -std=c++17 -sycl-std=2020 -fsycl -fsycl-is-device -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s

template <typename KernelName, typename KernelType>
[[clang::sycl_kernel]] void kernel_single_task(const KernelType &kernelFunc) {
kernelFunc();
}

struct A {
int a = 0;
A() = default;
};
constexpr A THE_NAME;

template <auto &R> void temp() {}
template <auto &R> void foo(const char *out) {
out = __builtin_unique_stable_name(temp<R>);
}

int main() {
kernel_single_task<class kernel>(
[]() {
const char *c;
foo<THE_NAME>(c);
});
}

// Note: the mangling here is actually the 'typeinfo name for void ()'. That is
// because the type of temp<R> is actually the function type (which is void()).
// CHECK: @__builtin_unique_stable_name._Z3fooIL_ZL8THE_NAMEEEvPKc = private unnamed_addr addrspace(1) constant [9 x i8] c"_ZTSFvvE\00", align 1