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

Florian Lindner via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 5 03:36:25 PST 2017


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



More information about the cfe-dev mailing list