clang-format: Patches and Questions

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dear All

I hope this is the right list to post to.

I've been experimenting with clang-format to find whether it will suit
our needs. I must say it's pretty impressive work. I like it a lot.

The only problem is that some of the styling we want to use isn't
supported yet. So I started trying to add support for the things we need
with varying degrees of success.

So far I've added 2 features:

The first is AttachNamespaceBraces. This overrides the normal
brace-attachment rules for namespaces (e.g. Allman), forcing the
egyptian braces for namespaces.

The second is ContinuationAlignment. This can either be:
AlignToParenthesis (the current behaviour)...

void foo_bar_foo_bar_foo_bar_foo_bar_foo(int a, int b, int c, int d, int e,
                                         int f, int g, int h, int i, int j,
                                         int k, int l, int m, int n, int o,
                                         int p, int q, int r, int s, int s,
                                         int u, int v, int w, int x)
{
  if (far_too_long_variable_names_are_painful ==
        far_too_long_variable_names_are_painful ||
      (far_too_long_variable_names_are_painful !=
       far_too_long_variable_names_are_painful))
    exit(1);
}

...and SingleIndent:

void foo_bar_foo_bar_foo_bar_foo_bar_foo(int a, int b, int c, int d, int e,
  int f, int g, int h, int i, int j, int k, int l, int m, int n, int o,
int p,
  int q, int r, int s, int s, int u, int v, int w, int x)
{
  if (far_too_long_variable_names_are_painful ==
    far_too_long_variable_names_are_painful ||
    (far_too_long_variable_names_are_painful !=
    far_too_long_variable_names_are_painful))
    exit(1);
}

These patches are published here: https://github.com/jhol/clang/commits/work
Could someone review the design and implementation of these?

There a few other things I'd like to have. Could anyone give me any
pointers about how to achieve these things?

1. The colon for initialiser lists is in the wrong position for our
style. We have it like this, attached to the line above:

Foo::Foo() :
  _first(1),
  _second(2)
{
}

I tried to figure out how to make this change, and failed.

2. For some reason clang-format deletes the empty line after after the
last function in a namespace:

namespace foo {

void bar()
{
}
}

Is it possible to correct this?

3. Astyle has a --remove-brackets feature that can removed the braces
from single line if statements:

Converting this...

if (1)
{
  do_something();
}
else
{
  do_something_else();
}

...to this....

if (1)
  do_something();
else
  do_something_else();

Thanks
Joel Holdsworth