[libc] [llvm] [libc] Add user defined literals to ease testing (PR #81267)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 08:28:48 PST 2024


https://github.com/nickdesaulniers commented:

Do you forsee usage of these literals outside of libc/test/src/__support/FPUtil/fpbits_test.cpp?  It seems like a fair amount of complexity added just to avoid typing out `static_cast<>()` in libc/test/src/__support/FPUtil/fpbits_test.cpp. libc/test/src/__support/FPUtil/fpbits_test.cpp is already inconsistent of its use of static_cast vs constructor calls.

The literal syntax doesn't save us much typing over just using the constructors:
```c++
static_cast<uint16_t>(1)
u16(1)
1_u16
```
I do like the idea of these suffixes (they remind me of rust, which I think has these), but if the goal is just to simplify libc/test/src/__support/FPUtil/fpbits_test.cpp then I think we can just consistently use the constructor functions rather than `static_cast` consistently throughout libc/test/src/__support/FPUtil/fpbits_test.cpp without adding support for custom literals.

https://github.com/llvm/llvm-project/pull/81267


More information about the llvm-commits mailing list