Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [omr-dev] our coding standard

On 8/22/2016 1:47 PM, Mark Stoodley wrote:
I would like to propose we move to a completely different coding
standard that can be automatically applied by a tool like clang-format:
maybe something like LLVM or WebKit.

To help people get a feel for what exactly these styles would look
like, I just pushed a series of branches wherein I took the omr
codebase and used all the built-in clang formatters.

* LLVM      https://github.com/mgaudet/omr/commits/clang-format-llvm
* Webkit    https://github.com/mgaudet/omr/commits/clang-format-webkit
* Mozilla   https://github.com/mgaudet/omr/commits/clang-format-mozilla
* Chromium  https://github.com/mgaudet/omr/commits/clang-format-chromium
* Google    https://github.com/mgaudet/omr/commits/clang-format-google

The script I used is below my signature. It produces one commit per
directory for tracing.

A couple of notes:

1. All branches share this commit: https://github.com/mgaudet/omr/commit/d06927d03d2d5c1387a63938369089cf2367a5c6

   This commit disables formatting to work around a bug that appears to
   exist in clang-format when dealing with the CUDAAPI 'decoration?'.

2. Comment reflow is turned on, though I would have preferred to keep
   it off. Unfortunately, the results with comment reflow and indented
   comment blocks aren't great.

3. Some styles in some files look particularly bad because they are
   enforcing a dramatically tighter width limit than OMR code already
   uses. This can be edited, or these kinds of lines could be re-flowed
   manually.

So far the travis jobs look good, though, they're not yet complete :)

-- Matthew Gaudet

reformat.sh:

style=webkit
complete_style="BasedOnStyle: $style\nSortIncludes: false"

FORMAT_CMD="clang-format-3.8 -i"

echo -e $complete_style > .clang-format
for i in `find $@ -type d -links 2`
do
   echo "Formatting $i"
   pushd $i;
   for suffix in hpp cpp h c
   do
      echo "    Formatting $i *.$suffix"
      echo "find . -name \*.$suffix -exec $FORMAT_CMD {} \;"
      find . -name \*.$suffix -exec $FORMAT_CMD {} \;
   done
   popd
   echo "Committing reformat"
   git commit -am "Reformatted $i into $style using clang-format-3.8

   .clang-format:
   $complete_style"
done



Back to the top