Skip to content

Commit 9b80656

Browse files
lntuemahesh-attarde
authored andcommitted
[libc] Add support for __builtin_is_constant_evaluated for GCC 9+. (llvm#150322)
https://lab.llvm.org/buildbot/#/builders/10/builds/10047/steps/5/logs/stdio
1 parent f86d36a commit 9b80656

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ 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)
1918
return __builtin_is_constant_evaluated();
20-
#else
21-
return false;
22-
#endif
2319
}
2420

2521
} // namespace cpp

libc/src/__support/RPC/rpc_server.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@
1515
#ifndef LLVM_LIBC_SRC___SUPPORT_RPC_RPC_SERVER_H
1616
#define LLVM_LIBC_SRC___SUPPORT_RPC_RPC_SERVER_H
1717

18+
#include "src/__support/macros/properties/compiler.h"
19+
1820
// Workaround for missing __has_builtin in < GCC 10.
1921
#ifndef __has_builtin
2022
#define __has_builtin(x) 0
2123
#endif
2224

2325
// Workaround for missing __builtin_is_constant_evaluated in < GCC 10.
24-
#ifndef __builtin_is_constant_evaluated
26+
// Also this builtin is defined for GCC 9.
27+
#if !(__has_builtin(__builtin_is_constant_evaluated) || \
28+
(defined(LIBC_COMPILER_IS_GCC) && (LIBC_COMPILER_GCC_VER >= 900)))
2529
#define __builtin_is_constant_evaluated(x) 0
2630
#endif
2731

libc/src/__support/macros/attributes.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,4 @@
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-
5751
#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_ATTRIBUTES_H

0 commit comments

Comments
 (0)