blob: 3f34fcfedc05ee4276e051cda12691ae839cd678 [file] [log] [blame]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001#!/bin/sh
2# Copyright lowRISC contributors.
3# Licensed under the Apache License, Version 2.0, see LICENSE for details.
4# SPDX-License-Identifier: Apache-2.0
5
6find sw hw \
lowRISC Contributors802543a2019-08-31 12:12:56 +01007 \( -name '*.cpp' \
8 -o -name '*.cc' \
9 -o -name '*.c' \
10 -o -name '*.h' \) \
11 -exec clang-format -i {} \;
12
13# Report on missing curly braces for loops and control statements.
14# clang-format cannot fix them for us, so this requires manual work.
15braces_missing=$(
16 find sw hw \
lowRISC Contributors802543a2019-08-31 12:12:56 +010017 \( -name '*.cpp' \
18 -o -name '*.cc' \
19 -o -name '*.c' \
20 -o -name '*.h' \) \
21 -exec grep -Hn -P '(^|\s)((if|while|for) \(.+\)|else\s*)$' {} \;
22)
23if [ ! -z "$braces_missing" ]; then
24 echo ERROR: Curly braces are missing from the following control or loop
25 echo statements. Please add them manually and re-run this script.
26 echo
27 echo "$braces_missing"
28 exit 1
29fi