r181439 - Further fix to pointer to member formatting.
Daniel Jasper
djasper at google.com
Wed May 8 08:06:58 PDT 2013
Author: djasper
Date: Wed May 8 10:06:58 2013
New Revision: 181439
URL: http://llvm.org/viewvc/llvm-project?rev=181439&view=rev
Log:
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;
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=181439&r1=181438&r2=181439&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed May 8 10:06:58 2013
@@ -1035,7 +1035,8 @@ bool TokenAnnotator::spaceRequiredBetwee
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))
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=181439&r1=181438&r2=181439&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 8 10:06:58 2013
@@ -2418,7 +2418,7 @@ TEST_F(FormatTest, UnderstandsBinaryOper
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, UnderstandsPointersTo
" ((*a).*f)();\n"
" a.*x;\n"
"}");
+ FormatStyle Style = getLLVMStyle();
+ Style.PointerBindsToType = true;
+ verifyFormat("typedef bool* (Class::*Member)() const;", Style);
}
TEST_F(FormatTest, UnderstandsUnaryOperators) {
More information about the cfe-commits
mailing list