llvm-project/clang/test/ParserSYCL/unique-stable-name.cpp
Erich Keane b5a034e771 [SYCL] Implement __builtin_unique_stable_name.
In order to support non-user-named kernels, SYCL needs some way in the
integration headers to name the kernel object themselves. Initially, the
design considered just RTTI naming of the lambdas, this results in a
quite unstable situation in light of some device/host macros.
Additionally, this ends up needing to use RTTI, which is a burden on the
implementation and typically unsupported.

Instead, we've introduced a builtin, __builtin_unique_stable_name, which
takes a type or expression, and results in a constexpr constant
character array that uniquely represents the type (or type of the
expression) being passed to it.

The implementation accomplishes that simply by using a slightly modified
version of the Itanium Mangling. The one exception is when mangling
lambdas, instead of appending the index of the lambda in the function,
it appends the macro-expansion back-trace of the lambda itself in the
form LINE->COL[~LINE->COL...].

Differential Revision: https://reviews.llvm.org/D76620
2020-03-25 07:01:50 -07:00

34 lines
1.0 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused %s
namespace NS{};
void f(int var) {
// expected-error@+1{{expected '(' after '__builtin_unique_stable_name'}}
__builtin_unique_stable_name int;
// expected-error@+1{{expected '(' after '__builtin_unique_stable_name'}}
__builtin_unique_stable_name {int};
__builtin_unique_stable_name(var);
// expected-error@+1{{use of undeclared identifier 'bad_var'}}
__builtin_unique_stable_name(bad_var);
// expected-error@+1{{use of undeclared identifier 'bad'}}
__builtin_unique_stable_name(bad::type);
// expected-error@+1{{no member named 'still_bad' in namespace 'NS'}}
__builtin_unique_stable_name(NS::still_bad);
}
template <typename T>
void f2() {
// expected-error@+1{{no member named 'bad_val' in 'S'}}
__builtin_unique_stable_name(T::bad_val);
// expected-error@+1{{no type named 'bad_type' in 'S'}}
__builtin_unique_stable_name(typename T::bad_type);
}
struct S{};
void use() {
// expected-note@+1{{in instantiation of}}
f2<S>();
}