summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2023-03-14 11:01:04 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-21 21:10:05 +0000
commit36b1fc5b58ac250784e6a466f8f6f4434b9b7a41 (patch)
tree1cdcd89d4f91164af5ae018a9db4c91889285c9c
parentb77285b17f20800855b8d5ac472feefcf569b799 (diff)
downloadchrome-ec-36b1fc5b58ac250784e6a466f8f6f4434b9b7a41.tar.gz
util/check_clang_format: Format C++ files
BRANCH=none BUG=b:236386294 TEST=./util/check_clang_format.py Change-Id: Ie0cafe0db519bbaca700917435a8b0e93a6e2678 Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4356906 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
-rwxr-xr-xutil/check_clang_format.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/util/check_clang_format.py b/util/check_clang_format.py
index 5862c02a3d..529a37302d 100755
--- a/util/check_clang_format.py
+++ b/util/check_clang_format.py
@@ -3,7 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-"""Validate all C source is formatted with clang-format.
+"""Validate all C/C++ source is formatted with clang-format.
This isn't very useful to users to call directly, but it is run it the
CQ. Most users will likely find out they forgot to clang-format by
@@ -21,7 +21,7 @@ from chromite.lib import commandline
def main(argv=None):
- """Find all C files and runs clang-format on them."""
+ """Find all C/C++ files and runs clang-format on them."""
parser = commandline.ArgumentParser()
parser.add_argument(
"--fix",
@@ -59,7 +59,11 @@ def main(argv=None):
continue
if "third_party" in path.parts:
continue
- if path.name.endswith(".c") or path.name.endswith(".h"):
+ if (
+ path.name.endswith(".c")
+ or path.name.endswith(".cc")
+ or path.name.endswith(".h")
+ ):
cmd.append(path)
logging.debug("Running %s", " ".join(shlex.quote(str(x)) for x in cmd))
@@ -72,7 +76,7 @@ def main(argv=None):
stdin=subprocess.DEVNULL,
)
if result.stderr:
- logging.error("All C source must be formatted with clang-format!")
+ logging.error("All C/C++ source must be formatted with clang-format!")
for line in result.stderr.splitlines():
logging.error("%s", line)
return 1