Skip to content

[libc][stdbit][c23] fixes typos in bit_width, bit_floor C type-generic macros #84659

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
Mar 10, 2024

Conversation

Flandini
Copy link
Contributor

Fixes #84658.

Assuming these were typos in the first place.

I am unsure of the best way to ensure that both sides of the preprocessor condition in libc/include/llvm-libc-macros/stdbit-macros.h are tested. Could someone point me in the right direction for adding test coverage to the non __cplusplus branch? Or maybe it is being tested and I've missed it.

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 label Mar 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 10, 2024

@llvm/pr-subscribers-libc

Author: Michael Flanders (Flandini)

Changes

Fixes #84658.

Assuming these were typos in the first place.

I am unsure of the best way to ensure that both sides of the preprocessor condition in libc/include/llvm-libc-macros/stdbit-macros.h are tested. Could someone point me in the right direction for adding test coverage to the non __cplusplus branch? Or maybe it is being tested and I've missed it.


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

1 Files Affected:

  • (modified) libc/include/llvm-libc-macros/stdbit-macros.h (+2-2)
diff --git a/libc/include/llvm-libc-macros/stdbit-macros.h b/libc/include/llvm-libc-macros/stdbit-macros.h
index 5b51068f866b71..e3eb6630afddb6 100644
--- a/libc/include/llvm-libc-macros/stdbit-macros.h
+++ b/libc/include/llvm-libc-macros/stdbit-macros.h
@@ -274,14 +274,14 @@ inline unsigned long long stdc_bit_floor(unsigned long long x) {
       unsigned long long: stdc_has_single_bit_ull)(x)
 #define stdc_bit_width(x)                                                      \
   _Generic((x),                                                                \
-      unsigned char: stdc_bit_width_ui,                                        \
+      unsigned char: stdc_bit_width_uc,                                        \
       unsigned short: stdc_bit_width_us,                                       \
       unsigned: stdc_bit_width_ui,                                             \
       unsigned long: stdc_bit_width_ul,                                        \
       unsigned long long: stdc_bit_width_ull)(x)
 #define stdc_bit_floor(x)                                                      \
   _Generic((x),                                                                \
-      unsigned char: stdc_bit_floor_ui,                                        \
+      unsigned char: stdc_bit_floor_uc,                                        \
       unsigned short: stdc_bit_floor_us,                                       \
       unsigned: stdc_bit_floor_ui,                                             \
       unsigned long: stdc_bit_floor_ul,                                        \

@lntue lntue self-requested a review March 10, 2024 05:07
Copy link
Contributor

@lntue lntue left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@lntue lntue merged commit 35b7843 into llvm:main Mar 10, 2024
Copy link

@Flandini 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 recieve 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!

@Flandini Flandini deleted the stdbit-tgm-typos branch March 10, 2024 06:48
@nickdesaulniers
Copy link
Member

Thanks for the patch!

So in order to support _BitInt, these macros all need to go in the garbage anyway and be replaced with if/else nests using if sizeof(param) < 8: stdc_foo_uc((char)param); else if sizeof(param) < 16: stdc_foo_us((short)param); ....

I'm not sure if gtest can be used to test code in C mode, but these macros all need to get rewritten anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc][stdbit] Typos in type generic macros for bit_width, bit_floor
4 participants