Skip to content

Commit

Permalink
Silence -Weffc++ compiler warnings from gcc 11.4
Browse files Browse the repository at this point in the history
  • Loading branch information
George Rhoten authored and George Rhoten committed Jan 12, 2025
1 parent 914aeec commit 5c425a6
Show file tree
Hide file tree
Showing 56 changed files with 207 additions and 129 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ set(IMPL_SOURCES
${SOURCES_DIR}/internal/catch_leak_detector.cpp
${SOURCES_DIR}/internal/catch_list.cpp
${SOURCES_DIR}/internal/catch_message_info.cpp
${SOURCES_DIR}/internal/catch_noncopyable.cpp
${SOURCES_DIR}/internal/catch_output_redirect.cpp
${SOURCES_DIR}/internal/catch_parse_numbers.cpp
${SOURCES_DIR}/internal/catch_polyfills.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/catch2/catch_assertion_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ namespace Catch {

AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression );

std::string message;
mutable std::string reconstructedExpression;
std::string message {};
mutable std::string reconstructedExpression {};
LazyExpression lazyExpression;
ResultWas::OfType resultType;

Expand Down
16 changes: 8 additions & 8 deletions src/catch2/catch_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ namespace Catch {
ColourMode defaultColourMode = ColourMode::PlatformDefault;
WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;

std::string defaultOutputFilename;
std::string name;
std::string processName;
std::vector<ReporterSpec> reporterSpecifications;
std::string defaultOutputFilename {};
std::string name {};
std::string processName {};
std::vector<ReporterSpec> reporterSpecifications {};

std::vector<std::string> testsOrTags;
std::vector<std::string> sectionsToRun;
std::vector<std::string> testsOrTags {};
std::vector<std::string> sectionsToRun {};
};


Expand Down Expand Up @@ -144,8 +144,8 @@ namespace Catch {
void readBazelEnvVars();

ConfigData m_data;
std::vector<ProcessedReporterSpec> m_processedReporterSpecs;
TestSpec m_testSpec;
std::vector<ProcessedReporterSpec> m_processedReporterSpecs {};
TestSpec m_testSpec {};
bool m_hasTestFilters = false;
};
} // end namespace Catch
Expand Down
4 changes: 2 additions & 2 deletions src/catch2/catch_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace Catch {
return *this;
}

ReusableStringStream m_stream;
ReusableStringStream m_stream {};
};

struct MessageBuilder : MessageStream {
Expand Down Expand Up @@ -62,7 +62,7 @@ namespace Catch {
};

class Capturer {
std::vector<MessageInfo> m_messages;
std::vector<MessageInfo> m_messages {};
IResultCapture& m_resultCapture;
size_t m_captured = 0;
public:
Expand Down
12 changes: 6 additions & 6 deletions src/catch2/catch_registry_hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ namespace Catch {
}

private:
TestRegistry m_testCaseRegistry;
ReporterRegistry m_reporterRegistry;
ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
TagAliasRegistry m_tagAliasRegistry;
StartupExceptionRegistry m_exceptionRegistry;
Detail::EnumValuesRegistry m_enumValuesRegistry;
TestRegistry m_testCaseRegistry {};
ReporterRegistry m_reporterRegistry {};
ExceptionTranslatorRegistry m_exceptionTranslatorRegistry {};
TagAliasRegistry m_tagAliasRegistry {};
StartupExceptionRegistry m_exceptionRegistry {};
Detail::EnumValuesRegistry m_enumValuesRegistry {};
};
}

Expand Down
6 changes: 4 additions & 2 deletions src/catch2/catch_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ namespace Catch {

m_tests = createShard(m_tests, m_config->shardCount(), m_config->shardIndex());
}
TestGroup( TestGroup const& ) = delete;
TestGroup& operator=( TestGroup const& ) = delete;

