diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index fc53681394e..71a1a28c85f 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -773,7 +773,11 @@ private: /// operator precedence. class ExpressionParser { public: - ExpressionParser(AnnotatedLine &Line) : Current(Line.First) {} + ExpressionParser(AnnotatedLine &Line) : Current(Line.First) { + // Skip leading "}", e.g. in "} else if (...) {". + if (Current->is(tok::r_brace)) + next(); + } /// \brief Parse expressions with the given operatore precedence. void parse(int Precedence = 0) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 1c2a5404091..19f702f06a6 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2073,6 +2073,10 @@ TEST_F(FormatTest, ExpressionIndentation) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +\n" " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb) {\n}"); + verifyFormat("if () {\n" + "} else if (aaaaa && bbbbb > // break\n" + " ccccc) {\n" + "}"); } TEST_F(FormatTest, ConstructorInitializers) { |

