Fix clang tidy (#2347)

This commit is contained in:
Rot127 2024-05-01 04:04:27 +00:00 committed by GitHub
parent b91c727481
commit 8f9a337dfa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 9 deletions

View File

@ -10,9 +10,11 @@ jobs:
analyze:
runs-on: ubuntu-latest
name: Install clang-tidy
name: clang-tidy
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install clang-tidy
run: |
sudo apt install clang-tidy
@ -20,10 +22,13 @@ jobs:
- name: Build
run: |
mkdir build && cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_SHARED_LIBS=1 ..
sudo cmake --build . --config Release
CC=clang cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_SHARED_LIBS=1 ..
CC=clang sudo cmake --build . --config Release
cd ..
- name: Check for warnings
env:
base_sha: ${{ github.event.pull_request.base.sha }}
head_sha: ${{ github.event.pull_request.head.sha }}
run: |
./run-clang-tidy.sh build

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -x
if [ $# -ne 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo "$0 <build-path>"
@ -7,7 +7,11 @@ fi
BUILD_PATH="$1"
clang-tidy $(find ./arch ./*.c -type f -iregex ".*\.[c]") -p "$BUILD_PATH" -checks=clang-analyzer-*,-clang-analyzer-cplusplus* | tee ct-warnings.txt
clang-tidy $(find ./arch ./*.c -type f -iregex ".*\.[c]") -p "$BUILD_PATH" -checks=clang-analyzer-*,-clang-analyzer-cplusplus* > ct-warnings.txt
if [ $? -ne 0 ]; then
echo "clang-tidy failed"
exit 1
fi
tmp=$(mktemp)
grep ": warning" ct-warnings.txt | grep -oE "^[/a-zA-Z0-9]*\.[ch]" | sort | uniq > $tmp
@ -15,16 +19,34 @@ top_level=$(git rev-parse --show-toplevel)
echo "\n\n###### REPORT\n\n"
for modified in $(git diff --name-only origin/next); do
changed_files=$(git diff --name-only $base_sha..$head_sha)
if [ $? -ne 0 ]; then
echo "Failed to get changed files."
exit 1
fi
faulty_files=""
for modified in $changed_files; do
files_changed=1
full_path="$top_level/$modified"
if grep -q "$full_path" $tmp; then
faulty_files="$faulty_files $modified"
echo "$full_path as warnings. Please fix them."
needs_fixes=1
fi
done
if [ -z $needs_fixes ]; then
echo "All good"
if [ -z $files_changed ]; then
echo "No files changed."
exit 0
fi
if [ -z $needs_fixes ]; then
echo "None of the changed files has clang-tidy warnings."
exit 0
fi
echo -e "\n\nclang-tidy warnings for: $faulty_files\n"
echo "Please fix them. Or, if completely unrelated, let us know."
exit 1

View File

@ -78,7 +78,7 @@ char *get_detail_ppc(csh *handle, cs_mode mode, cs_insn *ins)
}
if (ppc->bc.pred_ctr != PPC_PRED_INVALID)
printf("\t\tpred CTR: %s\n", get_pred_name(ppc->bc.pred_ctr));
if (ppc->bc.hint != PPC_BH_INVALID)
if (ppc->bc.hint != PPC_BR_NOT_GIVEN)
printf("\t\thint: %u\n", ppc->bc.hint);
}