aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlntue <lntue@google.com>2025-07-23 17:16:09 +0000
committerGitHub <noreply@github.com>2025-07-23 13:16:09 -0400
commit8ef0c50ecac8f1e707c02bee855f43eda114f8db (patch)
treeedb8af92e00bf29817dcc55f59c9f2cf6487785b
parent7baf4bdd164cad61f8f3e34ed833a695c4033250 (diff)
downloadllvm-8ef0c50ecac8f1e707c02bee855f43eda114f8db.zip
llvm-8ef0c50ecac8f1e707c02bee855f43eda114f8db.tar.gz
llvm-8ef0c50ecac8f1e707c02bee855f43eda114f8db.tar.bz2
[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
-rw-r--r--libc/src/__support/CPP/type_traits/is_constant_evaluated.h4
-rw-r--r--libc/src/__support/macros/attributes.h6
2 files changed, 10 insertions, 0 deletions
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 0bb2d08..9339af4 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 c647467..62b0f7c 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