C/C++ format tool based on clang-tidy and clang-format
#!/usr/bin/env bash
echo "clang-tidy starting "$*" ..."
sleep 1
TIDY="clang-tidy"
if [ -f /usr/local/opt/llvm/bin/clang-tidy ]; then
TIDY="/usr/local/opt/llvm/bin/clang-tidy"
fi
FORMAT="clang-format"
if [ -f /usr/local/bin/clang-format ]; then
FORMAT="/usr/local/bin/clang-format"
fi
$TIDY \
-fix \
-fix-errors \
-header-filter=.* \
--checks=readability-braces-around-statements,misc-macro-parentheses \
$* \
-- -I.
echo "clang-tidy finished!"
echo "clang-format starting "$*" ..."
sleep 1
$FORMAT -sort-includes -i $*
echo "clang-format finished!"
echo "iconv doc2unix starting "$*" ..."
sleep 1
for file in $*
do
iconv -f gbk -t utf8 "$file" >"$file.new"
mv -f "$file.new" "$file"
dos2unix "$file"
done
echo "iconv doc2unix finished!"
BasedOnStyle: Google
TabWidth: 4
IndentWidth: 4
UseTab: ForIndentation
SpacesBeforeTrailingComments: 1
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
ColumnLimit: 79
MaxEmptyLinesToKeep: 2