[all-commits] [llvm/llvm-project] 12a3af: [clang-format] Remove code related to trigraphs (#...
sstwcw via All-commits
all-commits at lists.llvm.org
Mon Jul 21 08:40:50 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 12a3afe47d4e5fcc97eb44271c00ace7cc8e4ff2
https://github.com/llvm/llvm-project/commit/12a3afe47d4e5fcc97eb44271c00ace7cc8e4ff2
Author: sstwcw <su3e8a96kzlver at posteo.net>
Date: 2025-07-21 (Mon, 21 Jul 2025)
Changed paths:
M clang/lib/Format/FormatTokenLexer.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Remove code related to trigraphs (#148640)
When reviewing #147156, the reviewers pointed out that we didn't need to
support the trigraph. The code never handled it right.
In the debug build, this kind of input caused the assertion in the
function `countLeadingWhitespace` to fail. The release build without
assertions outputted `?` `?` `/` separated by spaces.
```C
#define A ??/
int i;
```
This is because the code in `countLeadingWhitespace` assumed that the
underlying lexer recognized the entire `??/` sequence as a single token.
In fact, the lexer recognized it as 3 separate tokens. The flag to make
the lexer recognize trigraphs was never enabled.
This patch enables the flag in the underlying lexer. This way, the
program now either turns the trigraph into a single `\` or removes it
altogether if the line is short enough. There are operators like the
`??=` in C#. So the flag is not enabled for all input languages. Instead
the check for the token size is moved from the assert line into the if
line.
The problem was introduced by my own patch 370bee480139 from about 3
years ago. I added code to count the number of characters in the escape
sequence probably just because the block of code used to have a comment
saying someone should add the feature. Maybe I forgot to enable
assertions when I ran the code. I found the problem because reviewing
pull request 145243 made me look at the code again.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list