Issue |
142426
|
Summary |
[clang-format] Clang format takes way too long to format some preproc macros
|
Labels |
clang,
clang-format
|
Assignees |
|
Reporter |
JustLinuxUser
|
I have been playing around with the preproc macros, and I created a binary counter with the macros. A curious thing I noticed, is that clang-format quickly runs out of memory formatting this file.
I've simplified the file, to the minimum laggy example, let's call it example.h,
```c
#if b0 == 1
# if b1 == 1
# if b2 == 1
# if b3 == 1
# if b4 == 1
# if b5 == 1
# if b6 == 1
# if b7 == 1
# if b8 == 1
# if b9 == 1
# if b10 == 1
# if b11 == 1
# if b12 == 1
# if b13 == 1
# if b14 == 1
# if b15 == 1
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
# else
# endif
#endif
```
calling `clang-format example.h` takes ~10s on my computer, adding one more bit ~20s
It seams like clang-format is checking every combination of possibilities of the preprocessor macros, and I don't understand why.
I've also attached the original counter.h example, here is how to use it:
```c
#define VALUE 0
#include "counter.h"
// now the VALUE is 1
#include "counter.h"
// now the VALUE is 2
```
[counter.txt](https://github.com/user-attachments/files/20555612/counter.txt)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs