[PATCH] D43957: Fixing issue where a space was not added before a global namespace variable when SpacesInParentheses is set

Darby Payne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 20 15:40:54 PDT 2018


dpayne updated this revision to Diff 139212.
dpayne added a comment.

Adding a unit test for formatting a global namespace var with SpacesInParentheses enabled.


Repository:
  rC Clang

https://reviews.llvm.org/D43957

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8797,6 +8797,7 @@
   FormatStyle Spaces = getLLVMStyle();
 
   Spaces.SpacesInParentheses = true;
+  verifyFormat("do_something( ::globalVar );", Spaces);
   verifyFormat("call( x, y, z );", Spaces);
   verifyFormat("call();", Spaces);
   verifyFormat("std::function<void( int, int )> callback;", Spaces);
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2631,7 +2631,8 @@
             Style.Standard == FormatStyle::LS_Cpp03) ||
            !(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
                           tok::kw___super, TT_TemplateCloser,
-                          TT_TemplateOpener));
+                          TT_TemplateOpener)) ||
+           (Left.is(tok ::l_paren) && Style.SpacesInParentheses);
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
     return Style.SpacesInAngles;
   // Space before TT_StructuredBindingLSquare.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43957.139212.patch
Type: text/x-patch
Size: 1191 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180320/92dcb972/attachment.bin>


More information about the cfe-commits mailing list