llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[BitInt] Expose a _BitInt literal suffix in C++

Open erichkeane opened this issue 2 years ago • 6 comments

The C literal suffix for _BitInt is 'wb' or 'WB' (also allows a 'u' modifier for unsigned). We expose _BitInt in C++ as an extension, but do NOT expose the suffix, as it is one that the C++ committee might choose to use something else.

We should NOT do a single underscore, as that is reserved for the user defined literals (https://eel.is/c++draft/usrlit.suffix).

However, that standardeeze allows double-underscores for use by the implementation, so we could implement this with double-underscores without problem!

So allow: 123__WB, etc.

erichkeane avatar Mar 14 '24 13:03 erichkeane

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. In the comments of the issue, request for it to be assigned to you.
  2. Fix the issue locally.
  3. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  4. Create a Git commit.
  5. Run git clang-format HEAD~1 to format your changes.
  6. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

llvmbot avatar Mar 14 '24 13:03 llvmbot

@llvm/issue-subscribers-good-first-issue

Author: Erich Keane (erichkeane)

The C literal suffix for _BitInt is 'wb' or 'WB' (also allows a 'u' modifier for unsigned). We expose _BitInt in C++ as an extension, but do NOT expose the suffix, as it is one that the C++ committee might choose to use something else.

We should NOT do a single underscore, as that is reserved for the user defined literals (https://eel.is/c++draft/usrlit.suffix).

However, that standardeeze allows double-underscores for use by the implementation, so we could implement this with double-underscores without problem!

llvmbot avatar Mar 14 '24 13:03 llvmbot

@llvm/issue-subscribers-clang-frontend

Author: Erich Keane (erichkeane)

The C literal suffix for _BitInt is 'wb' or 'WB' (also allows a 'u' modifier for unsigned). We expose _BitInt in C++ as an extension, but do NOT expose the suffix, as it is one that the C++ committee might choose to use something else.

We should NOT do a single underscore, as that is reserved for the user defined literals (https://eel.is/c++draft/usrlit.suffix).

However, that standardeeze allows double-underscores for use by the implementation, so we could implement this with double-underscores without problem!

So allow: 123__WB, etc.

llvmbot avatar Mar 14 '24 14:03 llvmbot

Hi, I'm interested in taking on this issue, could I have it assigned to me?

js324 avatar Mar 14 '24 16:03 js324

Hi, I'm interested in taking on this issue, could I have it assigned to me?

Done! Sadly I'm away after today and won't be back until April, so my reviews on whatever you submit are going to be delayed.

However, make sure you include a 'release note' (See ReleaseNotes.rst), an 'extension' warning (we have others, you should be able to search our DiagnosticXKinds.td for "extension", and sufficient testing for this (I'd imagine an AST test and some sort of static-assert based -verify one that makes sure the values are the same/allow large values/etc.

Thanks!

erichkeane avatar Mar 14 '24 17:03 erichkeane

@erichkeane Hi, created a PR for this. I've included the things you've mentioned, but for testing, I ended up mostly using the same existing _BitInt literal cases as I thought they were comprehensive enough already. Also, I'm not sure if my parsing implementation was the best/most optimal way to do this. Please let me know if there's anything to change, thanks!

js324 avatar Mar 25 '24 21:03 js324