From: Daniel Jasper Date: Mon, 23 Jun 2014 07:36:18 +0000 (+0000) Subject: clang-format: Fix corner case in pointer/reference detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=300efe86485d2c8858bbd649f4bf5042a88ebcd1;p=clang clang-format: Fix corner case in pointer/reference detection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211487 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index dd1c6819e2..fdad75917c 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -918,6 +918,8 @@ private: if (NextToken->is(tok::l_square) && NextToken->Type != TT_LambdaLSquare) return TT_PointerOrReference; + if (NextToken->is(tok::kw_operator)) + return TT_PointerOrReference; if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen && PrevToken->MatchingParen->Previous && diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 13954fa6f8..968e13b3fe 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4844,6 +4844,8 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { // FIXME: Is there a way to make this work? // verifyIndependentOfContext("MACRO(A *a);"); + verifyFormat("DatumHandle const *operator->() const { return input_; }"); + EXPECT_EQ("#define OP(x) \\\n" " ostream &operator<<(ostream &s, const A &a) { \\\n" " return s << a.DebugString(); \\\n"