clang-format: hangs when a CASE macro is defined and used
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following simple `.clang-format` file, defining a `CASE` macro, results in a hang when trying to format the following simple `poc.cc` file.
```
$ cat .clang-format
Macros:
- CASE=case
$ cat poc.cc
int f() {
switch (42) {
#define CASE(kind)
CASE(1)
CASE(2)
#undef CASE
}
}
$ ./clang-format -version
clang-format version 21.1.3 (https://github.com/llvm/llvm-project 450f52eec88f728c89a9efd667dbeaf2dad93826)
$ ./clang-format poc.cc
^Cinterrupted
```
Contributor guide
Research direction
Reproduce the hang with the .clang-format configuration and poc.cc example using ./clang-format poc.cc. Start by tracing clang-format's handling of the CASE macro around the switch statement; done means the command completes without hanging while preserving the expected formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100