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

via cfe-commits cfe-commits at lists.llvm.org
Mon May 19 09:18:06 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};
----------------
mydeveloperday wrote:

in the documentation you show, neither true/false gives you what clang-format gives us today (with just BasedOnStyle: LLVM

which is ...

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

So lets assume I don't what your feature... how do I keep my current format? what should it be set to true or false?

```
       true:                      false:
       # include "A.h"             # include "A-util.h"
       # include "A.inc"           # include "A.h"
       # include "A-util.h"        # include "A.inc"
```

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


More information about the cfe-commits mailing list