Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/testing-arm-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ on:
- "packaging/**"
- "Makefile"
- "Makefile.inc"
- 'run-clang-tidy.sh'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang tidy is extremely slow. Do we really need to run it on all build targets? This is to have it check different permutations of the code, based on platform specific preprocessor macros?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exclusion so that the ARM Linux workflows don't run if we only modified the clang-tidy configuration.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, since we modified the workflows themselves, they are running.

- '**.clang-tidy'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/testing-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ on:
- "packaging/**"
- "Makefile"
- "Makefile.inc"
- 'run-clang-tidy.sh'
- '**.clang-tidy'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/testing-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ on:
- "packaging/**"
- "Makefile"
- "Makefile.inc"
- 'run-clang-tidy.sh'
- '**.clang-tidy'

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
46 changes: 23 additions & 23 deletions run-clang-tidy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash

set -e

CLEANUP_FILES=()
# shellcheck disable=SC2329
cleanup() { rm -rf "${CLEANUP_FILES[@]}"; }
trap cleanup EXIT
Comment thread
alexreinking marked this conversation as resolved.

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

##
Expand Down Expand Up @@ -36,12 +41,8 @@ get_thread_count() {
}

if [ "$(uname)" == "Darwin" ]; then
# shellcheck disable=SC2329
patch_file() { sed -i '' -E "$@"; }
_DEFAULT_LLVM_LOCATION="/opt/homebrew/opt/llvm@$EXPECTED_VERSION"
else
# shellcheck disable=SC2329
patch_file() { sed -i -E "$@"; }
_DEFAULT_LLVM_LOCATION="/usr/lib/llvm-$EXPECTED_VERSION"
fi

Expand Down Expand Up @@ -94,7 +95,7 @@ fi
# Use a temp folder for the CMake stuff here, so it's fresh & correct every time
if [[ -z ${CLANG_TIDY_BUILD_DIR} ]]; then
CLANG_TIDY_BUILD_DIR=$(mktemp -d)
trap 'rm -rf ${CLANG_TIDY_BUILD_DIR}' EXIT
CLEANUP_FILES+=("${CLANG_TIDY_BUILD_DIR}")
else
mkdir -p "${CLANG_TIDY_BUILD_DIR}"
fi
Expand Down Expand Up @@ -141,34 +142,33 @@ cmake -S "${ROOT_DIR}" -B "${CLANG_TIDY_BUILD_DIR}" -Wno-dev -DWITH_TESTS=OFF
echo Building Halide...
cmake --build "${CLANG_TIDY_BUILD_DIR}" -j "${J}"

echo Building runtime compilation database...
temp_file=$(mktemp)
trap 'rm -f $temp_file' EXIT
rm -f "${CLANG_TIDY_BUILD_DIR}/src/runtime/compile_commands.json"
cat "${CLANG_TIDY_BUILD_DIR}"/src/runtime/*.json >"$temp_file"
{
echo '['
cat "$temp_file" | sed '$ s/,$//'
echo ']'
} >"${CLANG_TIDY_BUILD_DIR}/src/runtime/compile_commands.json"

echo Merging compilation databases...
echo Merging runtime compilation database...
jq -s 'add' "${CLANG_TIDY_BUILD_DIR}/compile_commands.json" \
"${CLANG_TIDY_BUILD_DIR}/src/runtime/compile_commands.json" \
<(sed 's/,$//' "${CLANG_TIDY_BUILD_DIR}"/src/runtime/*.json | jq -s '.') \
>"${CLANG_TIDY_BUILD_DIR}/compile_commands_merged.json"
mv "${CLANG_TIDY_BUILD_DIR}/compile_commands_merged.json" "${CLANG_TIDY_BUILD_DIR}/compile_commands.json"

# Wrapper filters noisy "N warnings generated." from each clang-tidy invocation.
CLANG_TIDY_FILTER="${CLANG_TIDY_BUILD_DIR}/clang-tidy-filter.sh"
cat >"${CLANG_TIDY_FILTER}" <<WRAPPER
#!/usr/bin/env bash
"${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy" "\$@" 2>&1 | grep -v '^[[:digit:]]\+ warnings\? generated\.\$'
exit "\${PIPESTATUS[0]}"
Comment thread
alexreinking marked this conversation as resolved.
WRAPPER
chmod +x "${CLANG_TIDY_FILTER}"

echo Running clang-tidy...
PYTHONUNBUFFERED=1 "${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/run-clang-tidy" \
export PYTHONUNBUFFERED=1
"${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/run-clang-tidy" \
${FIX} \
-j "${J}" \
-quiet \
-p "${CLANG_TIDY_BUILD_DIR}" \
-clang-tidy-binary "${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy" \
-clang-tidy-binary "${CLANG_TIDY_FILTER}" \
-clang-apply-replacements-binary "${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-apply-replacements" \
"$@" 2>&1 | sed -Eu '/^[[:digit:]]+ warnings? generated\.$/{N;/\n$/d;}'
"$@"

CLANG_TIDY_EXIT_CODE=${PIPESTATUS[0]}
CLANG_TIDY_EXIT_CODE=$?

if [ "$CLANG_TIDY_EXIT_CODE" -eq 0 ]; then
echo "Success!"
Expand Down
73 changes: 6 additions & 67 deletions src/runtime/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,30 @@
InheritParentConfig: true
# keep-sorted start skip_lines=1 ignore_prefixes=-
Checks: >
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-*,
-bugprone-assignment-in-if-condition,
bugprone-bad-signal-to-kill-thread,
bugprone-bool-pointer-implicit-conversion,
-bugprone-bitwise-pointer-cast,
-bugprone-branch-clone,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
-bugprone-dynamic-static-initializers,
-bugprone-easily-swappable-parameters,
-bugprone-exception-escape,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
-bugprone-implicit-widening-of-multiplication-result,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-infinite-loop,
-bugprone-integer-division,
bugprone-lambda-function-name,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
-bugprone-multi-level-implicit-pointer-conversion,
-bugprone-narrowing-conversions,,
bugprone-no-escape,
bugprone-not-null-terminated-result,
bugprone-parent-virtual-call,
bugprone-posix-return,
bugprone-redundant-branch-condition,
-bugprone-reserved-identifier,
bugprone-shared-ptr-array-mismatch,
bugprone-signal-handler,
-bugprone-signed-char-misuse,
bugprone-sizeof-container,
-bugprone-sizeof-expression,
bugprone-spuriously-wake-up-functions,
bugprone-standalone-empty,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-stringview-nullptr,
bugprone-suspicious-enum-usage,
-bugprone-suspicious-include,
bugprone-suspicious-memory-comparison,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-realloc-usage,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-unchecked-optional-access,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unhandled-exception-at-new,
bugprone-unhandled-self-assignment,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
clang-diagnostic-shadow-field,
misc-confusable-identifiers,
misc-*,
-misc-const-correctness,
-misc-definitions-in-headers,
misc-misleading-bidirectional,
misc-misleading-identifier,
misc-misplaced-const,
misc-new-delete-overloads,
-misc-include-cleaner,
-misc-no-recursion,
misc-non-copyable-objects,
-misc-non-private-member-variables-in-classes,
misc-redundant-expression,
misc-static-assert,
misc-throw-by-value-catch-by-reference,
-misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
misc-unused-alias-decls,
-misc-unused-parameters,
misc-unused-using-decls,
misc-use-anonymous-namespace,
-misc-use-internal-linkage,
# keep-sorted end
...
Loading