From 551946c45bb27b78c85971d32e2a8bccbfa0d3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Wed, 24 Feb 2021 23:13:56 +0100 Subject: [PATCH] Split out INTERNAL_CATCH_UNIQUE_NAME into its own header Also small cleanup of includes of related headers. --- src/CMakeLists.txt | 1 + src/catch2/benchmark/catch_benchmark.hpp | 1 + src/catch2/catch_all.hpp | 1 + src/catch2/catch_tag_alias_autoregistrar.hpp | 1 + src/catch2/catch_test_macros.hpp | 2 ++ src/catch2/catch_translate_exception.hpp | 2 ++ .../interfaces/catch_interfaces_exception.hpp | 1 - src/catch2/internal/catch_section.hpp | 3 +-- .../internal/catch_source_line_info.hpp | 10 ---------- .../internal/catch_template_test_registry.hpp | 2 ++ src/catch2/internal/catch_test_macro_impl.hpp | 1 + src/catch2/internal/catch_test_registry.hpp | 1 + src/catch2/internal/catch_unique_name.hpp | 20 +++++++++++++++++++ 13 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 src/catch2/internal/catch_unique_name.hpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f2223639..2f3dd4ab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,6 +65,7 @@ set(INTERNAL_HEADERS ${SOURCES_DIR}/internal/catch_errno_guard.hpp ${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp ${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp + ${SOURCES_DIR}/internal/catch_unique_name.hpp ${SOURCES_DIR}/generators/catch_generator_exception.hpp ${SOURCES_DIR}/generators/catch_generators.hpp ${SOURCES_DIR}/generators/catch_generators_adapters.hpp diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp index 8ff69b4a..c99160fb 100644 --- a/src/catch2/benchmark/catch_benchmark.hpp +++ b/src/catch2/benchmark/catch_benchmark.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 3bd6d9c8..c6ab59ec 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -100,6 +100,7 @@ #include #include #include +#include #include #include #include diff --git a/src/catch2/catch_tag_alias_autoregistrar.hpp b/src/catch2/catch_tag_alias_autoregistrar.hpp index 6b5c2f1c..c742bcd3 100644 --- a/src/catch2/catch_tag_alias_autoregistrar.hpp +++ b/src/catch2/catch_tag_alias_autoregistrar.hpp @@ -9,6 +9,7 @@ #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED #include +#include #include namespace Catch { diff --git a/src/catch2/catch_test_macros.hpp b/src/catch2/catch_test_macros.hpp index dcbe53db..ae509150 100644 --- a/src/catch2/catch_test_macros.hpp +++ b/src/catch2/catch_test_macros.hpp @@ -13,6 +13,8 @@ #include #include #include +#include + // All of our user-facing macros support configuration toggle, that // forces them to be defined prefixed with CATCH_. We also like to diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp index 412a1062..1bb8bb92 100644 --- a/src/catch2/catch_translate_exception.hpp +++ b/src/catch2/catch_translate_exception.hpp @@ -9,6 +9,8 @@ #define CATCH_TRANSLATE_EXCEPTION_HPP_INCLUDED #include +#include +#include #include diff --git a/src/catch2/interfaces/catch_interfaces_exception.hpp b/src/catch2/interfaces/catch_interfaces_exception.hpp index 84bb4974..5d660873 100644 --- a/src/catch2/interfaces/catch_interfaces_exception.hpp +++ b/src/catch2/interfaces/catch_interfaces_exception.hpp @@ -9,7 +9,6 @@ #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED #include -#include #include #include diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp index 36d900bb..2e72923c 100644 --- a/src/catch2/internal/catch_section.hpp +++ b/src/catch2/internal/catch_section.hpp @@ -13,8 +13,7 @@ #include #include #include - -#include +#include namespace Catch { diff --git a/src/catch2/internal/catch_source_line_info.hpp b/src/catch2/internal/catch_source_line_info.hpp index 8aca4867..bd828fad 100644 --- a/src/catch2/internal/catch_source_line_info.hpp +++ b/src/catch2/internal/catch_source_line_info.hpp @@ -8,19 +8,9 @@ #ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED #define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED -#include - #include #include -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - // We need a dummy global operator<< so we can bring it into Catch namespace later struct Catch_global_namespace_dummy {}; std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); diff --git a/src/catch2/internal/catch_template_test_registry.hpp b/src/catch2/internal/catch_template_test_registry.hpp index 3617109b..83c47d7d 100644 --- a/src/catch2/internal/catch_template_test_registry.hpp +++ b/src/catch2/internal/catch_template_test_registry.hpp @@ -12,6 +12,8 @@ #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 diff --git a/src/catch2/internal/catch_test_macro_impl.hpp b/src/catch2/internal/catch_test_macro_impl.hpp index 9ceb03ab..357e114d 100644 --- a/src/catch2/internal/catch_test_macro_impl.hpp +++ b/src/catch2/internal/catch_test_macro_impl.hpp @@ -11,6 +11,7 @@ #include #include #include +#include // We need this suppression to leak, because it took until GCC 9 // for the front end to handle local suppression via _Pragma properly diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index 0f5ec488..9e8b5b6e 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -13,6 +13,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 diff --git a/src/catch2/internal/catch_unique_name.hpp b/src/catch2/internal/catch_unique_name.hpp new file mode 100644 index 00000000..31ab9126 --- /dev/null +++ b/src/catch2/internal/catch_unique_name.hpp @@ -0,0 +1,20 @@ + +// 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_UNIQUE_NAME_HPP_INCLUDED +#define CATCH_UNIQUE_NAME_HPP_INCLUDED + +#include +#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line +#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) +#ifdef CATCH_CONFIG_COUNTER +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) +#else +# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) +#endif + +#endif // CATCH_UNIQUE_NAME_HPP_INCLUDED