From 00fb3b5134dae39208ce8a7b50a8a1fec7c111e2 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 10 Oct 2018 06:26:01 +0000 Subject: [PATCH 01/13] ci: add CI script to run clang-tidy Signed-off-by: Lizan Zhou --- .circleci/config.yml | 8 + .clang-tidy | 306 ++++++++++++++++++++++++++++++ ci/build_setup.sh | 2 +- ci/do_ci.sh | 17 +- tools/gen_compilation_database.py | 21 +- 5 files changed, 346 insertions(+), 8 deletions(-) create mode 100644 .clang-tidy diff --git a/.circleci/config.yml b/.circleci/config.yml index 6566717c6a82..1e233800f208 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -84,6 +84,14 @@ jobs: - run: ci/coverage_publish.sh - store_artifacts: path: /build/envoy/generated/coverage + + clang-tidy: + executor: ubuntu-build + steps: + - run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken + - checkout + - run: ci/do_circle_ci.sh bazel.clang_tidy + format: executor: ubuntu-build resource_class: small diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000000..8fcb5957fe64 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,306 @@ +--- +# -cppcoreguidelines-pro-type-vararg: It will alert on every ASSERT. +Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-google-runtime-references,-llvm-header-guard,-clang-diagnostic-pragma-once-outside-header,-fuchsia-*,-android-*,-cppcoreguidelines-pro-type-vararg,-hicpp-va-arg' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +FormatStyle: none +CheckOptions: + - key: abseil-string-find-startswith.AbseilStringsMatchHeader + value: absl/strings/match.h + - key: abseil-string-find-startswith.IncludeStyle + value: llvm + - key: abseil-string-find-startswith.StringLikeClasses + value: '::std::basic_string' + - key: bugprone-argument-comment.StrictMode + value: '0' + - key: bugprone-assert-side-effect.AssertMacros + value: assert + - key: bugprone-assert-side-effect.CheckFunctionCalls + value: '0' + - key: bugprone-dangling-handle.HandleClasses + value: 'std::basic_string_view;std::experimental::basic_string_view' + - key: bugprone-exception-escape.FunctionsThatShouldNotThrow + value: '' + - key: bugprone-exception-escape.IgnoredExceptions + value: '' + - key: bugprone-misplaced-widening-cast.CheckImplicitCasts + value: '0' + - key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant + value: '1' + - key: bugprone-sizeof-expression.WarnOnSizeOfConstant + value: '1' + - key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression + value: '0' + - key: bugprone-sizeof-expression.WarnOnSizeOfThis + value: '1' + - key: bugprone-string-constructor.LargeLengthThreshold + value: '8388608' + - key: bugprone-string-constructor.WarnOnLargeLength + value: '1' + - key: bugprone-suspicious-enum-usage.StrictMode + value: '0' + - key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens + value: '5' + - key: bugprone-suspicious-missing-comma.RatioThreshold + value: '0.200000' + - key: bugprone-suspicious-missing-comma.SizeThreshold + value: '5' + - key: bugprone-suspicious-string-compare.StringCompareLikeFunctions + value: '' + - key: bugprone-suspicious-string-compare.WarnOnImplicitComparison + value: '1' + - key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison + value: '0' + - key: bugprone-unused-return-value.CheckedFunctions + value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty' + - key: cert-dcl59-cpp.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: cert-err09-cpp.CheckThrowTemporaries + value: '1' + - key: cert-err61-cpp.CheckThrowTemporaries + value: '1' + - key: cert-msc32-c.DisallowedSeedTypes + value: 'time_t,std::time_t' + - key: cert-msc51-cpp.DisallowedSeedTypes + value: 'time_t,std::time_t' + - key: cert-oop11-cpp.IncludeStyle + value: llvm + - key: cppcoreguidelines-no-malloc.Allocations + value: '::malloc;::calloc' + - key: cppcoreguidelines-no-malloc.Deallocations + value: '::free' + - key: cppcoreguidelines-no-malloc.Reallocations + value: '::realloc' + - key: cppcoreguidelines-owning-memory.LegacyResourceConsumers + value: '::free;::realloc;::freopen;::fclose' + - key: cppcoreguidelines-owning-memory.LegacyResourceProducers + value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile' + - key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader + value: '' + - key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle + value: '0' + - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays + value: '0' + - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions + value: '0' + - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor + value: '0' + - key: fuchsia-header-anon-namespaces.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: fuchsia-restrict-system-includes.Includes + value: '*' + - key: google-build-namespaces.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: google-global-names-in-headers.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.BranchThreshold + value: '4294967295' + - key: google-readability-function-size.LineThreshold + value: '4294967295' + - key: google-readability-function-size.NestingThreshold + value: '4294967295' + - key: google-readability-function-size.ParameterThreshold + value: '4294967295' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-function-size.VariableThreshold + value: '4294967295' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: google-runtime-int.SignedTypePrefix + value: int + - key: google-runtime-int.TypeSuffix + value: '' + - key: google-runtime-int.UnsignedTypePrefix + value: uint + - key: hicpp-braces-around-statements.ShortStatementLines + value: '0' + - key: hicpp-function-size.BranchThreshold + value: '4294967295' + - key: hicpp-function-size.LineThreshold + value: '4294967295' + - key: hicpp-function-size.NestingThreshold + value: '4294967295' + - key: hicpp-function-size.ParameterThreshold + value: '4294967295' + - key: hicpp-function-size.StatementThreshold + value: '800' + - key: hicpp-function-size.VariableThreshold + value: '4294967295' + - key: hicpp-member-init.IgnoreArrays + value: '0' + - key: hicpp-move-const-arg.CheckTriviallyCopyableMove + value: '1' + - key: hicpp-multiway-paths-covered.WarnOnMissingElse + value: '0' + - key: hicpp-named-parameter.IgnoreFailedSplit + value: '0' + - key: hicpp-no-malloc.Allocations + value: '::malloc;::calloc' + - key: hicpp-no-malloc.Deallocations + value: '::free' + - key: hicpp-no-malloc.Reallocations + value: '::realloc' + - key: hicpp-special-member-functions.AllowMissingMoveFunctions + value: '0' + - key: hicpp-special-member-functions.AllowSoleDefaultDtor + value: '0' + - key: hicpp-use-auto.MinTypeNameLength + value: '5' + - key: hicpp-use-auto.RemoveStars + value: '0' + - key: hicpp-use-emplace.ContainersWithPushBack + value: '::std::vector;::std::list;::std::deque' + - key: hicpp-use-emplace.SmartPointers + value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' + - key: hicpp-use-emplace.TupleMakeFunctions + value: '::std::make_pair;::std::make_tuple' + - key: hicpp-use-emplace.TupleTypes + value: '::std::pair;::std::tuple' + - key: hicpp-use-equals-default.IgnoreMacros + value: '1' + - key: hicpp-use-noexcept.ReplacementString + value: '' + - key: hicpp-use-noexcept.UseNoexceptFalse + value: '1' + - key: hicpp-use-nullptr.NullMacros + value: '' + - key: llvm-namespace-comment.ShortNamespaceLines + value: '1' + - key: llvm-namespace-comment.SpacesBeforeComments + value: '1' + - key: misc-definitions-in-headers.HeaderFileExtensions + value: ',h,hh,hpp,hxx' + - key: misc-definitions-in-headers.UseHeaderFileExtension + value: '1' + - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries + value: '1' + - key: misc-unused-parameters.StrictMode + value: '0' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-make-shared.IgnoreMacros + value: '1' + - key: modernize-make-shared.IncludeStyle + value: '0' + - key: modernize-make-shared.MakeSmartPtrFunction + value: 'std::make_shared' + - key: modernize-make-shared.MakeSmartPtrFunctionHeader + value: memory + - key: modernize-make-unique.IgnoreMacros + value: '1' + - key: modernize-make-unique.IncludeStyle + value: '0' + - key: modernize-make-unique.MakeSmartPtrFunction + value: 'std::make_unique' + - key: modernize-make-unique.MakeSmartPtrFunctionHeader + value: memory + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-pass-by-value.ValuesOnly + value: '0' + - key: modernize-raw-string-literal.ReplaceShorterLiterals + value: '0' + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-replace-random-shuffle.IncludeStyle + value: llvm + - key: modernize-use-auto.MinTypeNameLength + value: '5' + - key: modernize-use-auto.RemoveStars + value: '0' + - key: modernize-use-default-member-init.IgnoreMacros + value: '1' + - key: modernize-use-default-member-init.UseAssignment + value: '0' + - key: modernize-use-emplace.ContainersWithPushBack + value: '::std::vector;::std::list;::std::deque' + - key: modernize-use-emplace.SmartPointers + value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' + - key: modernize-use-emplace.TupleMakeFunctions + value: '::std::make_pair;::std::make_tuple' + - key: modernize-use-emplace.TupleTypes + value: '::std::pair;::std::tuple' + - key: modernize-use-equals-default.IgnoreMacros + value: '1' + - key: modernize-use-noexcept.ReplacementString + value: '' + - key: modernize-use-noexcept.UseNoexceptFalse + value: '1' + - key: modernize-use-nullptr.NullMacros + value: 'NULL' + - key: modernize-use-transparent-functors.SafeMode + value: '0' + - key: modernize-use-using.IgnoreMacros + value: '1' + - key: objc-forbidden-subclassing.ForbiddenSuperClassNames + value: 'ABNewPersonViewController;ABPeoplePickerNavigationController;ABPersonViewController;ABUnknownPersonViewController;NSHashTable;NSMapTable;NSPointerArray;NSPointerFunctions;NSTimer;UIActionSheet;UIAlertView;UIImagePickerController;UITextInputMode;UIWebView' + - key: objc-property-declaration.Acronyms + value: '' + - key: objc-property-declaration.IncludeDefaultAcronyms + value: '1' + - key: performance-faster-string-find.StringLikeClasses + value: 'std::basic_string' + - key: performance-for-range-copy.WarnOnAllAutoCopies + value: '0' + - key: performance-inefficient-string-concatenation.StrictMode + value: '0' + - key: performance-inefficient-vector-operation.VectorLikeClasses + value: '::std::vector' + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: '1' + - key: performance-move-constructor-init.IncludeStyle + value: llvm + - key: performance-type-promotion-in-math-fn.IncludeStyle + value: llvm + - key: performance-unnecessary-value-param.IncludeStyle + value: llvm + - key: portability-simd-intrinsics.Std + value: '' + - key: portability-simd-intrinsics.Suggest + value: '0' + - key: readability-braces-around-statements.ShortStatementLines + value: '0' + - key: readability-function-size.BranchThreshold + value: '4294967295' + - key: readability-function-size.LineThreshold + value: '4294967295' + - key: readability-function-size.NestingThreshold + value: '4294967295' + - key: readability-function-size.ParameterThreshold + value: '4294967295' + - key: readability-function-size.StatementThreshold + value: '800' + - key: readability-function-size.VariableThreshold + value: '4294967295' + - key: readability-identifier-naming.IgnoreFailedSplit + value: '0' + - key: readability-implicit-bool-conversion.AllowIntegerConditions + value: '0' + - key: readability-implicit-bool-conversion.AllowPointerConditions + value: '0' + - key: readability-inconsistent-declaration-parameter-name.IgnoreMacros + value: '1' + - key: readability-inconsistent-declaration-parameter-name.Strict + value: '0' + - key: readability-simplify-boolean-expr.ChainedConditionalAssignment + value: '0' + - key: readability-simplify-boolean-expr.ChainedConditionalReturn + value: '0' + - key: readability-simplify-subscript-expr.Types + value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array' + - key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold + value: '3' + - key: zircon-temporary-objects.Names + value: '' +... + diff --git a/ci/build_setup.sh b/ci/build_setup.sh index e90dbf14b9a3..b77f10892427 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -113,7 +113,7 @@ export ENVOY_CI_DIR="${ENVOY_SRCDIR}"/ci mkdir -p "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/tools mkdir -p "${ENVOY_CI_DIR}"/tools ln -sf "${ENVOY_SRCDIR}"/tools/bazel.rc "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/tools/ -ln -sf "${ENVOY_SRCDIR}"/tools/bazel.rc "${ENVOY_CI_DIR}"/tools/ +cp "${ENVOY_SRCDIR}"/tools/bazel.rc "${ENVOY_CI_DIR}"/tools/ mkdir -p "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/bazel mkdir -p "${ENVOY_CI_DIR}"/bazel ln -sf "${ENVOY_SRCDIR}"/bazel/get_workspace_status "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/bazel/ diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 5c52e62bf0c1..d3318c28deb0 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -2,7 +2,7 @@ # Run a CI build/test target, e.g. docs, asan. -set -e +set -ex build_setup_args="" if [[ "$1" == "fix_format" || "$1" == "check_format" || "$1" == "check_spelling" || "$1" == "fix_spelling" ]]; then @@ -171,6 +171,21 @@ elif [[ "$1" == "bazel.coverage" ]]; then # directory. Wow. cd "${ENVOY_BUILD_DIR}" SRCDIR="${GCOVR_DIR}" "${ENVOY_SRCDIR}"/test/run_envoy_bazel_coverage.sh + exit 0 +elif [[ "$1" == "bazel.clang_tidy" ]]; then + setup_clang_toolchain + echo "Generating compilation database..." + cd "${ENVOY_CI_DIR}" + + # The compilation database generate script doesn't support passing build options via CLI. + # Writing them into bazelrc + echo "build ${BAZEL_BUILD_OPTIONS}" >> tools/bazel.rc + + # bazel build need to be run to setup virtual includes, generating files which are consumed + # by clang-tidy + "${ENVOY_SRCDIR}/tools/gen_compilation_database.py" --run_bazel_build + run-clang-tidy-7 + exit 0 elif [[ "$1" == "bazel.coverity" ]]; then # Coverity Scan version 2017.07 fails to analyze the entirely of the Envoy diff --git a/tools/gen_compilation_database.py b/tools/gen_compilation_database.py index c312eefb2bee..25fc70cfa718 100755 --- a/tools/gen_compilation_database.py +++ b/tools/gen_compilation_database.py @@ -3,9 +3,15 @@ import argparse import os import json +import subprocess -def generateCompilationDatabase(): - os.system("bazel/gen_compilation_database.sh //source/... //test/... //tools/...") +def generateCompilationDatabase(args): + if args.run_bazel_build: + subprocess.check_call(["bazel", "build"] + args.bazel_targets) + + gen_compilation_database_sh = os.path.join(os.path.realpath(os.path.dirname(__file__)), + "../bazel/gen_compilation_database.sh") + subprocess.check_call([gen_compilation_database_sh] + args.bazel_targets) def isCompileTarget(target, args): filename = target["file"] @@ -40,14 +46,17 @@ def fixCompilationDatabase(args): db = json.load(db_file) db = [modifyCompileCommand(target) for target in db if isCompileTarget(target, args)] + os.remove("compile_commands.json") with open("compile_commands.json", "w") as db_file: json.dump(db, db_file, indent=2) if __name__ == "__main__": parser = argparse.ArgumentParser(description='Generate JSON compilation database') - parser.add_argument('--include_external', type=bool, default=False) - parser.add_argument('--include_genfiles', type=bool, default=False) - parser.add_argument('--include_headers', type=bool, default=False) + parser.add_argument('--run_bazel_build', action='store_true') + parser.add_argument('--include_external', action='store_true') + parser.add_argument('--include_genfiles', action='store_true') + parser.add_argument('--include_headers', action='store_true') + parser.add_argument('bazel_targets', nargs='*', default=["//source/...", "//test/...", "//tools/..."]) args = parser.parse_args() - generateCompilationDatabase() + generateCompilationDatabase(args) fixCompilationDatabase(args) From ce3d2c6a18d144c99bee7aa3c60458e6e7f3c2c7 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 10 Oct 2018 09:47:12 +0000 Subject: [PATCH 02/13] remove debug Signed-off-by: Lizan Zhou --- ci/do_ci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/do_ci.sh b/ci/do_ci.sh index d3318c28deb0..7788020a98d8 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -2,7 +2,7 @@ # Run a CI build/test target, e.g. docs, asan. -set -ex +set -e build_setup_args="" if [[ "$1" == "fix_format" || "$1" == "check_format" || "$1" == "check_spelling" || "$1" == "fix_spelling" ]]; then From 81565c3a1abff2d36254d22b90fd2347981320cf Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 10 Oct 2018 17:53:38 +0000 Subject: [PATCH 03/13] add more comments Signed-off-by: Lizan Zhou --- .clang-tidy | 11 ++++++++++- tools/gen_compilation_database.py | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 8fcb5957fe64..53a3321f33d1 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,14 @@ --- -# -cppcoreguidelines-pro-type-vararg: It will alert on every ASSERT. +# This file defines what clang-tidy checks and parameter. It is experimental, and may let +# clang-tidy issue warnings more than expected. +# Generated with `clang-tidy --checks='*' --dump-config` with following changes: +# +# -cppcoreguidelines-pro-type-vararg, -hicpp-va-arg: +# Raises warning on every ASSERT/RELEASE_ASSERT. +# -llvm-header-guard,-clang-diagnostic-pragma-once-outside-header: +# Allow `#pragma once` header guard. +# -google-runtime-references: +# Allow non-const refereces as function parameter or member variable per Envoy style. Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-google-runtime-references,-llvm-header-guard,-clang-diagnostic-pragma-once-outside-header,-fuchsia-*,-android-*,-cppcoreguidelines-pro-type-vararg,-hicpp-va-arg' WarningsAsErrors: '' HeaderFilterRegex: '' diff --git a/tools/gen_compilation_database.py b/tools/gen_compilation_database.py index 25fc70cfa718..39398cf4a7a1 100755 --- a/tools/gen_compilation_database.py +++ b/tools/gen_compilation_database.py @@ -46,6 +46,8 @@ def fixCompilationDatabase(args): db = json.load(db_file) db = [modifyCompileCommand(target) for target in db if isCompileTarget(target, args)] + + # Remove to avoid writing into symlink os.remove("compile_commands.json") with open("compile_commands.json", "w") as db_file: json.dump(db, db_file, indent=2) From 48e6eb30d9b9ba058254ca11e6b1ee1e8bd8b59d Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 10 Oct 2018 17:54:44 +0000 Subject: [PATCH 04/13] add ci doc Signed-off-by: Lizan Zhou --- .circleci/config.yml | 2 +- ci/README.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e233800f208..3d3559548f65 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ executors: ubuntu-build: description: "A regular build executor based on ubuntu image" docker: - - image: envoyproxy/envoy-build:faea2a2ebc397b7a3a5e3c877ceaefc5cf4daf25 + - image: envoyproxy/envoy-build:e6cb78532ee38ceec5282693011ac68c0aed6275 resource_class: xlarge working_directory: /source diff --git a/ci/README.md b/ci/README.md index 8d402f8dd235..91df7f398263 100644 --- a/ci/README.md +++ b/ci/README.md @@ -82,7 +82,8 @@ The `./ci/run_envoy_docker.sh './ci/do_ci.sh '` targets are: * `bazel.release.server_only` — build Envoy static binary under `-c opt` with gcc. * `bazel.coverage` — build and run tests under `-c dbg` with gcc, generating coverage information in `$ENVOY_DOCKER_BUILD_DIR/envoy/generated/coverage/coverage.html`. * `bazel.coverity` — build Envoy static binary and run Coverity Scan static analysis. -* `bazel.tsan` — build and run tests under `-c dbg --config=clang-tsan` with clang-6.0. +* `bazel.tsan` — build and run tests under `-c dbg --config=clang-tsan` with clang. +* `bazel.clang_tidy` — build and run clang-tidy over all source files. * `check_format`— run `clang-format-6.0` and `buildifier` on entire source tree. * `fix_format`— run and enforce `clang-format-6.0` and `buildifier` on entire source tree. * `check_spelling`— run `misspell` on entire project. From fac609eaad36ae11c4e4c014d27e07d7d6a61664 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 10 Oct 2018 20:57:52 +0000 Subject: [PATCH 05/13] fix typo Signed-off-by: Lizan Zhou --- .clang-tidy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 53a3321f33d1..1c3dfa7472dc 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -8,7 +8,7 @@ # -llvm-header-guard,-clang-diagnostic-pragma-once-outside-header: # Allow `#pragma once` header guard. # -google-runtime-references: -# Allow non-const refereces as function parameter or member variable per Envoy style. +# Allow non-const references as function parameter or member variable per Envoy style. Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-google-runtime-references,-llvm-header-guard,-clang-diagnostic-pragma-once-outside-header,-fuchsia-*,-android-*,-cppcoreguidelines-pro-type-vararg,-hicpp-va-arg' WarningsAsErrors: '' HeaderFilterRegex: '' From 3441099e862a7249a4f70c485711e07bababd7d6 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Thu, 11 Oct 2018 20:07:06 +0000 Subject: [PATCH 06/13] Cleaning up .clang-tidy Signed-off-by: Lizan Zhou --- .clang-tidy | 323 ++-------------------------------------------- ci/build_setup.sh | 4 +- 2 files changed, 13 insertions(+), 314 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1c3dfa7472dc..1d66cb13144f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,315 +1,14 @@ ---- -# This file defines what clang-tidy checks and parameter. It is experimental, and may let -# clang-tidy issue warnings more than expected. -# Generated with `clang-tidy --checks='*' --dump-config` with following changes: -# -# -cppcoreguidelines-pro-type-vararg, -hicpp-va-arg: -# Raises warning on every ASSERT/RELEASE_ASSERT. -# -llvm-header-guard,-clang-diagnostic-pragma-once-outside-header: -# Allow `#pragma once` header guard. -# -google-runtime-references: -# Allow non-const references as function parameter or member variable per Envoy style. -Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-google-runtime-references,-llvm-header-guard,-clang-diagnostic-pragma-once-outside-header,-fuchsia-*,-android-*,-cppcoreguidelines-pro-type-vararg,-hicpp-va-arg' -WarningsAsErrors: '' -HeaderFilterRegex: '' -AnalyzeTemporaryDtors: false -FormatStyle: none -CheckOptions: - - key: abseil-string-find-startswith.AbseilStringsMatchHeader - value: absl/strings/match.h - - key: abseil-string-find-startswith.IncludeStyle - value: llvm - - key: abseil-string-find-startswith.StringLikeClasses - value: '::std::basic_string' - - key: bugprone-argument-comment.StrictMode - value: '0' +Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,bugprone-*,modernize-*,performance-*,readability-redundant-*' + +#TODO(lizan): grow this list, fix possible warnings and make more checks as error +WarningsAsErrors: 'bugprone-assert-side-effect,modernize-make-shared,modernize-make-unique,readability-redundant-smartptr-get' + +CheckOptions: - key: bugprone-assert-side-effect.AssertMacros - value: assert - - key: bugprone-assert-side-effect.CheckFunctionCalls - value: '0' + value: 'ASSERT' + - key: bugprone-dangling-handle.HandleClasses - value: 'std::basic_string_view;std::experimental::basic_string_view' - - key: bugprone-exception-escape.FunctionsThatShouldNotThrow - value: '' - - key: bugprone-exception-escape.IgnoredExceptions - value: '' - - key: bugprone-misplaced-widening-cast.CheckImplicitCasts - value: '0' - - key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant - value: '1' - - key: bugprone-sizeof-expression.WarnOnSizeOfConstant - value: '1' - - key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression - value: '0' - - key: bugprone-sizeof-expression.WarnOnSizeOfThis - value: '1' - - key: bugprone-string-constructor.LargeLengthThreshold - value: '8388608' - - key: bugprone-string-constructor.WarnOnLargeLength - value: '1' - - key: bugprone-suspicious-enum-usage.StrictMode - value: '0' - - key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens - value: '5' - - key: bugprone-suspicious-missing-comma.RatioThreshold - value: '0.200000' - - key: bugprone-suspicious-missing-comma.SizeThreshold - value: '5' - - key: bugprone-suspicious-string-compare.StringCompareLikeFunctions - value: '' - - key: bugprone-suspicious-string-compare.WarnOnImplicitComparison - value: '1' - - key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison - value: '0' - - key: bugprone-unused-return-value.CheckedFunctions - value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty' - - key: cert-dcl59-cpp.HeaderFileExtensions - value: ',h,hh,hpp,hxx' - - key: cert-err09-cpp.CheckThrowTemporaries - value: '1' - - key: cert-err61-cpp.CheckThrowTemporaries - value: '1' - - key: cert-msc32-c.DisallowedSeedTypes - value: 'time_t,std::time_t' - - key: cert-msc51-cpp.DisallowedSeedTypes - value: 'time_t,std::time_t' - - key: cert-oop11-cpp.IncludeStyle - value: llvm - - key: cppcoreguidelines-no-malloc.Allocations - value: '::malloc;::calloc' - - key: cppcoreguidelines-no-malloc.Deallocations - value: '::free' - - key: cppcoreguidelines-no-malloc.Reallocations - value: '::realloc' - - key: cppcoreguidelines-owning-memory.LegacyResourceConsumers - value: '::free;::realloc;::freopen;::fclose' - - key: cppcoreguidelines-owning-memory.LegacyResourceProducers - value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile' - - key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader - value: '' - - key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle - value: '0' - - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays - value: '0' - - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions - value: '0' - - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor - value: '0' - - key: fuchsia-header-anon-namespaces.HeaderFileExtensions - value: ',h,hh,hpp,hxx' - - key: fuchsia-restrict-system-includes.Includes - value: '*' - - key: google-build-namespaces.HeaderFileExtensions - value: ',h,hh,hpp,hxx' - - key: google-global-names-in-headers.HeaderFileExtensions - value: ',h,hh,hpp,hxx' - - key: google-readability-braces-around-statements.ShortStatementLines - value: '1' - - key: google-readability-function-size.BranchThreshold - value: '4294967295' - - key: google-readability-function-size.LineThreshold - value: '4294967295' - - key: google-readability-function-size.NestingThreshold - value: '4294967295' - - key: google-readability-function-size.ParameterThreshold - value: '4294967295' - - key: google-readability-function-size.StatementThreshold - value: '800' - - key: google-readability-function-size.VariableThreshold - value: '4294967295' - - key: google-readability-namespace-comments.ShortNamespaceLines - value: '10' - - key: google-readability-namespace-comments.SpacesBeforeComments - value: '2' - - key: google-runtime-int.SignedTypePrefix - value: int - - key: google-runtime-int.TypeSuffix - value: '' - - key: google-runtime-int.UnsignedTypePrefix - value: uint - - key: hicpp-braces-around-statements.ShortStatementLines - value: '0' - - key: hicpp-function-size.BranchThreshold - value: '4294967295' - - key: hicpp-function-size.LineThreshold - value: '4294967295' - - key: hicpp-function-size.NestingThreshold - value: '4294967295' - - key: hicpp-function-size.ParameterThreshold - value: '4294967295' - - key: hicpp-function-size.StatementThreshold - value: '800' - - key: hicpp-function-size.VariableThreshold - value: '4294967295' - - key: hicpp-member-init.IgnoreArrays - value: '0' - - key: hicpp-move-const-arg.CheckTriviallyCopyableMove - value: '1' - - key: hicpp-multiway-paths-covered.WarnOnMissingElse - value: '0' - - key: hicpp-named-parameter.IgnoreFailedSplit - value: '0' - - key: hicpp-no-malloc.Allocations - value: '::malloc;::calloc' - - key: hicpp-no-malloc.Deallocations - value: '::free' - - key: hicpp-no-malloc.Reallocations - value: '::realloc' - - key: hicpp-special-member-functions.AllowMissingMoveFunctions - value: '0' - - key: hicpp-special-member-functions.AllowSoleDefaultDtor - value: '0' - - key: hicpp-use-auto.MinTypeNameLength - value: '5' - - key: hicpp-use-auto.RemoveStars - value: '0' - - key: hicpp-use-emplace.ContainersWithPushBack - value: '::std::vector;::std::list;::std::deque' - - key: hicpp-use-emplace.SmartPointers - value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' - - key: hicpp-use-emplace.TupleMakeFunctions - value: '::std::make_pair;::std::make_tuple' - - key: hicpp-use-emplace.TupleTypes - value: '::std::pair;::std::tuple' - - key: hicpp-use-equals-default.IgnoreMacros - value: '1' - - key: hicpp-use-noexcept.ReplacementString - value: '' - - key: hicpp-use-noexcept.UseNoexceptFalse - value: '1' - - key: hicpp-use-nullptr.NullMacros - value: '' - - key: llvm-namespace-comment.ShortNamespaceLines - value: '1' - - key: llvm-namespace-comment.SpacesBeforeComments - value: '1' - - key: misc-definitions-in-headers.HeaderFileExtensions - value: ',h,hh,hpp,hxx' - - key: misc-definitions-in-headers.UseHeaderFileExtension - value: '1' - - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries - value: '1' - - key: misc-unused-parameters.StrictMode - value: '0' - - key: modernize-loop-convert.MaxCopySize - value: '16' - - key: modernize-loop-convert.MinConfidence - value: reasonable - - key: modernize-loop-convert.NamingStyle - value: CamelCase - - key: modernize-make-shared.IgnoreMacros - value: '1' - - key: modernize-make-shared.IncludeStyle - value: '0' - - key: modernize-make-shared.MakeSmartPtrFunction - value: 'std::make_shared' - - key: modernize-make-shared.MakeSmartPtrFunctionHeader - value: memory - - key: modernize-make-unique.IgnoreMacros - value: '1' - - key: modernize-make-unique.IncludeStyle - value: '0' - - key: modernize-make-unique.MakeSmartPtrFunction - value: 'std::make_unique' - - key: modernize-make-unique.MakeSmartPtrFunctionHeader - value: memory - - key: modernize-pass-by-value.IncludeStyle - value: llvm - - key: modernize-pass-by-value.ValuesOnly - value: '0' - - key: modernize-raw-string-literal.ReplaceShorterLiterals - value: '0' - - key: modernize-replace-auto-ptr.IncludeStyle - value: llvm - - key: modernize-replace-random-shuffle.IncludeStyle - value: llvm - - key: modernize-use-auto.MinTypeNameLength - value: '5' - - key: modernize-use-auto.RemoveStars - value: '0' - - key: modernize-use-default-member-init.IgnoreMacros - value: '1' - - key: modernize-use-default-member-init.UseAssignment - value: '0' - - key: modernize-use-emplace.ContainersWithPushBack - value: '::std::vector;::std::list;::std::deque' - - key: modernize-use-emplace.SmartPointers - value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' - - key: modernize-use-emplace.TupleMakeFunctions - value: '::std::make_pair;::std::make_tuple' - - key: modernize-use-emplace.TupleTypes - value: '::std::pair;::std::tuple' - - key: modernize-use-equals-default.IgnoreMacros - value: '1' - - key: modernize-use-noexcept.ReplacementString - value: '' - - key: modernize-use-noexcept.UseNoexceptFalse - value: '1' - - key: modernize-use-nullptr.NullMacros - value: 'NULL' - - key: modernize-use-transparent-functors.SafeMode - value: '0' - - key: modernize-use-using.IgnoreMacros - value: '1' - - key: objc-forbidden-subclassing.ForbiddenSuperClassNames - value: 'ABNewPersonViewController;ABPeoplePickerNavigationController;ABPersonViewController;ABUnknownPersonViewController;NSHashTable;NSMapTable;NSPointerArray;NSPointerFunctions;NSTimer;UIActionSheet;UIAlertView;UIImagePickerController;UITextInputMode;UIWebView' - - key: objc-property-declaration.Acronyms - value: '' - - key: objc-property-declaration.IncludeDefaultAcronyms - value: '1' - - key: performance-faster-string-find.StringLikeClasses - value: 'std::basic_string' - - key: performance-for-range-copy.WarnOnAllAutoCopies - value: '0' - - key: performance-inefficient-string-concatenation.StrictMode - value: '0' - - key: performance-inefficient-vector-operation.VectorLikeClasses - value: '::std::vector' - - key: performance-move-const-arg.CheckTriviallyCopyableMove - value: '1' - - key: performance-move-constructor-init.IncludeStyle - value: llvm - - key: performance-type-promotion-in-math-fn.IncludeStyle - value: llvm - - key: performance-unnecessary-value-param.IncludeStyle - value: llvm - - key: portability-simd-intrinsics.Std - value: '' - - key: portability-simd-intrinsics.Suggest - value: '0' - - key: readability-braces-around-statements.ShortStatementLines - value: '0' - - key: readability-function-size.BranchThreshold - value: '4294967295' - - key: readability-function-size.LineThreshold - value: '4294967295' - - key: readability-function-size.NestingThreshold - value: '4294967295' - - key: readability-function-size.ParameterThreshold - value: '4294967295' - - key: readability-function-size.StatementThreshold - value: '800' - - key: readability-function-size.VariableThreshold - value: '4294967295' - - key: readability-identifier-naming.IgnoreFailedSplit - value: '0' - - key: readability-implicit-bool-conversion.AllowIntegerConditions - value: '0' - - key: readability-implicit-bool-conversion.AllowPointerConditions - value: '0' - - key: readability-inconsistent-declaration-parameter-name.IgnoreMacros - value: '1' - - key: readability-inconsistent-declaration-parameter-name.Strict - value: '0' - - key: readability-simplify-boolean-expr.ChainedConditionalAssignment - value: '0' - - key: readability-simplify-boolean-expr.ChainedConditionalReturn - value: '0' - - key: readability-simplify-subscript-expr.Types - value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array' - - key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold - value: '3' - - key: zircon-temporary-objects.Names - value: '' -... + value: 'std::basic_string_view;std::experimental::basic_string_view;absl::string_view' + - key: modernize-use-auto.MinTypeNameLength + value: '10' diff --git a/ci/build_setup.sh b/ci/build_setup.sh index b77f10892427..219a2dc8b269 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -124,8 +124,8 @@ export BUILDIFIER_BIN="/usr/local/bin/buildifier" function cleanup() { # Remove build artifacts. This doesn't mess with incremental builds as these # are just symlinks. - rm -f "${ENVOY_SRCDIR}"/bazel-* - rm -f "${ENVOY_CI_DIR}"/bazel-* + rm -rf "${ENVOY_SRCDIR}"/bazel-* + rm -rf "${ENVOY_CI_DIR}"/bazel-* rm -rf "${ENVOY_CI_DIR}"/bazel rm -rf "${ENVOY_CI_DIR}"/tools } From 67bea2609e6408496769b5306f17ad9664b28002 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 12 Oct 2018 19:39:30 +0000 Subject: [PATCH 07/13] add braces check Signed-off-by: Lizan Zhou --- .clang-tidy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 1d66cb13144f..c18c25f5f06e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,7 @@ -Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,bugprone-*,modernize-*,performance-*,readability-redundant-*' +Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,bugprone-*,modernize-*,performance-*,readability-redundant-*,readability-braces-around-statements' #TODO(lizan): grow this list, fix possible warnings and make more checks as error -WarningsAsErrors: 'bugprone-assert-side-effect,modernize-make-shared,modernize-make-unique,readability-redundant-smartptr-get' +WarningsAsErrors: 'bugprone-assert-side-effect,modernize-make-shared,modernize-make-unique,readability-redundant-smartptr-get,readability-braces-around-statements' CheckOptions: - key: bugprone-assert-side-effect.AssertMacros From f55bfd32ba42a5f89efeebdfa4564b51e1f31e6a Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 12 Oct 2018 20:07:10 +0000 Subject: [PATCH 08/13] run against diff Signed-off-by: Lizan Zhou --- .clang-tidy | 2 +- ci/do_ci.sh | 12 +----------- ci/run_clang_tidy.sh | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100755 ci/run_clang_tidy.sh diff --git a/.clang-tidy b/.clang-tidy index c18c25f5f06e..55d1c2389161 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,7 +3,7 @@ Checks: 'clang-diagnostic-*,clang-analyzer-*,abseil-*,bugprone-*,modern #TODO(lizan): grow this list, fix possible warnings and make more checks as error WarningsAsErrors: 'bugprone-assert-side-effect,modernize-make-shared,modernize-make-unique,readability-redundant-smartptr-get,readability-braces-around-statements' -CheckOptions: +CheckOptions: - key: bugprone-assert-side-effect.AssertMacros value: 'ASSERT' diff --git a/ci/do_ci.sh b/ci/do_ci.sh index 7788020a98d8..49e6a9d8103c 100755 --- a/ci/do_ci.sh +++ b/ci/do_ci.sh @@ -174,18 +174,8 @@ elif [[ "$1" == "bazel.coverage" ]]; then exit 0 elif [[ "$1" == "bazel.clang_tidy" ]]; then setup_clang_toolchain - echo "Generating compilation database..." cd "${ENVOY_CI_DIR}" - - # The compilation database generate script doesn't support passing build options via CLI. - # Writing them into bazelrc - echo "build ${BAZEL_BUILD_OPTIONS}" >> tools/bazel.rc - - # bazel build need to be run to setup virtual includes, generating files which are consumed - # by clang-tidy - "${ENVOY_SRCDIR}/tools/gen_compilation_database.py" --run_bazel_build - run-clang-tidy-7 - + ./run_clang_tidy.sh exit 0 elif [[ "$1" == "bazel.coverity" ]]; then # Coverity Scan version 2017.07 fails to analyze the entirely of the Envoy diff --git a/ci/run_clang_tidy.sh b/ci/run_clang_tidy.sh new file mode 100755 index 000000000000..5f21666b715f --- /dev/null +++ b/ci/run_clang_tidy.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +echo "Generating compilation database..." +# The compilation database generate script doesn't support passing build options via CLI. +# Writing them into bazelrc +echo "build ${BAZEL_BUILD_OPTIONS}" >> tools/bazel.rc + +# bazel build need to be run to setup virtual includes, generating files which are consumed +# by clang-tidy +"${ENVOY_SRCDIR}/tools/gen_compilation_database.py" --run_bazel_build + +if [[ "${RUN_FULL_CLANG_TIDY}" == 1 ]]; then + echo "Running full clang-tidy..." + run-clang-tidy-7 +elif [[ -z "${CIRCLE_PR_NUMBER}" && "$CIRCLE_BRANCH" == "master" ]]; then + echo "On master branch, running clang-tidy-diff against previous commit..." + git diff HEAD^ | clang-tidy-diff-7.py -p 1 +else + echo "Running clang-tidy-diff against master branch..." + git fetch https://github.com/envoyproxy/envoy.git master + git diff $(git merge-base HEAD FETCH_HEAD)..HEAD | clang-tidy-diff-7.py -p 1 +fi From 1406e3b17b721473f29809ea63683b54136008d2 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 12 Oct 2018 20:23:14 +0000 Subject: [PATCH 09/13] fix path Signed-off-by: Lizan Zhou --- ci/run_clang_tidy.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/run_clang_tidy.sh b/ci/run_clang_tidy.sh index 5f21666b715f..7c694f430749 100755 --- a/ci/run_clang_tidy.sh +++ b/ci/run_clang_tidy.sh @@ -11,6 +11,11 @@ echo "build ${BAZEL_BUILD_OPTIONS}" >> tools/bazel.rc # by clang-tidy "${ENVOY_SRCDIR}/tools/gen_compilation_database.py" --run_bazel_build +# It had to be in ENVOY_CI_DIR to run bazel to generate compile database, but clang-tidy-diff +# diff against current directory, moving them to ENVOY_SRCDIR. +mv ./compile_commands.json "${ENVOY_SRCDIR}/compile_commands.json" +cd "${ENVOY_SRCDIR}" + if [[ "${RUN_FULL_CLANG_TIDY}" == 1 ]]; then echo "Running full clang-tidy..." run-clang-tidy-7 From 7817f4662a56f787311f2ea6aba910c1769da056 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 19 Oct 2018 20:24:08 +0000 Subject: [PATCH 10/13] update build image Signed-off-by: Lizan Zhou --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d8a45ae95f9..a8dd1952343c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ executors: ubuntu-build: description: "A regular build executor based on ubuntu image" docker: - - image: envoyproxy/envoy-build:e6cb78532ee38ceec5282693011ac68c0aed6275 + - image: envoyproxy/envoy-build:dba462267df2f881f676ed7eb0c31637f646add2 resource_class: xlarge working_directory: /source From 8078e7432ba6c7cbd3e31eb799cab9f4533105fe Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 24 Oct 2018 07:29:41 +0000 Subject: [PATCH 11/13] review comments Signed-off-by: Lizan Zhou --- .circleci/config.yml | 3 ++- ci/build_setup.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bbdaae64ec87..52fb9cd1ec75 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -83,7 +83,7 @@ jobs: - store_artifacts: path: /build/envoy/generated/coverage - clang-tidy: + clang_tidy: executor: ubuntu-build steps: - run: rm -rf /home/circleci/project/.git # CircleCI git caching is likely broken @@ -148,6 +148,7 @@ workflows: - ipv6_tests - coverage - format + - clang_tidy - build_image - docs: filters: diff --git a/ci/build_setup.sh b/ci/build_setup.sh index 6c11fdd7ef03..f13905ca9139 100755 --- a/ci/build_setup.sh +++ b/ci/build_setup.sh @@ -114,8 +114,8 @@ mkdir -p "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/bazel mkdir -p "${ENVOY_CI_DIR}"/bazel ln -sf "${ENVOY_SRCDIR}"/bazel/get_workspace_status "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/bazel/ ln -sf "${ENVOY_SRCDIR}"/bazel/get_workspace_status "${ENVOY_CI_DIR}"/bazel/ -cp "${ENVOY_SRCDIR}"/.bazelrc "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/ -cp "${ENVOY_SRCDIR}"/.bazelrc "${ENVOY_CI_DIR}"/ +cp -f "${ENVOY_SRCDIR}"/.bazelrc "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/ +cp -f "${ENVOY_SRCDIR}"/.bazelrc "${ENVOY_CI_DIR}"/ # TODO(PiotrSikora): remove once we deprecate tools/bazel.rc in favor of .bazelrc. mkdir -p "${ENVOY_FILTER_EXAMPLE_SRCDIR}"/tools mkdir -p "${ENVOY_CI_DIR}"/tools From 6904c852908e4cdc2ffc7b395cd8b4eef2f18e25 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Fri, 12 Oct 2018 20:16:24 +0000 Subject: [PATCH 12/13] test clang-tidy Signed-off-by: Lizan Zhou --- source/common/ssl/utility.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/common/ssl/utility.cc b/source/common/ssl/utility.cc index c5ba449b6608..ef0a6ea0c73e 100644 --- a/source/common/ssl/utility.cc +++ b/source/common/ssl/utility.cc @@ -34,9 +34,8 @@ std::vector Utility::getSubjectAltNames(X509& cert, int type) { std::vector subject_alt_names; bssl::UniquePtr san_names( static_cast(X509_get_ext_d2i(&cert, NID_subject_alt_name, nullptr, nullptr))); - if (san_names == nullptr) { + if (san_names == nullptr) return subject_alt_names; - } for (const GENERAL_NAME* san : san_names.get()) { if (san->type == type) { ASN1_STRING* str = san->d.dNSName; From 7cd3c854fc451f2ff4713a4cc0713552705fa936 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 24 Oct 2018 21:31:59 +0000 Subject: [PATCH 13/13] Revert "test clang-tidy" This reverts commit 6904c852908e4cdc2ffc7b395cd8b4eef2f18e25. Signed-off-by: Lizan Zhou --- source/common/ssl/utility.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/common/ssl/utility.cc b/source/common/ssl/utility.cc index ef0a6ea0c73e..c5ba449b6608 100644 --- a/source/common/ssl/utility.cc +++ b/source/common/ssl/utility.cc @@ -34,8 +34,9 @@ std::vector Utility::getSubjectAltNames(X509& cert, int type) { std::vector subject_alt_names; bssl::UniquePtr san_names( static_cast(X509_get_ext_d2i(&cert, NID_subject_alt_name, nullptr, nullptr))); - if (san_names == nullptr) + if (san_names == nullptr) { return subject_alt_names; + } for (const GENERAL_NAME* san : san_names.get()) { if (san->type == type) { ASN1_STRING* str = san->d.dNSName;