[PATCH] [clang-format] Add SpaceBeforeBrackets

Daniel Jasper djasper at google.com
Thu Apr 16 01:38:50 PDT 2015


Sorry it took me so long to reply.


================
Comment at: include/clang/Format/Format.h:356-357
@@ -355,1 +355,4 @@
 
+  /// \brief If \c true, a space will be inserted between identifer and '['.
+  bool SpaceBeforeBrackets;
+
----------------
To be consistent with the option above, this should probably be called SpaceBeforeSquareBrackets. This is to make clear that this is not considering angle brackets or curly brackets.

However, I am actually not sure that is the best name. I think you are only trying to change the behavior for array subscripts. Maybe we should name the option accordingly (SpaceBeforeArraySubscripts). We can also rename SpaceInSquareBrackets correspondingly (I'll do that in a separate follow-up patch as it is a little bit tedious to be backwards compatible).

================
Comment at: unittests/Format/FormatTest.cpp:7992
@@ -7991,1 +7991,3 @@
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeBrackets) {
+    FormatStyle NoSpace = getLLVMStyle();
----------------
If this is only targeting array subscripts as I presume, please add corresponding tests that it doesn't influence other behavior, specifically lambdas and objc method expressions (e.g. "f([] {});").

Also not that array subscripts can be written the other way around "1[a]" is identical to "a[1]". Add a test for that as well.

http://reviews.llvm.org/D6920

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list