The default value for ContinuationIndentWidth inherited from the Google
style is 4. Since .clang-format-4 doubles the value of IndentWidth
from 2 to 4, it should also double ContinuationIndentWidth to retain
Google's double-indent style.
Before:
void forEachInterface(
const std::string& dirname,
const std::function<void(const std::string& path)) {
fn(dirname, "default");
DIR* dir = opendir(dirname.c_str());
After this patch:
void forEachInterface(
const std::string& dirname,
const std::function<void(const std::string& path)) {
fn(dirname, "default");
DIR* dir = opendir(dirname.c_str());
Test: applied to libsysutils/src/*.cpp and compared output.
Change-Id: I75c50fa9becd5291a17047933f443cc6db77838a
The previous rules would force short functions to be on a single line.
This change only allows single function lines in class definitions.
Test: Ran on a CL and verified single line functions only allowed in
Test: class defintions.
Change-Id: I5422543fdbb39da842bbd799c19fe2c443ff483c
The .clang-format files in the base, debuggerd, adb, libprocinfo, and
fastboot subdirectories each differ slightly from the top level
.clang-format-2 and .clang-format-4, but not in a substantially
meaningful way, as the source files in those directories have not been
re-formatted with clang-format. Therefore, let's reduce the
differences and use only the two top level clang-format files.
Secondly perform some small clean-up of the top level .clang-format
files. AllowShortBlocksOnASingleLine is already false in the Google
style, so it can be removed. AllowShortFunctionsOnASingleLine should
not change between the -2 and -4 versions, so leave it at the Google
default style in both, which is 'All'.
The diff stats for these changes are:
./base/
Old:
640 insertions(+), 531 deletions(-)
New:
563 insertions(+), 808 deletions(-)
./debuggerd/
Old:
910 insertions(+), 886 deletions(-)
New:
991 insertions(+), 1023 deletions(-)
./adb/
Old:
2623 insertions(+), 2886 deletions(-)
New:
2655 insertions(+), 3103 deletions(-)
./libprocinfo/
Old:
2 insertions(+), 1 deletion(-)
New:
4 insertions(+), 18 deletions(-)
./fastboot/
Old:
618 insertions(+), 743 deletions(-)
New:
726 insertions(+), 882 deletions(-)
./init/
Old:
1755 insertions(+), 1866 deletions(-)
New:
1715 insertions(+), 1952 deletions(-)
Test: Above clang-format stats
Change-Id: I3f7b8ab0660c8394c5008ba95ea15e70dd22b55b
Make the default the 4 tab space version.
Add a link to the 2 space version for libbacktrace.
The only other difference between the 4 space and 2 space tab version
is that the 2 space tab version allows short functions on a single line.
This is for things like constructors, short destructors, or accessor
functions. I believe this is closer to the Google C++ style guide.
Bug: 36046320
Test: NA
Change-Id: Ida08db18902eeb101f42869dd5590182529d54ef