-
Notifications
You must be signed in to change notification settings - Fork 224
How to format code
Jun Liu edited this page Oct 2, 2022
·
6 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:
#!/bin/bash
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-12 -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