Issue |
145189
|
Summary |
[clang-format] IntegerLiteralSeparator breaks preprocessing conditionals with digit separators
|
Labels |
clang-format
|
Assignees |
|
Reporter |
MorganCaron
|
I'm using clang-format with the following ``IntegerLiteralSeparator`` settings:
```yaml
IntegerLiteralSeparator:
Binary: 4
Decimal: 3
Hex: 2
```
When formatting code like this:
```cpp
#if __cpp_lib_smart_ptr_owner_equality >= 202306L
```
clang-format transforms it into:
```cpp
#if __cpp_lib_smart_ptr_owner_equality >= 202'306L
```
which causes a compilation error because the preprocessor does not accept digit separators ``'`` in numeric literals inside directives.
I’m aware that since C++20, there is an alternative to test feature macros using:
```cpp
#if __has_cpp_attribute(__cpp_lib_smart_ptr_owner_equality)
```
However, it would still be useful to have either:
- an option to disable ``IntegerLiteralSeparator`` only inside preprocessor directives, or
- for the behavior to be changed so that ``IntegerLiteralSeparator`` is not applied at all to preprocessor lines or specific preprocessor instructions such as ``#if``
This suggestion is intended to make formatting smoother and avoid breaking code when numeric literals appear in preprocessor conditionals
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs