[libcxx-commits] [libcxx] Fix detection of __datasizeof with Clang. (PR #94174)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jun 2 14:39:54 PDT 2024


https://github.com/EricWF created https://github.com/llvm/llvm-project/pull/94174

The `__has_extension` builtin macro is the same as __has_feature when
-pedantic-errors is specified, which means we don't get the right
information about __datasizeof being available.

Using __has_keyword (really !__is_identifier) will tell the truth
even when -pedantic-errors is specified.

This means we always have __datasizeof under Clang


>From 5c5a9521841cdbcb59fddaf44512d50bef2ae80e Mon Sep 17 00:00:00 2001
From: Eric Fiselier <eric at efcs.ca>
Date: Sun, 2 Jun 2024 17:35:10 -0400
Subject: [PATCH] Fix detection of __datasizeof with Clang.

The `__has_extension` builtin macro is the same as __has_feature when
-pedantic-errors is specified, which means we don't get the right
information about __datasizeof being available.

Using __has_keyword (really !__is_identifier) will tell the truth
even when -pedantic-errors is specified.

This means we always have __datasizeof under Clang
---
 libcxx/include/__type_traits/datasizeof.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__type_traits/datasizeof.h b/libcxx/include/__type_traits/datasizeof.h
index 54fde242ebcde..35c12921e8ffa 100644
--- a/libcxx/include/__type_traits/datasizeof.h
+++ b/libcxx/include/__type_traits/datasizeof.h
@@ -26,7 +26,7 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#if __has_extension(datasizeof)
+#if __has_keyword(__datasizeof) || __has_extension(datasizeof)
 template <class _Tp>
 inline const size_t __datasizeof_v = __datasizeof(_Tp);
 #else



More information about the libcxx-commits mailing list