[clang] [Clang] Add __has_target_builtin macro (PR #126324)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 10 14:57:27 PST 2025
================
@@ -357,6 +357,7 @@ void Preprocessor::RegisterBuiltinMacros() {
Ident__has_builtin = RegisterBuiltinMacro("__has_builtin");
Ident__has_constexpr_builtin =
RegisterBuiltinMacro("__has_constexpr_builtin");
+ Ident__has_target_builtin = RegisterBuiltinMacro("__has_target_builtin");
----------------
Artem-B wrote:
> My fear is that some C++ library headers start to use this macro `__has_target_builtin` in place of `__has_builtin`, and we cannot modify such headers.
IMO, now that we do document semantics of `__has_target_builtin()`, its misuse on the library side will be their problem to fix. The problem with `__has_builtin()` was that it was never intended to handle heterogeneous compilation, and that's what created the issue when CUDA/HIP made builtins from both host and device visible to the compiler, but not all of them codegen-able. `__has_target_builtin()` clearly states what to expect. Sure, it's possible to misuse it, but having it available unconditionally will make it much less cumbersome to use in the headers shared between CUDA and C++, and that's a fairly common use case.
I'd prefer to have `__has_target_builtin()` generally available.
https://github.com/llvm/llvm-project/pull/126324
More information about the cfe-commits
mailing list