[libc-commits] [libc] [libc] Remove obsolete LIBC_HAS_BUILTIN macro (PR #86554)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Mar 25 12:31:10 PDT 2024


================
@@ -71,7 +71,7 @@ template <typename T> struct Atomic {
 
   T load(MemoryOrder mem_ord = MemoryOrder::SEQ_CST,
          [[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) {
-    if constexpr (LIBC_HAS_BUILTIN(__scoped_atomic_load_n))
+    if constexpr (__has_builtin(__scoped_atomic_load_n))
----------------
nickdesaulniers wrote:

Thanks!

While you're here, do you mind converting this code from using

`if constexpr(__has_builtin(foo))`
to
`#if __has_builtin(foo)`
?

While it may not be as pretty (requires an `#endif`), it's better for compile time to evaluate this in the preprocessor than during constexpr evaluation.  Both sides of the condition need to be lexed+parsed as written.  Perhaps not meaningfully faster though.

https://github.com/llvm/llvm-project/pull/86554


More information about the libc-commits mailing list