summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp4
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index f6a80342dc7..55a1ddd91c0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1158,7 +1158,9 @@ private:
if (NextToken->is(tok::l_square) && NextToken->isNot(TT_LambdaLSquare))
return TT_PointerOrReference;
- if (NextToken->isOneOf(tok::kw_operator, tok::comma, tok::semi))
+ if (NextToken->is(tok::kw_operator) && !IsExpression)
+ return TT_PointerOrReference;
+ if (NextToken->isOneOf(tok::comma, tok::semi))
return TT_PointerOrReference;
if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen &&
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index a34aa88958f..581b10baafd 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5568,6 +5568,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
// verifyIndependentOfContext("MACRO(A *a);");
verifyFormat("DatumHandle const *operator->() const { return input_; }");
+ verifyFormat("return options != nullptr && operator==(*options);");
EXPECT_EQ("#define OP(x) \\\n"
" ostream &operator<<(ostream &s, const A &a) { \\\n"
OpenPOWER on IntegriCloud