[clang] [docs] Document some C++ standard library intrinsics (PR #247115)
Jan Schultke via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 30 01:51:54 PST 2026
https://github.com/eisenwave created https://github.com/llvm/llvm-project/pull/247115
This adds documentation for `__builtin_launder`, `__builtin_bit_cast`, `__builtin_is_constant_evaluated`, and `__builtin_is_within_lifetime` (ordered by their age within the C++ standard).
For each intrinsic, the description simply delegates to the cppreference documentation for the standard library function, such as for `std::launder`. Otherwise, we would need to maintain our own documentation of behavior, which would be quite challenging.
>From aa4e3a4b678b910b2fec440b3bbed7ef0bf96699 Mon Sep 17 00:00:00 2001
From: Eisenwave <me at eisenwave.net>
Date: Mon, 30 Nov 2026 10:49:00 +0100
Subject: [PATCH] [docs] Document some C++ standard library intrinsics
---
clang/docs/LanguageExtensions.md | 67 ++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/clang/docs/LanguageExtensions.md b/clang/docs/LanguageExtensions.md
index f53d4f636b4640..3d7bb7a321cb1f 100644
--- a/clang/docs/LanguageExtensions.md
+++ b/clang/docs/LanguageExtensions.md
@@ -4602,6 +4602,73 @@ required to the value of the stack pointer register.
`__builtin_stack_address` performs the necessary adjustments and returns the
correct boundary address.
+### `__builtin_launder`
+
+**Syntax**:
+
+```c++
+constexpr T *__builtin_launder(T *);
+```
+
+**Description**:
+
+`__builtin_launder` has the same effect as the C++17 standard library function
+[`std::launder`](https://en.cppreference.com/cpp/utility/launder).
+However, it is always available, including in C.
+
+### `__builtin_bit_cast` (C++)
+
+**Syntax**:
+
+```c++
+constexpr To __builtin_bit_cast(type-id To, From from);
+```
+
+**Example**:
+
+```c++
+template<typename To, typename From>
+constexpr To bit_cast(const From &from) noexcept {
+ return __builtin_bit_cast(To, from);
+}
+```
+
+**Description**:
+
+`__builtin_bit_cast` has the same effect as the C++20 standard library function
+[`std::bit_cast`](https://en.cppreference.com/cpp/numeric/bit_cast).
+However, it is always available in C++ mode.
+
+### `__builtin_is_constant_evaluated` (C++)
+
+**Syntax**:
+
+```c++
+constexpr bool __builtin_is_constant_evaluated();
+```
+
+**Description**:
+
+`__builtin_is_constant_evaluated` has the same effect as the C++20 standard
+library function
+[`std::is_constant_evaluated`](https://en.cppreference.com/cpp/types/is_constant_evaluated).
+However, it is always available in C++ mode.
+
+### `__builtin_is_within_lifetime` (C++)
+
+**Syntax**:
+
+```c++
+consteval bool __builtin_is_within_lifetime(T *);
+```
+
+**Description**:
+
+`__builtin_is_within_lifetime` has the same effect as the C++26 standard
+library function
+[`std::is_within_lifetime`](https://en.cppreference.com/cpp/types/is_within_lifetime).
+However, it is available in C++20 mode and above.
+
### Multiprecision Arithmetic Builtins
Clang provides a set of builtins which expose multiprecision arithmetic in a
More information about the cfe-commits
mailing list