Skip to content
Snippets Groups Projects
Commit 4b7b104c authored by Daniel Jasper's avatar Daniel Jasper
Browse files

Further fix to pointer to member formatting.

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
parent 395228fd
No related branches found
No related tags found
No related merge requests found
...@@ -1035,7 +1035,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, ...@@ -1035,7 +1035,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
return Right.FormatTok.Tok.isLiteral() || return Right.FormatTok.Tok.isLiteral() ||
((Right.Type != TT_PointerOrReference) && ((Right.Type != TT_PointerOrReference) &&
Right.isNot(tok::l_paren) && Style.PointerBindsToType && 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)) if (Right.is(tok::star) && Left.is(tok::l_paren))
return false; return false;
if (Left.is(tok::l_square)) if (Left.is(tok::l_square))
......
...@@ -2418,7 +2418,7 @@ TEST_F(FormatTest, UnderstandsBinaryOperators) { ...@@ -2418,7 +2418,7 @@ TEST_F(FormatTest, UnderstandsBinaryOperators) {
TEST_F(FormatTest, UnderstandsPointersToMembers) { TEST_F(FormatTest, UnderstandsPointersToMembers) {
verifyFormat("int A::*x;"); verifyFormat("int A::*x;");
verifyFormat("int (S::*func)(void *);"); verifyFormat("int (S::*func)(void *);");
verifyFormat("typedef bool (Class::*Member)() const;"); verifyFormat("typedef bool *(Class::*Member)() const;");
verifyFormat("void f() {\n" verifyFormat("void f() {\n"
" (a->*f)();\n" " (a->*f)();\n"
" a->*x;\n" " a->*x;\n"
...@@ -2426,6 +2426,9 @@ TEST_F(FormatTest, UnderstandsPointersToMembers) { ...@@ -2426,6 +2426,9 @@ TEST_F(FormatTest, UnderstandsPointersToMembers) {
" ((*a).*f)();\n" " ((*a).*f)();\n"
" a.*x;\n" " a.*x;\n"
"}"); "}");
FormatStyle Style = getLLVMStyle();
Style.PointerBindsToType = true;
verifyFormat("typedef bool* (Class::*Member)() const;", Style);
} }
TEST_F(FormatTest, UnderstandsUnaryOperators) { TEST_F(FormatTest, UnderstandsUnaryOperators) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment