From c742ea9ad97a34c8f652dd7f67012d5b3f818c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 14 Apr 2022 17:16:01 +0200 Subject: [PATCH 1/3] Some IWYU include cleanups --- src/catch2/benchmark/detail/catch_stats.cpp | 1 + src/catch2/catch_approx.cpp | 1 + src/catch2/catch_config.cpp | 2 -- src/catch2/catch_config.hpp | 7 ++++--- src/catch2/catch_test_case_info.cpp | 2 -- src/catch2/catch_totals.hpp | 1 - src/catch2/internal/catch_assertion_handler.hpp | 4 ++-- src/catch2/internal/catch_case_insensitive_comparisons.hpp | 2 -- src/catch2/internal/catch_clara.cpp | 5 ++++- src/catch2/internal/catch_clara.hpp | 1 - src/catch2/internal/catch_commandline.cpp | 2 -- src/catch2/internal/catch_console_colour.cpp | 3 +++ src/catch2/internal/catch_console_colour.hpp | 1 - src/catch2/internal/catch_debug_console.cpp | 2 ++ src/catch2/internal/catch_reporter_spec_parser.cpp | 1 - src/catch2/internal/catch_tag_alias_registry.hpp | 1 + src/catch2/internal/catch_xmlwriter.hpp | 1 + src/catch2/reporters/catch_reporter_automake.hpp | 2 ++ src/catch2/reporters/catch_reporter_cumulative_base.cpp | 2 ++ src/catch2/reporters/catch_reporter_cumulative_base.hpp | 1 - src/catch2/reporters/catch_reporter_multi.cpp | 2 -- src/catch2/reporters/catch_reporter_streaming_base.hpp | 2 -- src/catch2/reporters/catch_reporter_tap.cpp | 1 + src/catch2/reporters/catch_reporter_teamcity.cpp | 1 + tests/ExtraTests/X05-DeferredStaticChecks.cpp | 1 - 25 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index 0f94d5b7..10511d4c 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include diff --git a/src/catch2/catch_approx.cpp b/src/catch2/catch_approx.cpp index 50cb75c3..21652111 100644 --- a/src/catch2/catch_approx.cpp +++ b/src/catch2/catch_approx.cpp @@ -7,6 +7,7 @@ // SPDX-License-Identifier: BSL-1.0 #include #include +#include #include #include diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 79ec33f8..7363ee70 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -14,8 +14,6 @@ #include #include -#include - namespace Catch { bool operator==( ProcessedReporterSpec const& lhs, diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp index 2b57bbb5..8823accd 100644 --- a/src/catch2/catch_config.hpp +++ b/src/catch2/catch_config.hpp @@ -9,16 +9,17 @@ #define CATCH_CONFIG_HPP_INCLUDED #include -#include #include #include #include +#include #include #include -#include -#include +#include +#include #include +#include namespace Catch { diff --git a/src/catch2/catch_test_case_info.cpp b/src/catch2/catch_test_case_info.cpp index 83cfcc8e..6d89dc72 100644 --- a/src/catch2/catch_test_case_info.cpp +++ b/src/catch2/catch_test_case_info.cpp @@ -7,8 +7,6 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include -#include #include #include diff --git a/src/catch2/catch_totals.hpp b/src/catch2/catch_totals.hpp index 7ab6a1b6..6bc444fc 100644 --- a/src/catch2/catch_totals.hpp +++ b/src/catch2/catch_totals.hpp @@ -8,7 +8,6 @@ #ifndef CATCH_TOTALS_HPP_INCLUDED #define CATCH_TOTALS_HPP_INCLUDED -#include #include namespace Catch { diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp index 4d397766..5faa5e4b 100644 --- a/src/catch2/internal/catch_assertion_handler.hpp +++ b/src/catch2/internal/catch_assertion_handler.hpp @@ -13,11 +13,11 @@ #include #include +#include + namespace Catch { - struct AssertionResultData; class IResultCapture; - class RunContext; struct AssertionReaction { bool shouldDebugBreak = false; diff --git a/src/catch2/internal/catch_case_insensitive_comparisons.hpp b/src/catch2/internal/catch_case_insensitive_comparisons.hpp index 5742e6b7..c182e13e 100644 --- a/src/catch2/internal/catch_case_insensitive_comparisons.hpp +++ b/src/catch2/internal/catch_case_insensitive_comparisons.hpp @@ -10,8 +10,6 @@ #include -#include - namespace Catch { namespace Detail { //! Provides case-insensitive `op<` semantics when called diff --git a/src/catch2/internal/catch_clara.cpp b/src/catch2/internal/catch_clara.cpp index df844838..a4701a81 100644 --- a/src/catch2/internal/catch_clara.cpp +++ b/src/catch2/internal/catch_clara.cpp @@ -5,13 +5,16 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -#include + #include #include #include #include #include +#include +#include + namespace { bool isOptPrefix( char c ) { return c == '-' diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 00761c0a..0d3fb233 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -34,7 +34,6 @@ #include #include -#include #include #include #include diff --git a/src/catch2/internal/catch_commandline.cpp b/src/catch2/internal/catch_commandline.cpp index d16e7e37..59b06de9 100644 --- a/src/catch2/internal/catch_commandline.cpp +++ b/src/catch2/internal/catch_commandline.cpp @@ -12,11 +12,9 @@ #include #include #include -#include #include #include -#include #include #include diff --git a/src/catch2/internal/catch_console_colour.cpp b/src/catch2/internal/catch_console_colour.cpp index e9fa55f7..7f202490 100644 --- a/src/catch2/internal/catch_console_colour.cpp +++ b/src/catch2/internal/catch_console_colour.cpp @@ -16,13 +16,16 @@ #include #include #include +#include #include #include #include #include #include +#include #include +#include namespace Catch { diff --git a/src/catch2/internal/catch_console_colour.hpp b/src/catch2/internal/catch_console_colour.hpp index 661078af..aa3d83a2 100644 --- a/src/catch2/internal/catch_console_colour.hpp +++ b/src/catch2/internal/catch_console_colour.hpp @@ -16,7 +16,6 @@ namespace Catch { enum class ColourMode : std::uint8_t; - class IConfig; class IStream; struct Colour { diff --git a/src/catch2/internal/catch_debug_console.cpp b/src/catch2/internal/catch_debug_console.cpp index 5942524e..d13cc0bb 100644 --- a/src/catch2/internal/catch_debug_console.cpp +++ b/src/catch2/internal/catch_debug_console.cpp @@ -11,6 +11,8 @@ #include #include +#include + #if defined(CATCH_CONFIG_ANDROID_LOGWRITE) #include diff --git a/src/catch2/internal/catch_reporter_spec_parser.cpp b/src/catch2/internal/catch_reporter_spec_parser.cpp index 378a6f5a..28b2088a 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.cpp +++ b/src/catch2/internal/catch_reporter_spec_parser.cpp @@ -12,7 +12,6 @@ #include #include -#include namespace Catch { diff --git a/src/catch2/internal/catch_tag_alias_registry.hpp b/src/catch2/internal/catch_tag_alias_registry.hpp index 9dd86c13..3dbe0528 100644 --- a/src/catch2/internal/catch_tag_alias_registry.hpp +++ b/src/catch2/internal/catch_tag_alias_registry.hpp @@ -15,6 +15,7 @@ #include namespace Catch { + struct SourceLineInfo; class TagAliasRegistry : public ITagAliasRegistry { public: diff --git a/src/catch2/internal/catch_xmlwriter.hpp b/src/catch2/internal/catch_xmlwriter.hpp index 5be8277d..edeb64a2 100644 --- a/src/catch2/internal/catch_xmlwriter.hpp +++ b/src/catch2/internal/catch_xmlwriter.hpp @@ -11,6 +11,7 @@ #include #include +#include #include namespace Catch { diff --git a/src/catch2/reporters/catch_reporter_automake.hpp b/src/catch2/reporters/catch_reporter_automake.hpp index c544f337..cd85e6bf 100644 --- a/src/catch2/reporters/catch_reporter_automake.hpp +++ b/src/catch2/reporters/catch_reporter_automake.hpp @@ -10,6 +10,8 @@ #include +#include + namespace Catch { class AutomakeReporter final : public StreamingReporterBase { diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.cpp b/src/catch2/reporters/catch_reporter_cumulative_base.cpp index b52ba7ef..957880d0 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.cpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.cpp @@ -7,6 +7,8 @@ // SPDX-License-Identifier: BSL-1.0 #include +#include + #include #include diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp index d43ca479..742eaac9 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/src/catch2/reporters/catch_reporter_multi.cpp b/src/catch2/reporters/catch_reporter_multi.cpp index 86d39d6a..e8cf7bdf 100644 --- a/src/catch2/reporters/catch_reporter_multi.cpp +++ b/src/catch2/reporters/catch_reporter_multi.cpp @@ -11,8 +11,6 @@ #include #include -#include - namespace Catch { void MultiReporter::updatePreferences(IEventListener const& reporterish) { m_preferences.shouldRedirectStdOut |= diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp index afa67d76..5088bd0b 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -10,8 +10,6 @@ #include -#include -#include #include namespace Catch { diff --git a/src/catch2/reporters/catch_reporter_tap.cpp b/src/catch2/reporters/catch_reporter_tap.cpp index 4cc91b7b..71249f87 100644 --- a/src/catch2/reporters/catch_reporter_tap.cpp +++ b/src/catch2/reporters/catch_reporter_tap.cpp @@ -11,6 +11,7 @@ #include #include +#include #include namespace Catch { diff --git a/src/catch2/reporters/catch_reporter_teamcity.cpp b/src/catch2/reporters/catch_reporter_teamcity.cpp index 8f16757a..142dffbb 100644 --- a/src/catch2/reporters/catch_reporter_teamcity.cpp +++ b/src/catch2/reporters/catch_reporter_teamcity.cpp @@ -14,6 +14,7 @@ #include #include +#include namespace Catch { diff --git a/tests/ExtraTests/X05-DeferredStaticChecks.cpp b/tests/ExtraTests/X05-DeferredStaticChecks.cpp index a09ed1cc..62ceb4a7 100644 --- a/tests/ExtraTests/X05-DeferredStaticChecks.cpp +++ b/tests/ExtraTests/X05-DeferredStaticChecks.cpp @@ -12,7 +12,6 @@ */ #include -#include TEST_CASE("Deferred static checks") { STATIC_CHECK(1 == 2); From 574d042821ca70bb5188d7e6d0c841fcfc197fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 15 Apr 2022 16:40:06 +0200 Subject: [PATCH 2/3] Push catch_preprocessor include down from test_macros header --- src/catch2/catch_test_macros.hpp | 1 - src/catch2/generators/catch_generators.hpp | 2 ++ src/catch2/internal/catch_test_registry.hpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/catch2/catch_test_macros.hpp b/src/catch2/catch_test_macros.hpp index dde1c9cd..e92a45f0 100644 --- a/src/catch2/catch_test_macros.hpp +++ b/src/catch2/catch_test_macros.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/src/catch2/generators/catch_generators.hpp b/src/catch2/generators/catch_generators.hpp index 948d6f0f..acfdb7dc 100644 --- a/src/catch2/generators/catch_generators.hpp +++ b/src/catch2/generators/catch_generators.hpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index 9a03e6db..a9a78fd8 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -14,6 +14,7 @@ #include #include #include +#include // GCC 5 and older do not properly handle disabling unused-variable warning // with a _Pragma. This means that we have to leak the suppression to the From b5202576766c63a29275a8386a8e3c0439089382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 15 Apr 2022 17:14:25 +0200 Subject: [PATCH 3/3] Split REMOVE_PARENS from catch_preprocessor.hpp This way, some headers can include just the new header, which transitively decreases the total include size of test_macros.hpp. --- src/CMakeLists.txt | 1 + src/catch2/catch_all.hpp | 1 + src/catch2/internal/catch_preprocessor.hpp | 7 +------ .../catch_preprocessor_remove_parens.hpp | 19 +++++++++++++++++++ src/catch2/internal/catch_test_registry.hpp | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 src/catch2/internal/catch_preprocessor_remove_parens.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b52122fc..5c724a46 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -116,6 +116,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/internal/catch_platform.hpp ${SOURCES_DIR}/internal/catch_polyfills.hpp ${SOURCES_DIR}/internal/catch_preprocessor.hpp + ${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp ${SOURCES_DIR}/internal/catch_random_number_generator.hpp ${SOURCES_DIR}/internal/catch_random_seed_generation.hpp ${SOURCES_DIR}/reporters/catch_reporter_registrars.hpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index b082b766..5367ef3e 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -79,6 +79,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/internal/catch_preprocessor.hpp b/src/catch2/internal/catch_preprocessor.hpp index 00859b15..4292d0df 100644 --- a/src/catch2/internal/catch_preprocessor.hpp +++ b/src/catch2/internal/catch_preprocessor.hpp @@ -8,6 +8,7 @@ #ifndef CATCH_PREPROCESSOR_HPP_INCLUDED #define CATCH_PREPROCESSOR_HPP_INCLUDED +#include #if defined(__GNUC__) // We need to silence "empty __VA_ARGS__ warning", and using just _Pragma does not work @@ -59,10 +60,6 @@ #define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF #define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR #define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ @@ -77,8 +74,6 @@ #define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ #define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - #ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR #define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) #define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) diff --git a/src/catch2/internal/catch_preprocessor_remove_parens.hpp b/src/catch2/internal/catch_preprocessor_remove_parens.hpp new file mode 100644 index 00000000..80337890 --- /dev/null +++ b/src/catch2/internal/catch_preprocessor_remove_parens.hpp @@ -0,0 +1,19 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#ifndef CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED +#define CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED + +#define INTERNAL_CATCH_EXPAND1( param ) INTERNAL_CATCH_EXPAND2( param ) +#define INTERNAL_CATCH_EXPAND2( ... ) INTERNAL_CATCH_NO##__VA_ARGS__ +#define INTERNAL_CATCH_DEF( ... ) INTERNAL_CATCH_DEF __VA_ARGS__ +#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF + +#define INTERNAL_CATCH_REMOVE_PARENS( ... ) \ + INTERNAL_CATCH_EXPAND1( INTERNAL_CATCH_DEF __VA_ARGS__ ) + +#endif // CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index a9a78fd8..4d00699f 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include // GCC 5 and older do not properly handle disabling unused-variable warning // with a _Pragma. This means that we have to leak the suppression to the