r195552 - clang-format: The "<" of a template argument is not a binary operator.
Daniel Jasper
djasper at google.com
Sat Nov 23 06:45:49 PST 2013
Author: djasper
Date: Sat Nov 23 08:45:49 2013
New Revision: 195552
URL: http://llvm.org/viewvc/llvm-project?rev=195552&view=rev
Log:
clang-format: The "<" of a template argument is not a binary operator.
With Style.BreakBeforeBinaryOperators, clang-format breaks incorrectly.
This fixes llvm.org/PR17994.
Before:
return boost::fusion::at_c<0>(iiii).second == boost::fusion::at_c
<1>(iiii).second;
After:
return boost::fusion::at_c<0>(iiii).second ==
boost::fusion::at_c<1>(iiii).second;
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=195552&r1=195551&r2=195552&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sat Nov 23 08:45:49 2013
@@ -1492,7 +1492,7 @@ bool TokenAnnotator::canBreakBefore(cons
if (Right.Type == TT_CtorInitializerComma &&
Style.BreakConstructorInitializersBeforeComma)
return true;
- if (Right.isBinaryOperator() && Style.BreakBeforeBinaryOperators)
+ if (Right.Type == TT_BinaryOperator && Style.BreakBeforeBinaryOperators)
return true;
if (Left.is(tok::greater) && Right.is(tok::greater) &&
Left.Type != TT_TemplateCloser)
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=195552&r1=195551&r2=195552&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sat Nov 23 08:45:49 2013
@@ -2720,6 +2720,10 @@ TEST_F(FormatTest, ExpressionIndentation
" + sizeof(int32_t) // Offset of CU in the .debug_info section\n"
" + sizeof(int8_t) // Pointer Size (in bytes)\n"
" + sizeof(int8_t); // Segment Size (in bytes)");
+
+ verifyFormat("return boost::fusion::at_c<0>(iiii).second\n"
+ " == boost::fusion::at_c<1>(iiii).second;",
+ Style);
}
TEST_F(FormatTest, ConstructorInitializers) {
More information about the cfe-commits
mailing list