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

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 24 13:52:05 PDT 2026


================
@@ -6821,6 +6821,19 @@ the configuration (without a prefix: ``Auto``).
        # include "A.inc"              # include "A.h"
        # include "A-util.h"           # include "A.inc"
 
+  * ``bool FilesBeforeFolders`` When ``true``, sort includes so that files in a directory appear
----------------
HazardyKnusperkeks wrote:

> > what does it do when its false? does it leave it alone or is it FoldersBeforeFiles?
> 
> The default is `false` which keeps the existing logic intact, i.e. simple alphabetical sorting. When setting to `true` the files are sorted in the proposed way:
> 
>     1. sort files in the folder sort alphabetically
> 
>     2. If there are subfolders:
>        a. sort subfolders alphabetically
>        b. iterate on each subfolder
> 
> 
> > How does it work with "" and <>?
> 
> They are treated the same, so `<boost/cast.hpp>` would be before `<boost/align/align.hpp>`

I meant when mixing `"..."` and `<...>` how does `<boost/cast.hpp>` interact with `"booster.hpp"`?

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


More information about the cfe-commits mailing list