r257330 - clang-format: Fix overloading "operator, " definitions more thoroughly.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 11 04:55:35 PST 2016
Author: djasper
Date: Mon Jan 11 06:55:33 2016
New Revision: 257330
URL: http://llvm.org/viewvc/llvm-project?rev=257330&view=rev
Log:
clang-format: Fix overloading "operator," definitions more thoroughly.
Before:
aaaaaaaaaaaaaaaaaaaaaa operator,(aaaaaaaaaaaaaaaaaaaaa &
aaaaaaaaaaaaaaaaaaaaaaaaaa) const;
After:
aaaaaaaaaaaaaaaaaaaaaa operator,(
aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaaaaaaaaaaaaaaaaaaa) const;
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=257330&r1=257329&r2=257330&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 11 06:55:33 2016
@@ -119,7 +119,9 @@ private:
}
}
- if (Left->Previous &&
+ if (Left->is(TT_OverloadedOperatorLParen)) {
+ Contexts.back().IsExpression = false;
+ } else if (Left->Previous &&
(Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype,
tok::kw_if, tok::kw_while, tok::l_paren,
tok::comma) ||
@@ -132,9 +134,7 @@ private:
// This is a parameter list of a lambda expression.
Contexts.back().IsExpression = false;
} else if (Line.InPPDirective &&
- (!Left->Previous ||
- !Left->Previous->isOneOf(tok::identifier,
- TT_OverloadedOperator))) {
+ (!Left->Previous || !Left->Previous->is(tok::identifier))) {
Contexts.back().IsExpression = true;
} else if (Contexts[Contexts.size() - 2].CaretFound) {
// This is the parameter list of an ObjC block.
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=257330&r1=257329&r2=257330&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 11 06:55:33 2016
@@ -5492,7 +5492,7 @@ TEST_F(FormatTest, UnderstandsOverloaded
verifyFormat("template <typename AAAAAAA, typename BBBBBBB>\n"
"AAAAAAA operator/(const AAAAAAA &a, BBBBBBB &b);");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaa operator,(\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const;");
+ " aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaaaaaaaaaaaaaaaaaaa) const;");
verifyFormat(
"ostream &operator<<(ostream &OutputStream,\n"
More information about the cfe-commits
mailing list