Anchor some Clara vtables into the cpp file

Anchoring the vtables does 2 things
1) Fixes some instances of `-Wweak-vtables`
2) Decreases code size and linker pressure

However, there are still some unanchored ones, and thus we have
to keep suppressing `-Wweak-vtables` warning for Clang.
This commit is contained in:
Martin Hořeňovský 2020-08-20 23:16:06 +02:00
parent 7500ad1ffd
commit 24559493bf
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
2 changed files with 23 additions and 8 deletions

View File

@ -111,6 +111,8 @@ namespace Catch {
return ParserResult::ok( ParseResultType::Matched );
}
size_t ParserBase::cardinality() const { return 1; }
InternalParseResult ParserBase::parse( Args const& args ) const {
return parse( args.exeName(), TokenStream( args ) );
}
@ -124,7 +126,15 @@ namespace Catch {
return ParserResult::ok( ParseResultType::Matched );
}
} // namespace Detail
ResultBase::~ResultBase() = default;
bool BoundRef::isContainer() const { return false; }
bool BoundRef::isFlag() const { return false; }
bool BoundFlagRefBase::isFlag() const { return true; }
} // namespace Detail
Detail::InternalParseResult Arg::parse(std::string const&,
Detail::TokenStream const& tokens) const {

View File

@ -132,7 +132,13 @@ namespace Catch {
class ResultBase {
protected:
ResultBase( ResultType type ): m_type( type ) {}
virtual ~ResultBase() = default;
virtual ~ResultBase(); // = default;
ResultBase(ResultBase const&) = default;
ResultBase& operator=(ResultBase const&) = default;
ResultBase(ResultBase&&) = default;
ResultBase& operator=(ResultBase&&) = default;
virtual void enforceOk() const = 0;
@ -295,8 +301,8 @@ namespace Catch {
struct BoundRef : Catch::Detail::NonCopyable {
virtual ~BoundRef() = default;
virtual auto isContainer() const -> bool { return false; }
virtual auto isFlag() const -> bool { return false; }
virtual bool isContainer() const;
virtual bool isFlag() const;
};
struct BoundValueRefBase : BoundRef {
virtual auto setValue( std::string const& arg )
@ -304,7 +310,7 @@ namespace Catch {
};
struct BoundFlagRefBase : BoundRef {
virtual auto setFlag( bool flag ) -> ParserResult = 0;
bool isFlag() const override { return true; }
bool isFlag() const override;
};
template <typename T> struct BoundValueRef : BoundValueRefBase {
@ -312,8 +318,7 @@ namespace Catch {
explicit BoundValueRef( T& ref ): m_ref( ref ) {}
auto setValue( std::string const& arg )
-> ParserResult override {
ParserResult setValue( std::string const& arg ) override {
return convertInto( arg, m_ref );
}
};
@ -419,7 +424,7 @@ namespace Catch {
virtual auto parse( std::string const& exeName,
TokenStream const& tokens ) const
-> InternalParseResult = 0;
virtual auto cardinality() const -> size_t { return 1; }
virtual size_t cardinality() const;
InternalParseResult parse( Args const& args ) const;
};