This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] fix BreakBeforeBraces.MultiLine with for each macros
ClosedPublic

Authored by vthib on Aug 5 2020, 7:02 AM.

Details

Summary

The MultiLine option in BreakBeforeBraces was only handling standard
control statement, leading to invalid indentation with for each macros:

Previous behavior:

/* invalid: brace should be on the same line */
Q_FOREACH(int a; list)
{
    foo();
}

/* valid */
Q_FOREACH(int longVariable;
          list)
{
    foo();
}

To fix this, simply add the TT_ForEachMacro kind in the list of
recognized control statements for the multiline option.

This is a fix for https://bugs.llvm.org/show_bug.cgi?id=44632

Diff Detail

Event Timeline

vthib created this revision.Aug 5 2020, 7:02 AM
vthib requested review of this revision.Aug 5 2020, 7:02 AM
This revision is now accepted and ready to land.Aug 5 2020, 11:04 AM