diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -3701,7 +3701,6 @@ bool SpaceAfterOperatorKeyword; /// If \c true, a space will be inserted after the 'operator' keyword in a call expression. - /// This option defaults to SpaceAfterOperatorKeyword. /// \code /// true: false: /// foo.operator ==(...); vs. foo.operator==(...); @@ -4430,7 +4429,8 @@ SpaceAfterCStyleCast == R.SpaceAfterCStyleCast && SpaceAfterLogicalNot == R.SpaceAfterLogicalNot && SpaceAfterOperatorKeyword == R.SpaceAfterOperatorKeyword && - SpaceAfterOperatorKeywordInCall == R.SpaceAfterOperatorKeywordInCall && + SpaceAfterOperatorKeywordInCall == + R.SpaceAfterOperatorKeywordInCall && SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword && SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators && SpaceBeforeCaseColon == R.SpaceBeforeCaseColon && diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -4201,13 +4201,13 @@ // Space in __attribute__((attr)) ::type. if (Left.is(TT_AttributeParen) && Right.is(tok::coloncolon)) return true; - if (Left.is(tok::kw_operator)) { - if (Left.Previous && Left.Previous->isOneOf(tok::coloncolon, tok::period)) - return Style.SpaceAfterOperatorKeywordInCall || Right.is(tok::coloncolon); + if (Left.Previous && + Left.Previous->isOneOf(tok::coloncolon, tok::period)) + return Style.SpaceAfterOperatorKeywordInCall || + Right.is(tok::coloncolon); return Style.SpaceAfterOperatorKeyword || Right.is(tok::coloncolon); } - if (Right.is(tok::l_brace) && Right.is(BK_BracedInit) && !Left.opensScope() && Style.SpaceBeforeCpp11BracedList) { return true; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -22904,7 +22904,6 @@ TEST_F(FormatTest, SpaceAfterOperatorKeyword) { FormatStyle Style = getLLVMStyle(); verifyFormat("bool operator==();", Style); - Style.SpaceAfterOperatorKeyword = true; verifyFormat("bool operator ==();", Style); } @@ -22913,7 +22912,6 @@ FormatStyle Style = getLLVMStyle(); verifyFormat("foo.operator==();", Style); verifyFormat("foo.Foo::operator==();", Style); - Style.SpaceAfterOperatorKeywordInCall = true; verifyFormat("foo.operator ==();", Style); verifyFormat("foo.Foo::operator ==();", Style);