diff options
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 2 |
2 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index efb983e7366..369a37b082e 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -98,8 +98,10 @@ private: } } - if (Left->Previous && Left->Previous->isOneOf(tok::kw_static_assert, - tok::kw_if, tok::kw_while)) { + if (Left->Previous && + (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_if, + tok::kw_while, tok::l_paren, tok::comma) || + Left->Previous->Type == TT_BinaryOperator)) { // static_assert, if and while usually contain expressions. Contexts.back().IsExpression = true; } else if (Left->Previous && Left->Previous->is(tok::r_square) && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 0ae08bcfc07..3da478c0923 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4527,6 +4527,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { FormatStyle PointerLeft = getLLVMStyle(); PointerLeft.PointerBindsToType = true; verifyFormat("delete *x;", PointerLeft); + verifyFormat("STATIC_ASSERT((a & b) == 0);"); + verifyFormat("STATIC_ASSERT(0 == (a & b));"); } TEST_F(FormatTest, UnderstandsAttributes) { |

