Index: cfe/trunk/docs/ClangFormatStyleOptions.rst =================================================================== --- cfe/trunk/docs/ClangFormatStyleOptions.rst +++ cfe/trunk/docs/ClangFormatStyleOptions.rst @@ -2050,8 +2050,8 @@ .. code-block:: c++ true: false: - int a = 5; vs. int a=5; - a += 42 a+=42; + int a = 5; vs. int a= 5; + a += 42; a+= 42; **SpaceBeforeCpp11BracedList** (``bool``) If ``true``, a space will be inserted before a C++11 braced list Index: cfe/trunk/include/clang/Format/Format.h =================================================================== --- cfe/trunk/include/clang/Format/Format.h +++ cfe/trunk/include/clang/Format/Format.h @@ -1738,8 +1738,8 @@ /// If ``false``, spaces will be removed before assignment operators. /// \code /// true: false: - /// int a = 5; vs. int a=5; - /// a += 42 a+=42; + /// int a = 5; vs. int a= 5; + /// a += 42; a+= 42; /// \endcode bool SpaceBeforeAssignmentOperators; Index: cfe/trunk/lib/Format/TokenAnnotator.cpp =================================================================== --- cfe/trunk/lib/Format/TokenAnnotator.cpp +++ cfe/trunk/lib/Format/TokenAnnotator.cpp @@ -2870,7 +2870,7 @@ Left.isOneOf(tok::arrow, tok::period, tok::arrowstar, tok::periodstar) || (Right.is(tok::period) && Right.isNot(TT_DesignatedInitializerPeriod))) return false; - if (!Style.SpaceBeforeAssignmentOperators && + if (!Style.SpaceBeforeAssignmentOperators && Left.isNot(TT_TemplateCloser) && Right.getPrecedence() == prec::Assignment) return false; if (Style.Language == FormatStyle::LK_Java && Right.is(tok::coloncolon) && Index: cfe/trunk/unittests/Format/FormatTest.cpp =================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp +++ cfe/trunk/unittests/Format/FormatTest.cpp @@ -6620,8 +6620,15 @@ verifyFormat("A> a;", getChromiumStyle(FormatStyle::LK_Cpp)); - verifyFormat("int i = a<1> >> 1;"); + // template closer followed by a token that starts with > or = verifyFormat("bool b = a<1> > 1;"); + verifyFormat("bool b = a<1> >= 1;"); + verifyFormat("int i = a<1> >> 1;"); + FormatStyle Style = getLLVMStyle(); + Style.SpaceBeforeAssignmentOperators = false; + verifyFormat("bool b= a<1> == 1;", Style); + verifyFormat("a = 1;", Style); + verifyFormat("a >>= 1;", Style); verifyFormat("test >> a >> b;"); verifyFormat("test << a >> b;");