clang-format: Fix corner case in pointer/reference detection.
authorDaniel Jasper <djasper@google.com>
Mon, 23 Jun 2014 07:36:18 +0000 (07:36 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 23 Jun 2014 07:36:18 +0000 (07:36 +0000)
llvm-svn: 211487

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

index dd1c681..fdad759 100644 (file)
@@ -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 &&
index 13954fa..968e13b 100644 (file)
@@ -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"