Skip to content

Commit 8ef0c50

Browse files
authored
[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
1 parent 7baf4bd commit 8ef0c50

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

libc/src/__support/CPP/type_traits/is_constant_evaluated.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ namespace LIBC_NAMESPACE_DECL {
1515
namespace cpp {
1616

1717
LIBC_INLINE constexpr bool is_constant_evaluated() {
18+
#if LIBC_HAS_BUILTIN(__builtin_is_constant_evaluated)
1819
return __builtin_is_constant_evaluated();
20+
#else
21+
return false;
22+
#endif
1923
}
2024

2125
} // namespace cpp

libc/src/__support/macros/attributes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,10 @@
4848
#define LIBC_PREFERED_TYPE(TYPE)
4949
#endif
5050

51+
#ifndef __has_builtin
52+
#define LIBC_HAS_BUILTIN(X) 0
53+
#else
54+
#define LIBC_HAS_BUILTIN(X) __has_builtin(X)
55+
#endif
56+
5157
#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H

0 commit comments

Comments
 (0)