Ok, we've talked a lot about style, but the document hasn't really been updated:

Things to add:

1) if/while/for statements must use braces unless the entirety of the
statement fits in two lines.  if/elseif/else blocks can skip the
braces only if all blocks fit on two lines.  i.e. (if: 2 lines,
if/else: 4 lines, if/elseif/else: 6lines)

2) Instead of writing accessor functions functions named
setFoo/getFoo, if they do the obvious thing, just name them both foo
and depend on function overloading.  This change also implies that any
private variable should be given the same name as the function but
with a leading underscore.  In this example _foo;
Bad:
  int getFoo() const { return foo; }
  void setFoo(int _foo) { foo = _foo; }
Good:
  int foo() const { return _foo; }
  void foo(int foo) { _foo = foo; }

3) Functions:
template statements should be on a line by themselves
return types should be on their own line
function names should be at the beginning of the line (subject to
indenting rules).
EXCEPTION: In class bodies, the entire statement can be on one line if
it fits within the column limit.

Bad:
class Foo
{
  int foo() const
  {
     do something;
     return var;
  }
};

Good:
class Foo
{
  int
  foo() const
  {
     do something;
     return var;
  }
};

4) Namespaces do not increase the indentation.
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to