Skip to content

Commit fbef829

Browse files
committed
Constify various autoregistry globals to avoid clang-tidy complaints
1 parent d79a4f6 commit fbef829

File tree

5 files changed

+25
-23
lines changed

5 files changed

+25
-23
lines changed

src/catch2/catch_tag_alias_autoregistrar.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Catch {
2323
#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \
2424
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
2525
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
26-
namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \
26+
namespace{ const Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \
2727
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
2828

2929
#endif // CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED

src/catch2/internal/catch_fatal_condition_handler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace Catch {
7979
// There is no 1-1 mapping between signals and windows exceptions.
8080
// Windows can easily distinguish between SO and SigSegV,
8181
// but SigInt, SigTerm, etc are handled differently.
82-
static SignalDefs signalDefs[] = {
82+
static constexpr SignalDefs signalDefs[] = {
8383
{ EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" },
8484
{ EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" },
8585
{ EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" },
@@ -150,7 +150,7 @@ namespace Catch {
150150
const char* name;
151151
};
152152

153-
static SignalDefs signalDefs[] = {
153+
static constexpr SignalDefs signalDefs[] = {
154154
{ SIGINT, "SIGINT - Terminal interrupt signal" },
155155
{ SIGILL, "SIGILL - Illegal instruction signal" },
156156
{ SIGFPE, "SIGFPE - Floating point error signal" },

src/catch2/internal/catch_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Catch {
1515
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
1616
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
17-
static LeakDetector leakDetector;
17+
static const LeakDetector leakDetector;
1818
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
1919
}
2020

src/catch2/internal/catch_template_test_registry.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + '<' + types_list[index % num_types] + '>', Tags } ), index++)... };/* NOLINT */\
139139
} \
140140
}; \
141-
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
141+
static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
142142
using TestInit = typename create<TestName, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type; \
143143
TestInit t; \
144144
t.reg_tests(); \
@@ -184,7 +184,7 @@
184184
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\
185185
} \
186186
};\
187-
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
187+
static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
188188
using TestInit = typename convert<TestName, TmplList>::type; \
189189
TestInit t; \
190190
t.reg_tests(); \
@@ -220,7 +220,7 @@
220220
(void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++)... };/* NOLINT */ \
221221
}\
222222
};\
223-
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
223+
static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
224224
TestNameClass<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(__VA_ARGS__)>();\
225225
return 0;\
226226
}();\
@@ -270,7 +270,7 @@
270270
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + '<' + types_list[index % num_types] + '>', Tags } ), index++)... };/* NOLINT */ \
271271
}\
272272
};\
273-
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
273+
static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
274274
using TestInit = typename create<TestNameClass, decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS(TmplTypes)>(Catch::Detail::priority_tag<1>{})), TypeList<INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(INTERNAL_CATCH_REMOVE_PARENS(TypesList))>>::type;\
275275
TestInit t;\
276276
t.reg_tests();\
@@ -319,7 +319,7 @@
319319
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName##_catch_sr, Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */ \
320320
}\
321321
};\
322-
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
322+
static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
323323
using TestInit = typename convert<TestNameClass, TmplList>::type;\
324324
TestInit t;\
325325
t.reg_tests();\

src/catch2/reporters/catch_reporter_registrars.hpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,24 @@ namespace Catch {
103103

104104
#if !defined(CATCH_CONFIG_DISABLE)
105105

106-
# define CATCH_REGISTER_REPORTER( name, reporterType ) \
107-
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
108-
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
109-
namespace { \
110-
Catch::ReporterRegistrar<reporterType> INTERNAL_CATCH_UNIQUE_NAME( \
111-
catch_internal_RegistrarFor )( name ); \
112-
} \
106+
# define CATCH_REGISTER_REPORTER( name, reporterType ) \
107+
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
108+
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
109+
namespace { \
110+
const Catch::ReporterRegistrar<reporterType> \
111+
INTERNAL_CATCH_UNIQUE_NAME( catch_internal_RegistrarFor )( \
112+
name ); \
113+
} \
113114
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
114115

115-
# define CATCH_REGISTER_LISTENER( listenerType ) \
116-
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
117-
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
118-
namespace { \
119-
Catch::ListenerRegistrar<listenerType> INTERNAL_CATCH_UNIQUE_NAME( \
120-
catch_internal_RegistrarFor )( #listenerType##_catch_sr ); \
121-
} \
116+
# define CATCH_REGISTER_LISTENER( listenerType ) \
117+
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
118+
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
119+
namespace { \
120+
const Catch::ListenerRegistrar<listenerType> \
121+
INTERNAL_CATCH_UNIQUE_NAME( catch_internal_RegistrarFor )( \
122+
#listenerType##_catch_sr ); \
123+
} \
122124
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
123125

124126
#else // CATCH_CONFIG_DISABLE

0 commit comments

Comments
 (0)