From 86e5e821531ff563b7e4642aa792d9e0f3067557 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 10 Dec 2022 14:51:34 -0500 Subject: Test headers for warnings more strictly --- test/.clang-tidy | 13 +---------- test/cpp/.clang-tidy | 26 ++++++++++++++++++++++ test/cpp/test_build.cpp | 54 +++++++++++++++++++++++++++++++++++++++++++++ test/headers/.clang-tidy | 21 ++++++++++++++++++ test/headers/meson.build | 53 ++++++++++++++++++++++++++++++++++++++++++++ test/headers/test_headers.c | 42 +++++++++++++++++++++++++++++++++++ test/meson.build | 8 ++++++- test/test_build.cpp | 54 --------------------------------------------- 8 files changed, 204 insertions(+), 67 deletions(-) create mode 100644 test/cpp/.clang-tidy create mode 100644 test/cpp/test_build.cpp create mode 100644 test/headers/.clang-tidy create mode 100644 test/headers/meson.build create mode 100644 test/headers/test_headers.c delete mode 100644 test/test_build.cpp (limited to 'test') diff --git a/test/.clang-tidy b/test/.clang-tidy index ca868be..1c1d56a 100644 --- a/test/.clang-tidy +++ b/test/.clang-tidy @@ -2,25 +2,14 @@ # SPDX-License-Identifier: 0BSD OR ISC Checks: > - *, -*-else-after-return, -*-magic-numbers, - -altera-*, -bugprone-easily-swappable-parameters, -bugprone-macro-parentheses, -bugprone-suspicious-include, - -llvm-header-guard, -llvmlibc-implementation-in-namespace, - -llvmlibc-restrict-system-libc-headers, -modernize-use-trailing-return-type, -performance-no-int-to-ptr, -readability-function-cognitive-complexity, -readability-identifier-length, -WarningsAsErrors: '*' -HeaderFilterRegex: '.*' -FormatStyle: file -CheckOptions: - - key: hicpp-uppercase-literal-suffix.NewSuffixes - value: L;U;f - - key: readability-uppercase-literal-suffix.NewSuffixes - value: L;U;f +InheritParentConfig: true diff --git a/test/cpp/.clang-tidy b/test/cpp/.clang-tidy new file mode 100644 index 0000000..02d730c --- /dev/null +++ b/test/cpp/.clang-tidy @@ -0,0 +1,26 @@ +# Copyright 2020-2022 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +Checks: > + -*-avoid-c-arrays, + -*-deprecated-headers, + -*-no-malloc, + -*-use-auto, + -bugprone-reserved-identifier, + -cert-dcl37-c, + -cert-dcl50-cpp, + -cert-dcl51-cpp, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-cstyle-cast, + -cppcoreguidelines-pro-type-vararg, + -hicpp-no-array-decay, + -hicpp-vararg, + -llvmlibc-callee-namespace, + -modernize-use-nullptr, + -modernize-use-using, + -readability-implicit-bool-conversion, +InheritParentConfig: true + diff --git a/test/cpp/test_build.cpp b/test/cpp/test_build.cpp new file mode 100644 index 0000000..c8b2ca0 --- /dev/null +++ b/test/cpp/test_build.cpp @@ -0,0 +1,54 @@ +// Copyright 2022 David Robillard +// SPDX-License-Identifier: ISC + +#if defined(__clang__) +_Pragma("clang diagnostic push") +_Pragma("clang diagnostic ignored \"-Wold-style-cast\"") +_Pragma("clang diagnostic ignored \"-Wzero-as-null-pointer-constant\"") +#elif defined(__GNUC__) +_Pragma("GCC diagnostic push") +_Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") +#endif + +#include "lv2/atom/atom.h" // IWYU pragma: keep +#include "lv2/atom/forge.h" // IWYU pragma: keep +#include "lv2/atom/util.h" // IWYU pragma: keep +#include "lv2/buf-size/buf-size.h" // IWYU pragma: keep +#include "lv2/core/attributes.h" // IWYU pragma: keep +#include "lv2/core/lv2.h" // IWYU pragma: keep +#include "lv2/core/lv2_util.h" // IWYU pragma: keep +#include "lv2/data-access/data-access.h" // IWYU pragma: keep +#include "lv2/dynmanifest/dynmanifest.h" // IWYU pragma: keep +#include "lv2/event/event-helpers.h" // IWYU pragma: keep +#include "lv2/event/event.h" // IWYU pragma: keep +#include "lv2/instance-access/instance-access.h" // IWYU pragma: keep +#include "lv2/log/log.h" // IWYU pragma: keep +#include "lv2/log/logger.h" // IWYU pragma: keep +#include "lv2/midi/midi.h" // IWYU pragma: keep +#include "lv2/morph/morph.h" // IWYU pragma: keep +#include "lv2/options/options.h" // IWYU pragma: keep +#include "lv2/parameters/parameters.h" // IWYU pragma: keep +#include "lv2/patch/patch.h" // IWYU pragma: keep +#include "lv2/port-groups/port-groups.h" // IWYU pragma: keep +#include "lv2/port-props/port-props.h" // IWYU pragma: keep +#include "lv2/presets/presets.h" // IWYU pragma: keep +#include "lv2/resize-port/resize-port.h" // IWYU pragma: keep +#include "lv2/state/state.h" // IWYU pragma: keep +#include "lv2/time/time.h" // IWYU pragma: keep +#include "lv2/ui/ui.h" // IWYU pragma: keep +#include "lv2/units/units.h" // IWYU pragma: keep +#include "lv2/uri-map/uri-map.h" // IWYU pragma: keep +#include "lv2/urid/urid.h" // IWYU pragma: keep +#include "lv2/worker/worker.h" // IWYU pragma: keep + +int +main() +{ + return 0; +} + +#if defined(__clang__) +_Pragma("clang diagnostic pop") +#elif defined(__GNUC__) +_Pragma("GCC diagnostic pop") +#endif diff --git a/test/headers/.clang-tidy b/test/headers/.clang-tidy new file mode 100644 index 0000000..6ef3ba1 --- /dev/null +++ b/test/headers/.clang-tidy @@ -0,0 +1,21 @@ +# Copyright 2020-2022 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +Checks: > + *, + -*-magic-numbers, + -altera-*, + -bugprone-easily-swappable-parameters, + -bugprone-macro-parentheses, + -llvm-header-guard, + -llvmlibc-restrict-system-libc-headers, + -performance-no-int-to-ptr, + -readability-identifier-length, +CheckOptions: + - key: hicpp-uppercase-literal-suffix.NewSuffixes + value: L;U;f + - key: readability-uppercase-literal-suffix.NewSuffixes + value: L;U;f +FormatStyle: file +HeaderFilterRegex: 'lv2/.*\.h' +WarningsAsErrors: '*' diff --git a/test/headers/meson.build b/test/headers/meson.build new file mode 100644 index 0000000..e0a2d76 --- /dev/null +++ b/test/headers/meson.build @@ -0,0 +1,53 @@ +# Copyright 2020-2022 David Robillard +# SPDX-License-Identifier: 0BSD OR ISC + +header_c_suppressions = [] + +if get_option('strict') + if cc.get_id() == 'clang' + header_c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-declaration-after-statement', + '-Wno-padded', + ] + + elif cc.get_id() == 'gcc' + header_c_suppressions += [ + '-Wno-cast-align', + '-Wno-cast-qual', + '-Wno-padded', + '-Wno-sign-conversion', + '-Wno-suggest-attribute=format', + '-Wno-unused-const-variable', + ] + + if host_machine.system() == 'windows' + header_c_suppressions += [ + '-Wno-sign-conversion', + ] + endif + + elif cc.get_id() == 'msvc' + header_c_suppressions += [ + '/wd4820', # padding added after construct + ] + endif +endif + +if cc.get_id() == 'clang' + header_c_suppressions += [ + '-Wno-nullability-extension', + ] +endif + +test( + 'headers', + executable( + 'test_headers', + files('test_headers.c'), + c_args: header_c_suppressions, + dependencies: [lv2_dep], + ), + suite: 'unit', +) diff --git a/test/headers/test_headers.c b/test/headers/test_headers.c new file mode 100644 index 0000000..5736b44 --- /dev/null +++ b/test/headers/test_headers.c @@ -0,0 +1,42 @@ +// Copyright 2022 David Robillard +// SPDX-License-Identifier: ISC + +#include "lv2/atom/atom.h" // IWYU pragma: keep +#include "lv2/atom/forge.h" // IWYU pragma: keep +#include "lv2/atom/util.h" // IWYU pragma: keep +#include "lv2/buf-size/buf-size.h" // IWYU pragma: keep +#include "lv2/core/attributes.h" // IWYU pragma: keep +#include "lv2/core/lv2.h" // IWYU pragma: keep +#include "lv2/core/lv2_util.h" // IWYU pragma: keep +#include "lv2/data-access/data-access.h" // IWYU pragma: keep +#include "lv2/dynmanifest/dynmanifest.h" // IWYU pragma: keep +#include "lv2/event/event-helpers.h" // IWYU pragma: keep +#include "lv2/event/event.h" // IWYU pragma: keep +#include "lv2/instance-access/instance-access.h" // IWYU pragma: keep +#include "lv2/log/log.h" // IWYU pragma: keep +#include "lv2/log/logger.h" // IWYU pragma: keep +#include "lv2/midi/midi.h" // IWYU pragma: keep +#include "lv2/morph/morph.h" // IWYU pragma: keep +#include "lv2/options/options.h" // IWYU pragma: keep +#include "lv2/parameters/parameters.h" // IWYU pragma: keep +#include "lv2/patch/patch.h" // IWYU pragma: keep +#include "lv2/port-groups/port-groups.h" // IWYU pragma: keep +#include "lv2/port-props/port-props.h" // IWYU pragma: keep +#include "lv2/presets/presets.h" // IWYU pragma: keep +#include "lv2/resize-port/resize-port.h" // IWYU pragma: keep +#include "lv2/state/state.h" // IWYU pragma: keep +#include "lv2/time/time.h" // IWYU pragma: keep +#include "lv2/ui/ui.h" // IWYU pragma: keep +#include "lv2/units/units.h" // IWYU pragma: keep +#include "lv2/uri-map/uri-map.h" // IWYU pragma: keep +#include "lv2/urid/urid.h" // IWYU pragma: keep +#include "lv2/worker/worker.h" // IWYU pragma: keep + +#ifdef __GNUC__ +__attribute__((const)) +#endif +int +main(void) +{ + return 0; +} diff --git a/test/meson.build b/test/meson.build index bd736fe..630fb0d 100644 --- a/test/meson.build +++ b/test/meson.build @@ -71,7 +71,7 @@ if is_variable('cpp') test('cpp', executable( 'test_build_cpp', - files('test_build.cpp'), + files('cpp/test_build.cpp'), cpp_args: cpp_suppressions, dependencies: [lv2_dep], ), @@ -112,6 +112,12 @@ if get_option('strict') endif endif +################### +# Header Warnings # +################### + +subdir('headers') + ############## # Unit Tests # ############## diff --git a/test/test_build.cpp b/test/test_build.cpp deleted file mode 100644 index c8b2ca0..0000000 --- a/test/test_build.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2022 David Robillard -// SPDX-License-Identifier: ISC - -#if defined(__clang__) -_Pragma("clang diagnostic push") -_Pragma("clang diagnostic ignored \"-Wold-style-cast\"") -_Pragma("clang diagnostic ignored \"-Wzero-as-null-pointer-constant\"") -#elif defined(__GNUC__) -_Pragma("GCC diagnostic push") -_Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") -#endif - -#include "lv2/atom/atom.h" // IWYU pragma: keep -#include "lv2/atom/forge.h" // IWYU pragma: keep -#include "lv2/atom/util.h" // IWYU pragma: keep -#include "lv2/buf-size/buf-size.h" // IWYU pragma: keep -#include "lv2/core/attributes.h" // IWYU pragma: keep -#include "lv2/core/lv2.h" // IWYU pragma: keep -#include "lv2/core/lv2_util.h" // IWYU pragma: keep -#include "lv2/data-access/data-access.h" // IWYU pragma: keep -#include "lv2/dynmanifest/dynmanifest.h" // IWYU pragma: keep -#include "lv2/event/event-helpers.h" // IWYU pragma: keep -#include "lv2/event/event.h" // IWYU pragma: keep -#include "lv2/instance-access/instance-access.h" // IWYU pragma: keep -#include "lv2/log/log.h" // IWYU pragma: keep -#include "lv2/log/logger.h" // IWYU pragma: keep -#include "lv2/midi/midi.h" // IWYU pragma: keep -#include "lv2/morph/morph.h" // IWYU pragma: keep -#include "lv2/options/options.h" // IWYU pragma: keep -#include "lv2/parameters/parameters.h" // IWYU pragma: keep -#include "lv2/patch/patch.h" // IWYU pragma: keep -#include "lv2/port-groups/port-groups.h" // IWYU pragma: keep -#include "lv2/port-props/port-props.h" // IWYU pragma: keep -#include "lv2/presets/presets.h" // IWYU pragma: keep -#include "lv2/resize-port/resize-port.h" // IWYU pragma: keep -#include "lv2/state/state.h" // IWYU pragma: keep -#include "lv2/time/time.h" // IWYU pragma: keep -#include "lv2/ui/ui.h" // IWYU pragma: keep -#include "lv2/units/units.h" // IWYU pragma: keep -#include "lv2/uri-map/uri-map.h" // IWYU pragma: keep -#include "lv2/urid/urid.h" // IWYU pragma: keep -#include "lv2/worker/worker.h" // IWYU pragma: keep - -int -main() -{ - return 0; -} - -#if defined(__clang__) -_Pragma("clang diagnostic pop") -#elif defined(__GNUC__) -_Pragma("GCC diagnostic pop") -#endif -- cgit v1.2.1