Skip to content

Commit

Permalink
Upgrade clang-format and clang-tidy to LLVM-12 (#6233)
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-johnson committed Sep 2, 2021
1 parent 24d6bd6 commit b78b205
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Checks: >
performance-*,
-performance-inefficient-string-concatenation,
-performance-inefficient-vector-operation,
-performance-no-int-to-ptr,
readability-avoid-const-params-in-decls,
readability-braces-around-statements,
readability-const-return-type,
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.11
- uses: DoozyX/clang-format-lint-action@v0.12
with:
source: '.'
extensions: 'h,c,cpp'
clangFormatVersion: 11
clangFormatVersion: 12
check_clang_tidy:
name: Check clang-tidy
runs-on: ubuntu-20.04
Expand All @@ -28,12 +28,12 @@ jobs:
- name: Install clang-tidy
run: |
sudo apt-get update
sudo apt-get install llvm-11 clang-11 liblld-11-dev libclang-11-dev clang-tidy-11 ninja-build
sudo apt-get install llvm-12 clang-12 liblld-12-dev libclang-12-dev clang-tidy-12 ninja-build
- name: Run clang-tidy
run: |
export CC=clang-11
export CXX=clang++-11
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-11
export CC=clang-12
export CXX=clang++-12
export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-12
./run-clang-tidy.sh
check_cmake_file_lists:
name: Check CMake file lists
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2336,15 +2336,15 @@ $(BIN_DIR)/HalideTraceDump: $(ROOT_DIR)/util/HalideTraceDump.cpp $(ROOT_DIR)/uti

# Note: you must have CLANG_FORMAT_LLVM_INSTALL_DIR set for this rule to work.
# Let's default to the Ubuntu install location.
CLANG_FORMAT_LLVM_INSTALL_DIR ?= /usr/lib/llvm-11
CLANG_FORMAT_LLVM_INSTALL_DIR ?= /usr/lib/llvm-12

.PHONY: format
format:
@CLANG_FORMAT_LLVM_INSTALL_DIR=$(CLANG_FORMAT_LLVM_INSTALL_DIR) ${ROOT_DIR}/run-clang-format.sh

# Note: you must have CLANG_TIDY_LLVM_INSTALL_DIR set for these rules to work.
# Let's default to the Ubuntu install location.
CLANG_TIDY_LLVM_INSTALL_DIR ?= /usr/lib/llvm-11
CLANG_TIDY_LLVM_INSTALL_DIR ?= /usr/lib/llvm-12

.PHONY: clang-tidy
clang-tidy:
Expand Down
14 changes: 7 additions & 7 deletions run-clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ set -e

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

# We are currently standardized on using LLVM/Clang11 for this script.
# We are currently standardized on using LLVM/Clang12 for this script.
# Note that this is totally independent of the version of LLVM that you
# are using to build Halide itself. If you don't have LLVM11 installed,
# are using to build Halide itself. If you don't have LLVM12 installed,
# you can usually install what you need easily via:
#
# sudo apt-get install llvm-11 clang-11 libclang-11-dev clang-tidy-11
# export CLANG_FORMAT_LLVM_INSTALL_DIR=/usr/lib/llvm-11
# sudo apt-get install llvm-12 clang-12 libclang-12-dev clang-tidy-12
# export CLANG_FORMAT_LLVM_INSTALL_DIR=/usr/lib/llvm-12

[ -z "$CLANG_FORMAT_LLVM_INSTALL_DIR" ] && echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." && exit
echo CLANG_FORMAT_LLVM_INSTALL_DIR = ${CLANG_FORMAT_LLVM_INSTALL_DIR}

VERSION=$(${CLANG_FORMAT_LLVM_INSTALL_DIR}/bin/clang-format --version)
if [[ ${VERSION} =~ .*version\ 11.* ]]
if [[ ${VERSION} =~ .*version\ 12.* ]]
then
echo "clang-format version 11 found."
echo "clang-format version 12 found."
else
echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM 11 install!"
echo "CLANG_FORMAT_LLVM_INSTALL_DIR must point to an LLVM 12 install!"
exit 1
fi

Expand Down
14 changes: 7 additions & 7 deletions run-clang-tidy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

FIX=$1

# We are currently standardized on using LLVM/Clang11 for this script.
# We are currently standardized on using LLVM/Clang12 for this script.
# Note that this is totally independent of the version of LLVM that you
# are using to build Halide itself. If you don't have LLVM11 installed,
# are using to build Halide itself. If you don't have LLVM12 installed,
# you can usually install what you need easily via:
#
# sudo apt-get install llvm-11 clang-11 libclang-11-dev clang-tidy-11
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-11
# sudo apt-get install llvm-12 clang-12 libclang-12-dev clang-tidy-12
# export CLANG_TIDY_LLVM_INSTALL_DIR=/usr/lib/llvm-12

[ -z "$CLANG_TIDY_LLVM_INSTALL_DIR" ] && echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM installation dir for this script." && exit
echo CLANG_TIDY_LLVM_INSTALL_DIR = ${CLANG_TIDY_LLVM_INSTALL_DIR}

VERSION=$(${CLANG_TIDY_LLVM_INSTALL_DIR}/bin/clang-tidy --version)
if [[ ${VERSION} =~ .*version\ 11.* ]]
if [[ ${VERSION} =~ .*version\ 12.* ]]
then
echo "clang-tidy version 11 found."
echo "clang-tidy version 12 found."
else
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 11 install!"
echo "CLANG_TIDY_LLVM_INSTALL_DIR must point to an LLVM 12 install!"
exit 1
fi

Expand Down

0 comments on commit b78b205

Please sign in to comment.