[clang] [clang-format] Add FilesBeforeFolders option to SortIncludes (PR #208954)

Savvas Shiakas via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 19 11:58:11 PDT 2026


Shiakaron wrote:

> While I absolutely share this sorting, it is already possible with the regexes and the priorities without any doubt or confusion.

@HazardyKnusperkeks I have tried to achieve this using regexes and priorities but could only go far due to the iterative nature of this sorting. This is what we have, which fails to replicate the desired logic:

```
IncludeCategories:
  - Regex: '^[^/]*$'
    SortPriority: 0
  - Regex: '^[^/]*/[^/]*$'
    SortPriority: 1
  - Regex: '^[^/]*(/[^/]*){2}$'
    SortPriority: 2
  - Regex: '^[^/]*(/[^/]*){3}$'
    SortPriority: 3
  - Regex: '^[^/]*(/[^/]*){4}$'
    SortPriority: 4
  - Regex: '^[^/]*(/[^/]*){5}$'
    SortPriority: 5
```

Is it possible for you to share the your clang format settings? I would be so happy if this is really possible with the regexes and sort priorities

https://github.com/llvm/llvm-project/pull/208954


More information about the cfe-commits mailing list