Start of public OpenTitan development history
Code contributors:
Alex Bradbury <asb@lowrisc.org>
Cindy Chen <chencindy@google.com>
Eunchan Kim <eunchan@google.com>
Gaurang Chitroda <gaurangg@google.com>
Mark Hayter <mark.hayter@gmail.com>
Michael Schaffner <msf@google.com>
Miguel Osorio <miguelosorio@google.com>
Nils Graf <nilsg@google.com>
Philipp Wagner <phw@lowrisc.org>
Pirmin Vogel <vogelpi@lowrisc.org>
Ram Babu Penugonda <rampenugonda@google.com>
Scott Johnson <scottdj@google.com>
Shail Kushwah <kushwahs@google.com>
Srikrishna Iyer <sriyer@google.com>
Steve Nelson <Steve.Nelson@wdc.com>
Tao Liu <taliu@google.com>
Timothy Chen <timothytim@google.com>
Tobias Wölfel <tobias.woelfel@mailbox.org>
Weicai Yang <weicai@google.com>
diff --git a/util/run-clang-format.sh b/util/run-clang-format.sh
new file mode 100755
index 0000000..6e23acf
--- /dev/null
+++ b/util/run-clang-format.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Copyright lowRISC contributors.
+# Licensed under the Apache License, Version 2.0, see LICENSE for details.
+# SPDX-License-Identifier: Apache-2.0
+
+find sw hw \
+ -not \( -path '*/vendor' -prune \) \
+ -not \( -path 'sw/coremark' -prune \) \
+ \( -name '*.cpp' \
+ -o -name '*.cc' \
+ -o -name '*.c' \
+ -o -name '*.h' \) \
+ -exec clang-format -i {} \;
+
+# Report on missing curly braces for loops and control statements.
+# clang-format cannot fix them for us, so this requires manual work.
+braces_missing=$(
+ find sw hw \
+ -not \( -path '*/vendor' -prune \) \
+ -not \( -path 'sw/coremark' -prune \) \
+ \( -name '*.cpp' \
+ -o -name '*.cc' \
+ -o -name '*.c' \
+ -o -name '*.h' \) \
+ -exec grep -Hn -P '(^|\s)((if|while|for) \(.+\)|else\s*)$' {} \;
+)
+if [ ! -z "$braces_missing" ]; then
+ echo ERROR: Curly braces are missing from the following control or loop
+ echo statements. Please add them manually and re-run this script.
+ echo
+ echo "$braces_missing"
+ exit 1
+fi