]> granicus.if.org Git - clang/commitdiff
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)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211487 91177308-0d34-0410-b5e6-96231b3b80d8

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

index dd1c6819e28a625f75599a9d8b1bf51e1a629dad..fdad75917c64c0e89bf2b09597551847d1af7bad 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 13954fa6f86ebf580d5cdd125d3d8d27516936da..968e13b3feba30b6869f5390e8d5df6889e0e63b 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"