[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 4 23:06:53 PDT 2025
https://github.com/owenca requested changes to this pull request.
It seems that we don't need to add a separate formatting pass for this new option as changing the case of letters in numeric literals has no impact on any existing passes. IMO, the best place to handle this is in `FormatTokenLexer::getNextToken()`. For example:
```cpp
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -1313,6 +1313,9 @@ FormatToken *FormatTokenLexer::getNextToken() {
}
WhitespaceLength += Text.size();
readRawToken(*FormatTok);
+ if (FormatTok->Finalized || FormatTok->isNot(tok::numeric_constant))
+ continue;
+ // Handle Style.NumericLiteralCase here.
}
if (FormatTok->is(tok::unknown))
```
https://github.com/llvm/llvm-project/pull/151590
More information about the cfe-commits
mailing list