[cfe-dev] clang-format identation with BreakBeforeBraces: GNU and #define
via cfe-dev
cfe-dev at lists.llvm.org
Thu Feb 6 14:08:19 PST 2020
Dear all,
Versions of clang-format 3.5.2-10 incorrectly format identation when
BreakBeforeBraces: GNU has been selected and #ifdefs are used then
comments gets idented wrongly.
Example using clang-format 10.0.0+b452de0
function test()
{
#ifdef TEST1
if (test1)
{
printf("test1");
}
#endif
/* This comment has been indented wrong */
#ifdef TEST2
if (test2)
{
printf("test1");
}
#endif
}
function test()
{
if (test1)
{
printf("test1");
}
/* This comment has been indented correct */
if (test2)
{
printf("test1");
}
}
Is this defined behavior? It only occurs when there is a comment
between two ifdef blocks.
Adding a variable between will yield the correct indentation
function test()
{
#ifdef TEST1
if (test1)
{
printf("test1");
}
#endif
/* This comment has been indented correct */
int test = 0;
#ifdef TEST2
if (test2)
{
printf("test1");
}
#endif
}
More information about the cfe-dev
mailing list