aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-28 13:40:17 +0000
committerDaniel Jasper <djasper@google.com>2013-02-28 13:40:17 +0000
commit9c3c7b3130bc72b3f50703c11b85152b1264fc90 (patch)
tree9310f235d2667a3bd772f99480d006775b254333
parentff9a01000ff74a994aa3da26ea2ec732c97291b7 (diff)
No spaces around pointers to members.
Before: (a ->* f)() After: (a->*f)() git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176252 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/TokenAnnotator.cpp7
-rw-r--r--unittests/Format/FormatTest.cpp1
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 6b91993c4f..5c17223219 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -1027,6 +1027,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if (Tok.Parent->is(tok::comma))
return true;
+ if (Tok.is(tok::comma))
+ return false;
if (Tok.Type == TT_CtorInitializerColon || Tok.Type == TT_ObjCBlockLParen)
return true;
if (Tok.Parent->FormatTok.Tok.is(tok::kw_operator))
@@ -1048,8 +1050,9 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
Tok.Parent->Type == TT_TemplateCloser &&
Style.Standard != FormatStyle::LS_Cpp11;
}
- if (Tok.Type == TT_BinaryOperator ||
- (Tok.Parent->Type == TT_BinaryOperator && Tok.isNot(tok::comma)))
+ if (Tok.is(tok::arrowstar) || Tok.Parent->is(tok::arrowstar))
+ return false;
+ if (Tok.Type == TT_BinaryOperator || Tok.Parent->Type == TT_BinaryOperator)
return true;
if (Tok.Parent->Type == TT_TemplateCloser && Tok.is(tok::l_paren))
return false;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 98e035a598..02c749337e 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1713,6 +1713,7 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
TEST_F(FormatTest, UnderstandsBinaryOperators) {
verifyFormat("COMPARE(a, ==, b);");
+ verifyFormat("(a->*f)()");
}
TEST_F(FormatTest, UnderstandsUnaryOperators) {