[clang] [clang-format] Don't case-fix numeric literals in macro invocations (PR #212328)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 00:48:17 PDT 2026
owenca wrote:
> We can easily skip C/C++ preprocessor directives
For example:
```diff
--- a/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ b/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -101,8 +101,12 @@ IntegerLiteralSeparatorFixer::process(const Environment &Env,
Token Tok;
tooling::Replacements Result;
- for (bool Skip = false; !Lex.LexFromRawLexer(Tok);) {
+ for (bool Skip = false, IsPPLine = false; !Lex.LexFromRawLexer(Tok);) {
auto Length = Tok.getLength();
+ if (Tok.isAtStartOfLine())
+ IsPPLine = Tok.is(tok::hash);
+ if (IsPPLine)
+ continue;
if (Length < 2)
continue;
auto Location = Tok.getLocation();
```
https://github.com/llvm/llvm-project/pull/212328
More information about the cfe-commits
mailing list