[PATCH] Support GNU style rule to put a space before opening parenthesis.

Daniel Jasper djasper at google.com
Mon Dec 9 06:39:19 PST 2013


  A couple of nits, otherwise looks good.


================
Comment at: include/clang/Format/Format.h:260
@@ +259,3 @@
+  /// \brief Different ways to put a space before opening parentheses.
+  enum SpaceBeforeParensKind {
+    /// Never put a space before opening parentheses.
----------------
nit: ..Kind does not quite feel right (although I might be wrong). How about ..Options?

================
Comment at: include/clang/Format/Format.h:266
@@ +265,3 @@
+    SBPK_ControlStatements,
+    /// Put a space before opening parentheses always, except when it's
+    /// prohibited by the syntax rules (in function-like macro definitions) or
----------------
nit: Move "always" to the beginning.

================
Comment at: include/clang/Format/Format.h:273
@@ +272,3 @@
+
+  /// \brief Defines, in which cases to put a space before opening parentheses.
+  SpaceBeforeParensKind SpaceBeforeParens;
----------------
nit: No comma.

================
Comment at: lib/Format/Format.cpp:100
@@ +99,3 @@
+    IO.enumCase(Value, "Never", clang::format::FormatStyle::SBPK_Never);
+    IO.enumCase(Value, "false", clang::format::FormatStyle::SBPK_Never);
+    IO.enumCase(Value, "ControlStatements",
----------------
Put "true" and "false" next to each other and add:

   // For backward compatibility.

I think soon-ish we'll need to come up with a way to version config files and enable breaking changes.

================
Comment at: unittests/Format/FormatTest.cpp:2085
@@ -2084,2 +2084,3 @@
 TEST_F(FormatTest, RespectWhitespaceInMacroDefinitions) {
-  verifyFormat("#define A (1)");
+  EXPECT_EQ("#define A (x)", format("#define A (x)"));
+  EXPECT_EQ("#define A(x)", format("#define A(x)"));
----------------
I think having this test once is sufficient (it is also below).


http://llvm-reviews.chandlerc.com/D2326

BRANCH
  svn

ARCANIST PROJECT
  clang



More information about the cfe-commits mailing list