[libcxx-commits] [libcxx] [libc++][type_traits] Implements "A type trait to detect reference binding to temporary" (PR #128649)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 5 22:44:51 PST 2025
================
@@ -1215,6 +1215,21 @@ typedef __char32_t char32_t;
# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
# endif
+// TODO(LLVM 22): Remove this macro once LLVM19 support ends.
+# if __has_builtin(__reference_constructs_from_temporary) || \
+ (defined(_LIBCPP_CLANG_VER) && (_LIBCPP_CLANG_VER >= 1900))
+# define _LIBCPP_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY 1
+# else
+# define _LIBCPP_HAS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY 0
+# endif
+
+// TODO(LLVM 22): Remove this macro once LLVM19 support ends.
+# if __has_builtin(__reference_converts_from_temporary) || (defined(_LIBCPP_CLANG_VER) && (_LIBCPP_CLANG_VER >= 1901))
----------------
Zingam wrote:
Android Clang reports for example as Clang 19.0. It gets branched off `main` in between official LLVM releases with cherry-picked commits, therefore Clang 19.0 could have some features of Clang 19.1, which were committed to `main` before it got branched off. In our case:
- Android Clang 19.0 is missing `__reference_converts_from_temporary`
- Android Clang 20.0 is missing `__has_builtin(__reference_{constructs|converts|_from_temporary)` fixes
I updated the macro to make this clearer. I hope that this is no longer confusing.
https://github.com/llvm/llvm-project/pull/128649
More information about the libcxx-commits
mailing list