From: Daniel Jasper Date: Wed, 23 Dec 2015 18:01:29 +0000 (+0000) Subject: clang-format: Fix incorrect pointer detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9d71da68e651373fee5e6f40c9b9e824d069ba5e;p=clang clang-format: Fix incorrect pointer detection. Before: return * this += 1; After: return *this += 1; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256342 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index e06389c317..52dd831b67 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -831,7 +831,7 @@ private: void modifyContext(const FormatToken &Current) { if (Current.getPrecedence() == prec::Assignment && - !Line.First->isOneOf(tok::kw_template, tok::kw_using) && + !Line.First->isOneOf(tok::kw_template, tok::kw_using, tok::kw_return) && (!Current.Previous || Current.Previous->isNot(tok::kw_operator))) { Contexts.back().IsExpression = true; if (!Line.startsWith(TT_UnaryOperator)) { diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 6245f8c043..ac7bd5abf7 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5613,6 +5613,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { Left.PointerAlignment = FormatStyle::PAS_Left; verifyFormat("x = *a(x) = *a(y);", Left); verifyFormat("for (;; * = b) {\n}", Left); + verifyFormat("return *this += 1;", Left); verifyIndependentOfContext("a = *(x + y);"); verifyIndependentOfContext("a = &(x + y);");