r178887 - Fix bad formatting of overloaded operator definitions.
Daniel Jasper
djasper at google.com
Fri Apr 5 10:21:59 PDT 2013
Author: djasper
Date: Fri Apr 5 12:21:59 2013
New Revision: 178887
URL: http://llvm.org/viewvc/llvm-project?rev=178887&view=rev
Log:
Fix bad formatting of overloaded operator definitions.
Before:
bool operator<
(const aaaaaaaaaaaaaaaaaaaaa &left, const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}
After:
bool operator<(const aaaaaaaaaaaaaaaaaaaaa &left,
const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}
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=178887&r1=178886&r2=178887&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Apr 5 12:21:59 2013
@@ -1137,7 +1137,8 @@ bool TokenAnnotator::canBreakBefore(cons
if (Right.Type == TT_ConditionalExpr || Right.is(tok::question))
return true;
if (Right.Type == TT_RangeBasedForLoopColon ||
- Right.Type == TT_InheritanceColon)
+ Right.Type == TT_InheritanceColon ||
+ Right.Type == TT_OverloadedOperatorLParen)
return false;
if (Left.Type == TT_RangeBasedForLoopColon ||
Left.Type == TT_InheritanceColon)
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=178887&r1=178886&r2=178887&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Apr 5 12:21:59 2013
@@ -2226,6 +2226,10 @@ TEST_F(FormatTest, UndestandsOverloadedO
verifyFormat(
"ostream &operator<<(ostream &OutputStream,\n"
" SomeReallyLongType WithSomeReallyLongValue);");
+ verifyFormat("bool operator<(const aaaaaaaaaaaaaaaaaaaaa &left,\n"
+ " const aaaaaaaaaaaaaaaaaaaaa &right) {\n"
+ " return left.group < right.group;\n"
+ "}");
verifyGoogleFormat("operator void*();");
verifyGoogleFormat("operator SomeType<SomeType<int>>();");
More information about the cfe-commits
mailing list