-
Notifications
You must be signed in to change notification settings - Fork 242
How to format code
JonathanLichtnerAMD edited this page Feb 21, 2025
·
7 revisions
Update 10012022: clang-format-10 has been updated to clang-format-12
Run this script from the root of MIOpen tree (where the .clang-format file resides) prior committing your edits to avoid formatting failures:
CLANG_FORMAT='clang-format-12'
if ! command -v $CLANG_FORMAT 2>&1 /dev/null
then
echo "${CLANG_FORMAT} is not installed or in your path"
exit 1
fi
find . -iname '*.h' \
-o -iname '*.hpp' \
-o -iname '*.cpp' \
-o -iname '*.h.in' \
-o -iname '*.hpp.in' \
-o -iname '*.cpp.in' \
-o -iname '*.cl' \
| grep -v -E '(build/)|(install/)' \
| xargs -n 1 -P $(nproc) -I{} -t ${CLANG_FORMAT} -style=file {} -i 2>/dev/null
The script reformats source files, when necessary. Please do not forget to commit reformatted source files after that.
Note:
| grep -v -E '(build/)|(install/)'
is used to avoid formatting within ./build/
and ./install/
(I use these for building etc.); please fix this line according to your needs.
--atamazov