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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Eric (EricWF)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/94174.diff


1 Files Affected:

- (modified) libcxx/include/__type_traits/datasizeof.h (+1-1) 


``````````diff
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

``````````

</details>


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


More information about the libcxx-commits mailing list