<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63619>63619</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang-format SortIncludes does not allow main headers in <> instead of ""
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          aristotelos
      </td>
    </tr>
</table>

<pre>
    Clang-format has advanced detection of the "main header" of a C++ file to keep it as the first include. However, this only works if the main header file is referenced using double quotes (`"myproject/MyClass.h"`), not if the main header is referenced using angle brackets (`<myproject/MyClass.h>`). This is invalid because there is no strict rule to put main header includes into double quotes.

## Root cause

Clang-format has [a hard-coded check that the main header file should be included with double quotes](https://github.com/llvm/llvm-project/blob/d32fb5e5f51dedba495301073b9250f84ac6d8a8/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp#L237). 

## Reproduction scenario

Project layout:
```
myproject
   include
      myproject
 MyClass.h
   src
       MyClass.cc
```

.clang-format file:
```
SortIncludes: true
```

MyClass.cc:
```
#include <myproject/MyClass.h>
#include <anotherproject/OtherClass.h>
```

Clang-format will reformat this to:
```
#include <anotherproject/OtherClass.h>
#include <myproject/MyClass.h>
```
because it doesn't recognize `<myproject/MyClass.h>` as the main header reference.

Workaround: change MyClass.cc to:
```
#include "myproject/MyClass.h"
#include <anotherproject/OtherClass.h>
```


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVU1v4zYQ_TX0ZRBBJi1HOuiQjzV2gRYt2gV6HpFjiw3DcUkqhvvrC0pxLHe9aRYoYMgYkMP35g3nEWO0O0_UiupeVI8LHFLPocVgY-JEjuOiY3NsHxz63c2WwzMm6DECmhf0mgwYSqSTZQ-8hdQTCCmf0XroCQ0FIWVeQHgQ8l7Ie9haR5AYnoj2YBNgHLO2NsQE1ms3GCrgMx_oJWc_QOptBPbuCAcOT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