Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
// Google Recommends:
if (x == kFoo) return new Foo();
if (condition)
  DoSomething();  // 2 space indent.
if (condition) {
  DoSomething();  // 2 space indent.
}
// we only use:
if (x == kFoo) return new Foo();  // If the whole line fits into the 90 character limit
if (condition) {
  DoSomething();  // Otherwise, 2 space indent.
}

...

Re-formatting

You can use clang-format to automatically reformat only the parts of the code you touched. See https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting for a general clang-format reference. Impala's clang-format file is located at ${IMPALA_HOME}/.clang-format. The clang-* command uses the format file. 

To reformat the code around the lines that your last commit touched, you can run:

Code Block
git diff -U0 --no-color HEAD^ | "${IMPALA_TOOLCHAIN}/llvm-${IMPALA_LLVM_VERSION}/share/clang/clang-format-diff.py" -binary "${IMPALA_TOOLCHAIN}/llvm-${IMPALA_LLVM_VERSION}/bin/clang-format" -p1 -i


The -i option means in-place replacement. Run it without -i option if you'd like to see difference before applying the effect of the command.

If the above approach does not work or you may want to use a different version, you can use a system version of clang-tidy. On Ubuntu,

Code Block
sudo apt-get install clang-format-3.9
git diff -U0 --no-color HEAD^ | clang-format-diff-3.9 -p1 -i

 

 

Info
titleTip
clang-format is not perfect and sometimes reformats things in strange ways, or will reformat large areas of code. If clang-format doesn't match the existing style of the surrounding code, please consider manually formatting that part of the code - mixing large white

Third-Party Libraries

  • Boost - we use a different set of Boost libraries. Reducing # of dependencies is encouraged and adding dependencies to new libraries should be carefully evaluated.

...

Code Block
git diff asf-gerrit/master | "${IMPALA_TOOLCHAIN}/llvm-${IMPALA_LLVM_VERSION}/share/clang/clang-tidy-diff.py" -clang-tidy-binary "${IMPALA_TOOLCHAIN}/llvm-${IMPALA_LLVM_VERSION}/bin/clang-tidy" -p 1