Skip to content

Conversation

@philnik777
Copy link
Contributor

__has_feature(modules) is always true in C++20 and later. Instead of using that, just disable extension warnings if they're not ignored through the system header machinery anyways.

@philnik777 philnik777 marked this pull request as ready for review April 11, 2025 10:09
@philnik777 philnik777 requested a review from a team as a code owner April 11, 2025 10:09
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Apr 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 11, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

__has_feature(modules) is always true in C++20 and later. Instead of using that, just disable extension warnings if they're not ignored through the system header machinery anyways.


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

1 Files Affected:

  • (modified) libcxx/include/__config (+3-3)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 084e1d4402e6c..05ae32f01e865 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -543,9 +543,9 @@ typedef __char32_t char32_t;
 #  endif
 
 // Clang modules take a significant compile time hit when pushing and popping diagnostics.
-// Since all the headers are marked as system headers in the modulemap, we can simply disable this
-// pushing and popping when building with clang modules.
-#  if !__has_feature(modules)
+// Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can
+// simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined.
+#  ifdef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
 #    define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS                                                                         \
       _LIBCPP_DIAGNOSTIC_PUSH                                                                                          \
       _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions")                                                           \

@philnik777 philnik777 force-pushed the fix_extension_warnings branch from 184dbc0 to a0bbdd6 Compare May 8, 2025 05:30
@philnik777 philnik777 merged commit ab65e4a into llvm:main May 10, 2025
85 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants