diff options
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 4feddfd8d4d..94acbd3e4e7 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -93,7 +93,8 @@ private: } } - if (Left->Previous && Left->Previous->is(tok::kw_static_assert)) + if (Left->Previous && Left->Previous->isOneOf(tok::kw_static_assert, + tok::kw_if, tok::kw_while)) Contexts.back().IsExpression = true; if (StartsObjCMethodExpr) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 6cea8a332ad..79e0186a81d 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3712,6 +3712,8 @@ TEST_F(FormatTest, UnderstandsRvalueReferences) { verifyFormat("template <bool B, bool C> class A {\n" " static_assert(B && C, \"Something is wrong\");\n" "};"); + verifyGoogleFormat("#define IF(a, b, c) if (a && (b == c))"); + verifyGoogleFormat("#define WHILE(a, b, c) while (a && (b == c))"); } TEST_F(FormatTest, FormatsBinaryOperatorsPrecedingEquals) { |