Totals execute() {
Totals totals;
Expand Down Expand Up @@ -138,8 +140,8 @@ namespace Catch {
IEventListener* m_reporter;
Config const* m_config;
RunContext m_context;
std::set<TestCaseHandle const*> m_tests;
TestSpec::Matches m_matches;
std::set<TestCaseHandle const*> m_tests {};
TestSpec::Matches m_matches {};
bool m_unmatchedTestSpecs = false;
};

Expand Down
8 changes: 4 additions & 4 deletions src/catch2/catch_session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Catch {
public:

Session();
~Session();
~Session() override;

void showHelp() const;
void libIdentify();
Expand Down Expand Up @@ -51,9 +51,9 @@ namespace Catch {
private:
int runInternal();

Clara::Parser m_cli;
ConfigData m_configData;
Detail::unique_ptr<Config> m_config;
Clara::Parser m_cli {};
ConfigData m_configData {};
Detail::unique_ptr<Config> m_config {};
bool m_startupExceptions = false;
};

Expand Down
4 changes: 2 additions & 2 deletions src/catch2/catch_test_case_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ namespace Catch {
std::string name;
StringRef className;
private:
std::string backingTags;
std::string backingTags {};
// Internally we copy tags to the backing storage and then add
// refs to this storage to the tags vector.
void internalAppendTag(StringRef tagString);
public:
std::vector<Tag> tags;
std::vector<Tag> tags {};
SourceLineInfo lineInfo;
TestCaseProperties properties = TestCaseProperties::None;
};
Expand Down
8 changes: 4 additions & 4 deletions src/catch2/catch_test_spec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ namespace Catch {
};

struct Filter {
std::vector<Detail::unique_ptr<Pattern>> m_required;
std::vector<Detail::unique_ptr<Pattern>> m_forbidden;
std::vector<Detail::unique_ptr<Pattern>> m_required {};
std::vector<Detail::unique_ptr<Pattern>> m_forbidden {};

//! Serializes this filter into a string that would be parsed into
//! an equivalent filter
Expand Down Expand Up @@ -97,8 +97,8 @@ namespace Catch {
const vectorStrings & getInvalidSpecs() const;

private:
std::vector<Filter> m_filters;
std::vector<std::string> m_invalidSpecs;
std::vector<Filter> m_filters {};
std::vector<std::string> m_invalidSpecs {};

friend class TestSpecParser;
//! Serializes this test spec into a string that would be parsed into
Expand Down
4 changes: 2 additions & 2 deletions src/catch2/catch_totals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ namespace Catch {

Totals delta( Totals const& prevTotals ) const;

Counts assertions;
Counts testCases;
Counts assertions {};
Counts testCases {};
};
}

Expand Down
4 changes: 4 additions & 0 deletions src/catch2/generators/catch_generator_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

namespace Catch {

GeneratorException::GeneratorException( GeneratorException const& other):
m_msg(other.m_msg)
{}

const char* GeneratorException::what() const noexcept {
return m_msg;
}
Expand Down
2 changes: 2 additions & 0 deletions src/catch2/generators/catch_generator_exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ namespace Catch {
GeneratorException(const char* msg):
m_msg(msg)
{}
GeneratorException( GeneratorException const& other );
GeneratorException& operator=( GeneratorException const& ) = delete;

const char* what() const noexcept override final;
};
Expand Down
2 changes: 1 addition & 1 deletion src/catch2/generators/catch_generators_random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class RandomFloatingGenerator<long double> final : public IGenerator<long double
// want to drag it into the header.
struct PImpl;
Catch::Detail::unique_ptr<PImpl> m_pimpl;
long double m_current_number;
long double m_current_number {};

public:
RandomFloatingGenerator( long double a, long double b, std::uint32_t seed );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace Catch {

namespace Detail {
struct EnumInfo {
StringRef m_name;
std::vector<std::pair<int, StringRef>> m_values;
StringRef m_name {};
std::vector<std::pair<int, StringRef>> m_values {};

~EnumInfo();

Expand All @@ -27,7 +27,7 @@ namespace Catch {

class IMutableEnumValuesRegistry {
public:
virtual ~IMutableEnumValuesRegistry(); // = default;
virtual ~IMutableEnumValuesRegistry();

virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values ) = 0;

Expand Down
6 changes: 3 additions & 3 deletions src/catch2/interfaces/catch_interfaces_generatortracker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Catch {
class GeneratorUntypedBase {
// Caches result from `toStringImpl`, assume that when it is an
// empty string, the cache is invalidated.
mutable std::string m_stringReprCache;
mutable std::string m_stringReprCache {};

// Counts based on `next` returning true
std::size_t m_currentElementIndex = 0;
Expand All @@ -42,7 +42,7 @@ namespace Catch {
GeneratorUntypedBase(GeneratorUntypedBase const&) = default;
GeneratorUntypedBase& operator=(GeneratorUntypedBase const&) = default;

virtual ~GeneratorUntypedBase(); // = default;
virtual ~GeneratorUntypedBase();

/**
* Attempts to move the generator to the next element
Expand Down Expand Up @@ -79,7 +79,7 @@ namespace Catch {

class IGeneratorTracker {
public:
virtual ~IGeneratorTracker(); // = default;
virtual ~IGeneratorTracker();
virtual auto hasGenerator() const -> bool = 0;
virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0;
virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0;
Expand Down
12 changes: 11 additions & 1 deletion src/catch2/interfaces/catch_interfaces_reporter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ namespace Catch {
std::map<std::string, std::string> customOptions );

ReporterConfig( ReporterConfig&& ) = default;
ReporterConfig( ReporterConfig const& ) = delete;
ReporterConfig& operator=( ReporterConfig&& ) = default;
ReporterConfig& operator=( ReporterConfig const& ) = delete;
~ReporterConfig(); // = default

Detail::unique_ptr<IStream> takeStream() &&;
Expand Down Expand Up @@ -75,6 +77,8 @@ namespace Catch {
Counts const& _assertions,
double _durationInSeconds,
bool _missingAssertions );
SectionStats( SectionStats const& ) = default;
SectionStats& operator=( SectionStats const& ) = default;

SectionInfo sectionInfo;
Counts assertions;
Expand All @@ -88,6 +92,8 @@ namespace Catch {
std::string&& _stdOut,
std::string&& _stdErr,
bool _aborting );
TestCaseStats( TestCaseStats const& ) = default;
TestCaseStats& operator=( TestCaseStats const& ) = default;

TestCaseInfo const * testInfo;
Totals totals;
Expand All @@ -100,6 +106,8 @@ namespace Catch {
TestRunStats( TestRunInfo const& _runInfo,
Totals const& _totals,
bool _aborting );
TestRunStats( TestRunStats const& ) = default;
TestRunStats& operator=( TestRunStats const& ) = default;

TestRunInfo runInfo;
Totals totals;
Expand Down Expand Up @@ -133,12 +141,14 @@ namespace Catch {
class IEventListener {
protected:
//! Derived classes can set up their preferences here
ReporterPreferences m_preferences;
ReporterPreferences m_preferences {};
//! The test run's config as filled in from CLI and defaults
IConfig const* m_config;

public:
IEventListener( IConfig const* config ): m_config( config ) {}
IEventListener( IEventListener const& ) = delete;
IEventListener& operator=( IEventListener const& ) = delete;

virtual ~IEventListener(); // = default;

Expand Down
2 changes: 1 addition & 1 deletion src/catch2/internal/catch_assertion_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Catch {

class AssertionHandler {
AssertionInfo m_assertionInfo;
AssertionReaction m_reaction;
AssertionReaction m_reaction {};
bool m_completed = false;
IResultCapture& m_resultCapture;

Expand Down
18 changes: 9 additions & 9 deletions src/catch2/internal/catch_clara.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace Catch {
using Iterator = std::vector<StringRef>::const_iterator;
Iterator it;
Iterator itEnd;
std::vector<Token> m_tokenBuffer;
std::vector<Token> m_tokenBuffer {};
void loadBuffer();

public:
Expand Down Expand Up @@ -275,7 +275,7 @@ namespace Catch {
}

std::string
m_errorMessage; // Only populated if resultType is an error
m_errorMessage {}; // Only populated if resultType is an error

BasicResult( ResultType type,
std::string&& message ):
Expand Down Expand Up @@ -491,8 +491,8 @@ namespace Catch {
protected:
Optionality m_optionality = Optionality::Optional;
std::shared_ptr<BoundRef> m_ref;
StringRef m_hint;
StringRef m_description;
StringRef m_hint {};
StringRef m_description {};

explicit ParserRefImpl( std::shared_ptr<BoundRef> const& ref ):
m_ref( ref ) {}
Expand Down Expand Up @@ -569,7 +569,7 @@ namespace Catch {
// A parser for options
class Opt : public Detail::ParserRefImpl<Opt> {
protected:
std::vector<StringRef> m_optNames;
std::vector<StringRef> m_optNames {};

public:
template <typename LambdaT>
Expand Down Expand Up @@ -620,7 +620,7 @@ namespace Catch {
// Specifies the name of the executable
class ExeName : public Detail::ComposableParserImpl<ExeName> {
std::shared_ptr<std::string> m_name;
std::shared_ptr<Detail::BoundValueRefBase> m_ref;
std::shared_ptr<Detail::BoundValueRefBase> m_ref {};

public:
ExeName();
Expand All @@ -644,9 +644,9 @@ namespace Catch {

// A Combined parser
class Parser : Detail::ParserBase {
mutable ExeName m_exeName;
std::vector<Opt> m_options;
std::vector<Arg> m_args;
mutable ExeName m_exeName {};
std::vector<Opt> m_options {};
std::vector<Arg> m_args {};

public:

Expand Down
2 changes: 2 additions & 0 deletions src/catch2/internal/catch_console_colour.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ namespace Catch {
IStream* m_stream;
public:
ColourImpl( IStream* stream ): m_stream( stream ) {}
ColourImpl( ColourImpl const& ) = delete;
ColourImpl& operator=( ColourImpl const& ) = delete;

//! RAII wrapper around writing specific colour of text using specific
//! colour impl into a stream.
Expand Down
1 change: 1 addition & 0 deletions src/catch2/internal/catch_decomposer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wsign-compare"
# pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
# pragma GCC diagnostic ignored "-Weffc++"
#endif

#if defined(CATCH_CPP20_OR_GREATER) && __has_include(<compare>)
Expand Down
Loading

0 comments on commit 5c425a6

Please sign in to comment.