]> granicus.if.org Git - clang/commitdiff
Further fix to pointer to member formatting.
authorDaniel Jasper <djasper@google.com>
Wed, 8 May 2013 15:06:58 +0000 (15:06 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 8 May 2013 15:06:58 +0000 (15:06 +0000)
With style where the *s go with the type:
Before: typedef bool* (Class:: *Member)() const;
After:  typedef bool* (Class::*Member)() const;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181439 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ab9c8c88597f5181128d147eaf841782c16113a5..75b173ef4f464f9d0385e081143f7f874bd3275c 100644 (file)
@@ -1035,7 +1035,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
     return Right.FormatTok.Tok.isLiteral() ||
            ((Right.Type != TT_PointerOrReference) &&
             Right.isNot(tok::l_paren) && Style.PointerBindsToType &&
-            Left.Parent && Left.Parent->isNot(tok::l_paren));
+            Left.Parent &&
+            !Left.Parent->isOneOf(tok::l_paren, tok::coloncolon));
   if (Right.is(tok::star) && Left.is(tok::l_paren))
     return false;
   if (Left.is(tok::l_square))
index 715c55fd48bf2f22954727289a05ab9d93b119e3..9e6a60961bce7104636a054efa8f3e13327bebad 100644 (file)
@@ -2418,7 +2418,7 @@ TEST_F(FormatTest, UnderstandsBinaryOperators) {
 TEST_F(FormatTest, UnderstandsPointersToMembers) {
   verifyFormat("int A::*x;");
   verifyFormat("int (S::*func)(void *);");
-  verifyFormat("typedef bool (Class::*Member)() const;");
+  verifyFormat("typedef bool *(Class::*Member)() const;");
   verifyFormat("void f() {\n"
                "  (a->*f)();\n"
                "  a->*x;\n"
@@ -2426,6 +2426,9 @@ TEST_F(FormatTest, UnderstandsPointersToMembers) {
                "  ((*a).*f)();\n"
                "  a.*x;\n"
                "}");
+  FormatStyle Style = getLLVMStyle();
+  Style.PointerBindsToType = true;
+  verifyFormat("typedef bool* (Class::*Member)() const;", Style);
 }
 
 TEST_F(FormatTest, UnderstandsUnaryOperators) {