Skip to content

[libc++][NFC] Inline _LIBCPP_FALLTHROUGH() #135001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2025

Conversation

philnik777
Copy link
Contributor

We have [[fallthrough]] available in all standards modes, so we can just inline it like other stanard attributes we use.

@philnik777
Copy link
Contributor Author

The CI failure is unrelated.

@philnik777 philnik777 marked this pull request as ready for review April 11, 2025 10:07
@philnik777 philnik777 requested a review from a team as a code owner April 11, 2025 10:07
@philnik777 philnik777 merged commit cb43fe3 into llvm:main Apr 11, 2025
84 of 85 checks passed
@philnik777 philnik777 deleted the remove_libcpp_fallthrough branch April 11, 2025 10:07
@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

We have [[fallthrough]] available in all standards modes, so we can just inline it like other stanard attributes we use.


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

5 Files Affected:

  • (modified) libcxx/include/__config (-3)
  • (modified) libcxx/include/__functional/hash.h (+2-2)
  • (modified) libcxx/include/locale (+1-1)
  • (modified) libcxx/include/regex (+1-1)
  • (modified) libcxx/src/filesystem/path_parser.h (+1-1)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index b6da7114cfc85..e6acd9f237e3f 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1129,9 +1129,6 @@ typedef __char32_t char32_t;
     __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
 #  define _LIBCPP_PACKED __attribute__((__packed__))
 
-// Use a function like macro to imply that it must be followed by a semicolon
-#  define _LIBCPP_FALLTHROUGH() [[fallthrough]]
-
 #  if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
 #    define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
 #  else
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index a191748f2db60..9d3cb71cfc8fa 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -64,10 +64,10 @@ struct __murmur2_or_cityhash<_Size, 32> {
     switch (__len) {
     case 3:
       __h ^= static_cast<_Size>(__data[2] << 16);
-      _LIBCPP_FALLTHROUGH();
+      [[__fallthrough__]];
     case 2:
       __h ^= static_cast<_Size>(__data[1] << 8);
-      _LIBCPP_FALLTHROUGH();
+      [[__fallthrough__]];
     case 1:
       __h ^= __data[0];
       __h *= __m;
diff --git a/libcxx/include/locale b/libcxx/include/locale
index 3afdef856ede7..e4c623e784a8a 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -2421,7 +2421,7 @@ bool money_get<_CharT, _InputIterator>::__do_get(
           return false;
         }
       }
-      _LIBCPP_FALLTHROUGH();
+      [[__fallthrough__]];
     case money_base::none:
       if (__p != 3) {
         while (__b != __e && __ct.is(ctype_base::space, *__b))
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 067f904d4e699..11199b5222175 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -3930,7 +3930,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
       if (__hd == -1)
         std::__throw_regex_error<regex_constants::error_escape>();
       __sum = 16 * __sum + static_cast<unsigned>(__hd);
-      _LIBCPP_FALLTHROUGH();
+      [[__fallthrough__]];
     case 'x':
       ++__first;
       if (__first == __last)
diff --git a/libcxx/src/filesystem/path_parser.h b/libcxx/src/filesystem/path_parser.h
index 06623696452da..5968f449235ba 100644
--- a/libcxx/src/filesystem/path_parser.h
+++ b/libcxx/src/filesystem/path_parser.h
@@ -90,7 +90,7 @@ struct PathParser {
       if (TkEnd)
         return makeState(PS_InRootName, Start, TkEnd);
     }
-      _LIBCPP_FALLTHROUGH();
+      [[__fallthrough__]];
     case PS_InRootName: {
       PosPtr TkEnd = consumeAllSeparators(Start, End);
       if (TkEnd)

var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
We have `[[fallthrough]]` available in all standards modes, so we can
just inline it like other stanard attributes we use.
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.

2 participants