mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 21:35:40 +02:00
Fix clang analyzer warning about FilterGenerator
Refactor FilterGenerator to remove ctor call to overridden method next() in order to address clang static analyzer diagnostic: catch2-src/single_include/catch2/catch.hpp:4166:42: note: Call to virtual method 'FilterGenerator::next' during construction bypasses virtual dispatch auto has_initial_value = next(); ^~~~~~
This commit is contained in:

committed by
Martin Hořeňovský

parent
f45dac8fc1
commit
33794a204c
@@ -63,7 +63,7 @@ namespace Generators {
|
||||
if (!m_predicate(m_generator.get())) {
|
||||
// It might happen that there are no values that pass the
|
||||
// filter. In that case we throw an exception.
|
||||
auto has_initial_value = next();
|
||||
auto has_initial_value = nextImpl();
|
||||
if (!has_initial_value) {
|
||||
Catch::throw_exception(GeneratorException("No valid value found in filtered generator"));
|
||||
}
|
||||
@@ -75,6 +75,11 @@ namespace Generators {
|
||||
}
|
||||
|
||||
bool next() override {
|
||||
return nextImpl();
|
||||
}
|
||||
|
||||
private:
|
||||
bool nextImpl() {
|
||||
bool success = m_generator.next();
|
||||
if (!success) {
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user