<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118002>118002</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[ClangFormat] Adjusting Include Order for Main Headers by Prefix Match
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
thirumurugan-git
</td>
</tr>
</table>
<pre>
Does the `IncludeIsMainRegex` option in the Clang format file only search for the suffix in the header stem? Is there an option to check the header prefix to identify it as "not a main file"? For example, consider the following code:
```cpp
// file: a.cc
#include "b.h"
#include "../a.h"
// some code
```
When formatting this, `a.h` is prioritized as `0` (default) and always appears first. However, I want it to be placed last. Does Clang-Format support any option in the `.clang-format` file to address this, or would I need to use `clang-off` for the include section?
**Note:** The include must retain the relative path. Alternate approaches are not feasible. Could such an option be introduced in the future?"
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcVNFu7CYQ_Rr8MoqF8a6z--CHNJF183DbqqrU5zEer7nFYMGQzfbrK_AmN7oSkmUYzjnMOYAxmosj6sXxN3F8qTDx4kPPiwlpTSFd0D1cDFejn279i6cIvBCITr46bdNEr_E7GvcXXehddBL8xsY7MK6UPVt0F5h9WJFhNpbAO3uDSBj0kudLVUzzbN4_9iyEEwWITKtoB3gthIEA3Qc4e9AL6X-_lm-BMgZ7MBM5NvMNDANGEEo5z4CwonFFg1AqAw8-AL3juuWZZ9DeRZORMujsrfVX4y6g_USifRKyjE7uQ29b_lWDUMOO2T4B1lqX2dbsrcncY71kvl-n61qoAT_XPrGiX2nn_MK2V_yzkLu3krMyXkzMwkUnM1AnwUTYgvHBsPmPpnL4TmYAEOo00YzJslBnQDcB2iveIuC2EYYIswmRa_jmr_RGIcO-whUd5yayh5Fgs6hpAou5ruSgmPsw7ObGtG0-MKC7_ZIB0clal9JdfNZTosAecJoCxfh5Fh_g6pOd4BUc0ZRLUiwQO4Kf57L9HpyPhkbSmTG7-tHNPH73XLwrP_D3lw1rigyBGO8aA1lk80awIS81PFmm4JAp9yd41AtFwECQkzQTRjNaquG5SI1JL1_COWYWDn5KuV13_DlxCiTaQShVTX07ndszVtQ3j606yUZ2qlp6Kc-nx_O5lcdZdnqk-TA2jeweUZOeW6kq0yupDk2jTk3bPh6aum0Op6PsVKsPp1adOnGQtKKxtbVva-3DpTIxJuqb5iSlqiyOZGO56Eo5ukJZzRE8vlShz5sexnSJ4iCtiRx_wrBhW16I4vluuTi-wNP0I8WSxvtrAH-EfIeyQflZgG_ldkYYb_DnfkO_I-ulSsH2C_MWiz85-hfDSxpr7Vehhkx8_zxswf8gzUINRW4Uarif561X_wcAAP__LqyLaA">