style guidelines

Probably this has come up before... but have we considered just adopting the Google style guidlines and maybe modifying it in some places?

They have a nice script for c++ which will check for many things.

http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml

http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py

Probably this has come up before… but have we considered just adopting
the Google style guidlines and maybe modifying it in some places?

Despite working at Google, and having to cope with multiple different styles in my day-to-day work as a consequence, I would not push for this.

I think that we should focus on building some consistency of style and formatting within the LLVM/Clang/… codebases rather than picking one style or another. Frankly, I just don’t care what the style is nearly as much as I care that it is consistently applied.

I’ll add minor points:

  • I suspect LLVM/Clang/… have plenty of good reasons to deviate from any existing style. We shouldn’t constrain ourselves to external guidelines at this point; these are large healthy projects.

  • We can fix any problems or inconsistencies with the style guidelines if contributors can agree to what they are and what would be a superior alternative.

Finally:

They have a nice script for c++ which will check for many things.

It is not a nice script. Trust me. I use it every day, and I hate it with a burning, fiery passion. Read the python code. It is not nice, it is terrible. It is an atrocity. It is everything that is bad about trying to “parse” C++ with regular expressions and python hacks, built up w/o any overarching design or cohesion over years.

I await the day we can kill it off and use a real Clang-based tool instead.

I think I can adapt the script they have to llvm style guidelines for C++.
There can be a configuration file so various checking can be optionally turned on/off.

I will write one for tablegen files.

What I’m thinking of is a scheme so that things can be configured on a per directory basis.

for example:

there could be a .style_check file in a directory and it provides the default

similarly:

.style_check.td provides further specialization for .td files
.style_check.h provides further specialization for .h files

this could also be configured in the makefiles.

but the idea is to make some style checkers for various file types.

initially .cpp/.h and .td.