[PATCH] Added SpaceAfterFunctionName option

Alexander Kornienko alexfh at google.com
Wed Dec 4 07:25:56 PST 2013


  djasper's comments from the first e-mail thread:
  > Two things I am wondering initially:
  > 1. Do we really need all four combinations of the two boolean flags (for function calls and for control statements)? The answer might be yes, but I'd just like to make sure.
  > 2. How does this affect constructor initializers (": a(1)") and variable declarations ("int a(1);")?

  In the patch, any identifier is considered to be a function name, so spaces will be inserted in these cases as well. The first case may be not difficult to fix, but the second one can be indistinguishable from function declaration: "int a(b);" can mean different things depending on whether b is a constant or a type name. But, luckily, the GNU Coding Standards don't try to distinguish between these [1]:
  "We find it easier to read a program when it has spaces before the open-parentheses and after the commas."

  So we may really want to have a style parameter "SpaceBeforeOpenParenthesis", which will have an option to put spaces before all the parentheses except for a few cases:
    * inside function-like macro definitions: "#define A(x) x" changes the meaning once we insert a space after 'A';
    * after opening parens and brackets: '(', '[';
    * after unary operators: '*', '&', '~', '!';
    * and maybe some other.

  What do you think?

  [1] http://www.gnu.org/prep/standards/standards.html#index-spaces-before-open_002dparen

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



More information about the cfe-commits mailing list