Skip to content
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

[libc++][regex] add _LIBCPP_FALLTHROUGH to suppress fallthrough warning #100821

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

vegerot
Copy link
Contributor

@vegerot vegerot commented Jul 26, 2024

Summary:
The diff #97926 is stacked on top of this patch because this file reports an error when enabling -Wimplicit-fallthrough in -Wextra.

Test plan:

$ time (mkdir build_runtimes && cd build_runtimes && set -x && CC=../build/bin/clang CXX=../build/bin/clang++ cmake -G Ninja ../runtimes -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind'  && ninja && bin/llvm-lit -sv ../libcxx/test/std/re )

note: whether I put a break; or fallthrough, the tests pass anyways which is sus.

@vegerot vegerot requested a review from a team as a code owner July 26, 2024 22:03
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 26, 2024

@llvm/pr-subscribers-libcxx

Author: Max Coplan (vegerot)

Changes

The diff #97926 is stacked on top of this patch because this file reports an error when enabling -Wimplicit-fallthrough in -Wextra


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

1 Files Affected:

  • (modified) libcxx/include/regex (+1-1)
diff --git a/libcxx/include/regex b/libcxx/include/regex
index b814135121321..463fea1638454 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
       if (__hd == -1)
         __throw_regex_error<regex_constants::error_escape>();
       __sum = 16 * __sum + static_cast<unsigned>(__hd);
-      // fallthrough
+    [[clang::fallthrough]];
     case 'x':
       ++__first;
       if (__first == __last)

@@ -3921,7 +3921,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
if (__hd == -1)
__throw_regex_error<regex_constants::error_escape>();
__sum = 16 * __sum + static_cast<unsigned>(__hd);
// fallthrough
[[clang::fallthrough]];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for reviewer: this fallthrough looks strange. Are we sure it shouldn't be a break;?

I should probably change this to a break; and see what tests break...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that we should spell the attribute as [[_Clang::__fallthrough__]] to defend against user-defined macros. (As clang is never reserved and fallthrough is reserved only since C++17.)
Or can we use [[__fallthrough__]]?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that there was a fallthrough comment, I'd assume it was intentional. And, as @frederick-vs-ja we should make this [[__fallthrough__]] instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. done
  2. Whether I put a break; or fallthrough here, the tests pass which is a little sus. (thanks to @philnik777 for helping me run the tests)

@vegerot
Copy link
Contributor Author

vegerot commented Jul 26, 2024

question for reviewer: what is the proper etiquette for stacked diffs? Should I open two PRs or have one PR with two commits?

@mordante
Copy link
Member

question for reviewer: what is the proper etiquette for stacked diffs? Should I open two PRs or have one PR with two commits?

It's only possible to make stacked reviews for members of the LLVM project since it requires write access to the repository. I prefer you wait uploading the next patch until this one lands. Having two patches mixed causes reviewers to review the same code twice.

@vegerot vegerot force-pushed the add-fallthrough-annotation branch from eb83d32 to 1f23197 Compare July 28, 2024 21:02
@vegerot vegerot changed the title [libcxx] [regex] add [[clang::fallthrough]] to suppress fallthrough warning [libcxx] [regex] add [[__fallthrough__]] to suppress fallthrough warning Jul 28, 2024
libcxx/include/regex Outdated Show resolved Hide resolved
Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this can be merged once CI is green.

@ldionne ldionne changed the title [libcxx] [regex] add [[__fallthrough__]] to suppress fallthrough warning [libc++][regex] add _LIBCPP_FALLTHROUGH to suppress fallthrough warning Aug 16, 2024
…ning

Summary:
The diff llvm#97926 is stacked on top of this patch because this file
reports an error when enabling `-Wimplicit-fallthrough` in `-Wextra`.

Test plan:

```sh
$ time (mkdir build_runtimes && cd build_runtimes && set -x && CC=../build/bin/clang CXX=../build/bin/clang++ cmake -G Ninja ../runtimes -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind'  && ninja && bin/llvm-lit -sv ../libcxx/test/std/re )
```

note: whether I put a `break;` or fallthrough, the tests pass anyways
which is sus.
@vegerot vegerot force-pushed the add-fallthrough-annotation branch from 370c6e8 to 9fc7b9b Compare August 17, 2024 21:46
@vegerot
Copy link
Contributor Author

vegerot commented Aug 23, 2024

@ldionne Thanks for the +1! CI is green. Are we good to land?

@ldionne ldionne merged commit 3d18cea into llvm:main Aug 23, 2024
56 checks passed
Copy link

@vegerot Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

cjdb pushed a commit to cjdb/llvm-project that referenced this pull request Aug 23, 2024
dmpolukhin pushed a commit to dmpolukhin/llvm-project that referenced this pull request Sep 2, 2024
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.

6 participants