[libc-commits] [libc] 8ef0c50 - [libc] Fix problem with older compilers that do not have __has_builtin. (#150264)
via libc-commits
libc-commits at lists.llvm.org
Wed Jul 23 10:16:13 PDT 2025
Author: lntue
Date: 2025-07-23T13:16:09-04:00
New Revision: 8ef0c50ecac8f1e707c02bee855f43eda114f8db
URL: https://github.com/llvm/llvm-project/commit/8ef0c50ecac8f1e707c02bee855f43eda114f8db
DIFF: https://github.com/llvm/llvm-project/commit/8ef0c50ecac8f1e707c02bee855f43eda114f8db.diff
LOG: [libc] Fix problem with older compilers that do not have __has_builtin. (#150264)
Fixing bot failures:
https://lab.llvm.org/buildbot/#/builders/10/builds/10025
Added:
Modified:
libc/src/__support/CPP/type_traits/is_constant_evaluated.h
libc/src/__support/macros/attributes.h
Removed:
################################################################################
diff --git a/libc/src/__support/CPP/type_traits/is_constant_evaluated.h b/libc/src/__support/CPP/type_traits/is_constant_evaluated.h
index 0bb2d0806cb0d..9339af46d6762 100644
--- a/libc/src/__support/CPP/type_traits/is_constant_evaluated.h
+++ b/libc/src/__support/CPP/type_traits/is_constant_evaluated.h
@@ -15,7 +15,11 @@ namespace LIBC_NAMESPACE_DECL {
namespace cpp {
LIBC_INLINE constexpr bool is_constant_evaluated() {
+#if LIBC_HAS_BUILTIN(__builtin_is_constant_evaluated)
return __builtin_is_constant_evaluated();
+#else
+ return false;
+#endif
}
} // namespace cpp
diff --git a/libc/src/__support/macros/attributes.h b/libc/src/__support/macros/attributes.h
index c6474673de85a..62b0f7c3d6155 100644
--- a/libc/src/__support/macros/attributes.h
+++ b/libc/src/__support/macros/attributes.h
@@ -48,4 +48,10 @@
#define LIBC_PREFERED_TYPE(TYPE)
#endif
+#ifndef __has_builtin
+#define LIBC_HAS_BUILTIN(X) 0
+#else
+#define LIBC_HAS_BUILTIN(X) __has_builtin(X)
+#endif
+
#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H
More information about the libc-commits
mailing list