From b8f1b71a05b43b0d47e3b1535d57f13aecc2bdd8 Mon Sep 17 00:00:00 2001 From: Esun Kim Date: Mon, 21 Sep 2020 15:24:23 -0700 Subject: [PATCH] Use clang-tidy 7 --- .clang-tidy | 17 +++++++++++++++-- .../grpc_clang_tidy/Dockerfile.template | 9 +++------ .../dockerfile/test/sanity/Dockerfile.template | 13 ++++--------- tools/distrib/run_clang_tidy.py | 7 +++++++ tools/dockerfile/grpc_clang_tidy/Dockerfile | 9 +++------ tools/dockerfile/test/sanity/Dockerfile | 13 ++++--------- 6 files changed, 36 insertions(+), 32 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index d2174417920..c6777357ec1 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,6 +1,19 @@ --- -Checks: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*,bugprone-*' -WarningsAsErrors: 'modernize-use-nullptr,google-build-namespaces,google-build-explicit-make-pair,readability-function-size,performance-*,bugprone-*' +Checks: '-*, + bugprone-*, + -bugprone-forward-declaration-namespace, + -bugprone-integer-division, + -bugprone-misplaced-widening-cast, + -bugprone-narrowing-conversions, + -bugprone-too-small-loop-variable, + performance-*, + -performance-unnecessary-copy-initialization, + -performance-unnecessary-value-param, + google-build-namespaces, + google-build-explicit-make-pair, + modernize-use-nullptr, + readability-function-size' +WarningsAsErrors: '*' CheckOptions: - key: readability-function-size.StatementThreshold value: '450' diff --git a/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template b/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template index 4d5c83fda04..195a7b936ee 100644 --- a/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template +++ b/templates/tools/dockerfile/grpc_clang_tidy/Dockerfile.template @@ -16,12 +16,9 @@ <%include file="../python_debian10.include"/> - # Install clang-tidy 6.0 - # This is because clang-tidy 7.0 started treating compiler errors as tidy errors - # and there are a couple of files which are not properly compiled via tidy so it - # should be using 6.0 version until all compilation errors are addressed. - RUN apt-get update && apt-get install -y clang-tidy-6.0 jq - ENV CLANG_TIDY=clang-tidy-6.0 + # Install clang-tidy 7 + RUN apt-get update && apt-get install -y clang-tidy-7 jq + ENV CLANG_TIDY=clang-tidy-7 ADD clang_tidy_all_the_things.sh / diff --git a/templates/tools/dockerfile/test/sanity/Dockerfile.template b/templates/tools/dockerfile/test/sanity/Dockerfile.template index 314f3ab625f..c486a9821ed 100644 --- a/templates/tools/dockerfile/test/sanity/Dockerfile.template +++ b/templates/tools/dockerfile/test/sanity/Dockerfile.template @@ -33,15 +33,10 @@ RUN python2 -m pip install simplejson mako virtualenv==16.7.9 lxml RUN python3 -m pip install simplejson mako virtualenv==16.7.9 lxml - # Install clang & clang-format - RUN apt-get install -y clang clang-format - - # Install clang-tidy 6.0 - # This is because clang-tidy 7.0 started treating compiler errors as tidy errors - # and there are a couple of files which are not properly compiled via tidy so it - # should be using 6.0 version until all compilation errors are addressed. - RUN apt-get install -y clang-tidy-6.0 jq - ENV CLANG_TIDY=clang-tidy-6.0 + # Install clang, clang-format, and clang-tidy + RUN apt-get install -y clang clang-format-7 clang-tidy-7 jq + ENV CLANG_FORMAT=clang-format-7 + ENV CLANG_TIDY=clang-tidy-7 <%include file="../../bazel.include"/> diff --git a/tools/distrib/run_clang_tidy.py b/tools/distrib/run_clang_tidy.py index 6cdddcc5781..9af6c8fc61e 100755 --- a/tools/distrib/run_clang_tidy.py +++ b/tools/distrib/run_clang_tidy.py @@ -37,8 +37,15 @@ argp.add_argument('-j', argp.set_defaults(fix=False) args = argp.parse_args() +# Explicitly passing the .clang-tidy config by reading it. +# This is required because source files in the compilation database are +# in a different source tree so clang-tidy cannot find the right config file +# by seeking their parent directories. +with open(".clang-tidy") as f: + config = f.read() cmdline = [ clang_tidy, + '--config=' + config, ] if args.fix: diff --git a/tools/dockerfile/grpc_clang_tidy/Dockerfile b/tools/dockerfile/grpc_clang_tidy/Dockerfile index 54eb6a52e06..4c47e8dc7fa 100644 --- a/tools/dockerfile/grpc_clang_tidy/Dockerfile +++ b/tools/dockerfile/grpc_clang_tidy/Dockerfile @@ -61,12 +61,9 @@ RUN mkdir /var/local/jenkins -# Install clang-tidy 6.0 -# This is because clang-tidy 7.0 started treating compiler errors as tidy errors -# and there are a couple of files which are not properly compiled via tidy so it -# should be using 6.0 version until all compilation errors are addressed. -RUN apt-get update && apt-get install -y clang-tidy-6.0 jq -ENV CLANG_TIDY=clang-tidy-6.0 +# Install clang-tidy 7 +RUN apt-get update && apt-get install -y clang-tidy-7 jq +ENV CLANG_TIDY=clang-tidy-7 ADD clang_tidy_all_the_things.sh / diff --git a/tools/dockerfile/test/sanity/Dockerfile b/tools/dockerfile/test/sanity/Dockerfile index 87ce4d0d0f9..ccfd6f08b6b 100644 --- a/tools/dockerfile/test/sanity/Dockerfile +++ b/tools/dockerfile/test/sanity/Dockerfile @@ -81,15 +81,10 @@ RUN apt-get update && apt-get install -y \ RUN python2 -m pip install simplejson mako virtualenv==16.7.9 lxml RUN python3 -m pip install simplejson mako virtualenv==16.7.9 lxml -# Install clang & clang-format -RUN apt-get install -y clang clang-format - -# Install clang-tidy 6.0 -# This is because clang-tidy 7.0 started treating compiler errors as tidy errors -# and there are a couple of files which are not properly compiled via tidy so it -# should be using 6.0 version until all compilation errors are addressed. -RUN apt-get install -y clang-tidy-6.0 jq -ENV CLANG_TIDY=clang-tidy-6.0 +# Install clang, clang-format, and clang-tidy +RUN apt-get install -y clang clang-format-7 clang-tidy-7 jq +ENV CLANG_FORMAT=clang-format-7 +ENV CLANG_TIDY=clang-tidy-7 #========================