clang-format tries to automatically detect the Cpp standard used,
particularly when determining to put spaces in template definitions:
Cpp03: std::vector<std::pair<bool, bool> >
vs
Cpp11: std::vector<std::pair<bool, bool>>
It doesn't always get this correct as seen in
https://android-review.googlesource.com/c/platform/system/core/+/973463/8
but since we know that all code within Android is C++17, we can safely
assume it should be formatted with the newer standard.
Test: clang-format doesn't break the above change.
Change-Id: I7d1d709690b7bca6da3863cc9a58e53eaec751b0
As of [1], the Google format, which we default to, uses IncludeBlocks:
Regroup, which sorts all includes with <> and without .h into the top
group reserved for libc headers, e.g.:
+#include <android-base/properties.h>
+#include <android-base/strings.h>
#include <ctype.h>
#include <stdlib.h>
#include <sys/system_properties.h>
#include <iostream>
-#include <android-base/properties.h>
-#include <android-base/strings.h>
This is accurate to the Google C++ style guide, which states that
other library headers should be included with "", however we have a
strong tendency to use <> for these headers for Android, so we must
revert this change.
Note, clang-format allows regexes for creating the blocks as well,
however, short of including all possible libc headers, I don't think
there's a way to differentiate between <sys/wait.h> and
<other_lib/header.h>.
[1]:
62e3198c4f (diff-b689ebff2e51e675b346a88289e74542)
Test: clang-format doesn't do the above.
Change-Id: Ifef605ffd6b4c8a36512377644e64ddd26b68a21