r179270 - Fix formatting of overloaded assignment operators.
Daniel Jasper
djasper at google.com
Thu Apr 11 01:48:21 PDT 2013
Author: djasper
Date: Thu Apr 11 03:48:20 2013
New Revision: 179270
URL: http://llvm.org/viewvc/llvm-project?rev=179270&view=rev
Log:
Fix formatting of overloaded assignment operators.
Before: SomeType &operator=(const SomeType & S);
After: SomeType &operator=(const SomeType &S);
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=179270&r1=179269&r2=179270&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Apr 11 03:48:20 2013
@@ -563,7 +563,8 @@ private:
};
void determineTokenType(AnnotatedToken &Current) {
- if (getPrecedence(Current) == prec::Assignment) {
+ if (getPrecedence(Current) == prec::Assignment &&
+ (!Current.Parent || Current.Parent->isNot(tok::kw_operator))) {
Contexts.back().IsExpression = true;
for (AnnotatedToken *Previous = Current.Parent;
Previous && Previous->isNot(tok::comma);
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=179270&r1=179269&r2=179270&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Apr 11 03:48:20 2013
@@ -2374,6 +2374,7 @@ TEST_F(FormatTest, UndestandsOverloadedO
" const aaaaaaaaaaaaaaaaaaaaa &right) {\n"
" return left.group < right.group;\n"
"}");
+ verifyFormat("SomeType &operator=(const SomeType &S);");
verifyGoogleFormat("operator void*();");
verifyGoogleFormat("operator SomeType<SomeType<int>>();");
More information about the cfe-commits
mailing list