[clang-format] fix BreakBeforeBraces.MultiLine with for each macros
authorMitchell Balan <mitchell@stellarscience.com>
Wed, 5 Aug 2020 18:29:57 +0000 (14:29 -0400)
committerMitchell Balan <mitchell@stellarscience.com>
Wed, 5 Aug 2020 18:31:42 +0000 (14:31 -0400)
commit7ad60f6452ff483912776ef6eda4e28c60d9da6e
tree5e46dadf1eb6c161eb0e8d1e76fe858b3ef629a8
parent40626184cf95a08f8c62192fa19cd8a71a476206
[clang-format] fix BreakBeforeBraces.MultiLine with for each macros
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

Reviewers: MyDeveloperDay, mitchell-stellar

Reviewed by: mitchell-stellar

Contributed by: vthib

Subscribers: cfe-commits

Tags: #clang, #clang-format, #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D85304
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp