[cfe-dev] Understanding clang-format's IncludeIsMainRegex

Eric Liu via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 5 06:01:48 PST 2017


Hi Florian,

Note that clang-format only sorts #includes in the same block. If you
delete the empty line between the two blocks, clang-format should do the
right thing for you.

Cheers,
Eric

On Thu, Jan 5, 2017, 12:36 Florian Lindner via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hello,
>
> I try to understand the IncludeIsMainRegex setting of clang-format
> http://releases.llvm.org/3.9.0/tools/clang/docs/ClangFormatStyleOptions.html
>
> My cpp file indention.cpp contains includes:
>
> #include <string>
>
> #include "../precice/src/action/Action.hpp"
> #include "indention.hpp"
> #include <boost/array.hpp>
>
> Now I try to assess what affect IncludeIsMainRegex has:
>
> 1) IncludeIsMainRegex: '$' (default for style LLVM)
>
> clang-format -style=file indention.cpp
> shows no effect
>
> neither do
>
> 2) IncludeIsMainRegex: ''
> 3) IncludeIsMainRegex: 'hpp$'
> 4) IncludeIsMainRegex: '\.hpp$
> 5) IncludeIsMainRegex: '.hpp$
>
>
> According to the documentation I expected that 2 and 3 match the suffix
> and assign category 0 to the include, thus placing it at the top.
>
> Where is my understanding wrong?
>
> Thanks,
> Florian
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170105/55a639da/attachment.html>


More information about the cfe-dev mailing list