r185321 - Don't add an extra space before ellipsis after pointers.

Daniel Jasper djasper at google.com
Mon Jul 1 02:47:25 PDT 2013


Author: djasper
Date: Mon Jul  1 04:47:25 2013
New Revision: 185321

URL: http://llvm.org/viewvc/llvm-project?rev=185321&view=rev
Log:
Don't add an extra space before ellipsis after pointers.

Before (for styles where the pointer binds to the type):
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts* ... ts) {}
After:
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts*... ts) {}

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=185321&r1=185320&r2=185321&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jul  1 04:47:25 2013
@@ -1065,6 +1065,8 @@ bool TokenAnnotator::spaceRequiredBetwee
     return !Left.isOneOf(tok::identifier, tok::greater, tok::l_paren);
   if (Left.is(tok::less) || Right.isOneOf(tok::greater, tok::less))
     return false;
+  if (Right.is(tok::ellipsis))
+    return false;
   if (Right.Type == TT_PointerOrReference)
     return Left.Tok.isLiteral() ||
            ((Left.Type != TT_PointerOrReference) && Left.isNot(tok::l_paren) &&
@@ -1110,8 +1112,6 @@ bool TokenAnnotator::spaceRequiredBetwee
   if (Left.isOneOf(tok::identifier, tok::greater, tok::r_square) &&
       Right.is(tok::l_brace) && Right.getNextNoneComment())
     return false;
-  if (Right.is(tok::ellipsis))
-    return false;
   if (Left.is(tok::period) || Right.is(tok::period))
     return false;
   if (Left.Type == TT_BlockComment && Left.TokenText.endswith("=*/"))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=185321&r1=185320&r2=185321&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jul  1 04:47:25 2013
@@ -3284,6 +3284,11 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
 TEST_F(FormatTest, UnderstandsEllipsis) {
   verifyFormat("int printf(const char *fmt, ...);");
   verifyFormat("template <class... Ts> void Foo(Ts... ts) { Foo(ts...); }");
+  verifyFormat("template <class... Ts> void Foo(Ts *... ts) {}");
+
+  FormatStyle PointersLeft = getLLVMStyle();
+  PointersLeft.PointerBindsToType = true;
+  verifyFormat("template <class... Ts> void Foo(Ts*... ts) {}", PointersLeft);
 }
 
 TEST_F(FormatTest, AdaptivelyFormatsPointersAndReferences) {





More information about the cfe-commits mailing list