r198769 - clang-format: Fix spacing in Cpp11 braced lists:

Daniel Jasper djasper at google.com
Wed Jan 8 07:41:13 PST 2014


Author: djasper
Date: Wed Jan  8 09:41:13 2014
New Revision: 198769

URL: http://llvm.org/viewvc/llvm-project?rev=198769&view=rev
Log:
clang-format: Fix spacing in Cpp11 braced lists:

Before:
  vector<int> foo{ ::SomeFunction()};

After:
  vector<int> foo{::SomeFunction()};

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=198769&r1=198768&r2=198769&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jan  8 09:41:13 2014
@@ -1278,7 +1278,7 @@ bool TokenAnnotator::spaceRequiredBetwee
     return false;
   if (Left.is(tok::coloncolon))
     return false;
-  if (Right.is(tok::coloncolon))
+  if (Right.is(tok::coloncolon) && Left.isNot(tok::l_brace))
     return (Left.is(tok::less) && Style.Standard == FormatStyle::LS_Cpp03) ||
            !Left.isOneOf(tok::identifier, tok::greater, tok::l_paren,
                          tok::r_paren, tok::less);

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=198769&r1=198768&r2=198769&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan  8 09:41:13 2014
@@ -4826,6 +4826,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
                  "  aaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaa,\n"
                  "  aaaaaaa,      a\n"
                  "};");
+    verifyFormat("vector<int> foo = { ::SomeGlobalFunction() };");
 
     FormatStyle NoSpaces = getLLVMStyle();
     NoSpaces.Cpp11BracedListStyle = true;
@@ -4846,6 +4847,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
                  "  T member = {arg1, arg2};\n"
                  "};",
                  NoSpaces);
+    verifyFormat("vector<int> foo = {::SomeGlobalFunction()};", NoSpaces);
 
     // FIXME: The alignment of these trailing comments might be bad. Then again,
     // this might be utterly useless in real code.





More information about the cfe-commits mailing list