[clang] clang-format: Add IncludeSortKey option (PR #137840)

Daan De Meyer via cfe-commits cfe-commits at lists.llvm.org
Mon May 19 10:33:25 PDT 2025


================
@@ -1647,7 +1647,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
   LLVMStyle.SeparateDefinitionBlocks = FormatStyle::SDS_Leave;
   LLVMStyle.ShortNamespaceLines = 1;
   LLVMStyle.SkipMacroDefinitionBody = false;
-  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false};
+  LLVMStyle.SortIncludes = {/*Enabled=*/true, /*IgnoreCase=*/false, /*IgnoreExtension=*/false};
----------------
DaanDeMeyer wrote:

```
#include "A.h"
#include "A-util.h"
#include "A.inc"
```

I don't see how clang-format would ever return this today without disabling include sorting? `-` sorts before `.` so `A-util.h` will always be put before `A.h` and `A.inc` today if include sorting is enabled.

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


More information about the cfe-commits mailing list