| Issue |
60586
|
| Summary |
[clang-format] IncludeCategories: Add a regex group named main into the Regex Solver
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Febbe
|
There are many issues, regarding main file sorting.
Also, we have the issue, that a main source file can have 2 main headers, e.g. `a.cpp` `a.h` and `a_priv.h`
With IncludeIsMainRegex and IncludeIsMainSourceRegex only a mapping between a header to a source can be defined, but not the other way round.
A solution to all issues would be, to add a parameter in the form of a named capture group to the regex.
For example, a hypothetical group definition (?<main>regex) would map to `\k<main>`, which then maps to the main file's stem.
```
IncludeCategories:
- Regex: '\k<main>_priv\.h"$'
Priority: 0
```
The above would then match `a_priv.h` as expected.
With that, programmers could also override the default behavior, to accomplish:
#58284
#37620 #39735 #53013
Possible implementation could be:
- generate all possible main-header stems from IncludeIsMainRegex and IncludeIsMainSourceRegex
- supply all (including the original stem) to the Regex solver as group (do this in a loop, if it's not possible to accomplish this via one group)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs