aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/TokenAnnotator.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp1
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 42cbf04aec..08d9b10694 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -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);
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 5b5f483c62..09fbce830e 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -2374,6 +2374,7 @@ TEST_F(FormatTest, UndestandsOverloadedOperators) {
" const aaaaaaaaaaaaaaaaaaaaa &right) {\n"
" return left.group < right.group;\n"
"}");
+ verifyFormat("SomeType &operator=(const SomeType &S);");
verifyGoogleFormat("operator void*();");
verifyGoogleFormat("operator SomeType<SomeType<int>>();");