Sweep out Wshadow

Most of the changes are completely pointless renaming of constructor
arguments so that they do not use the same name as the type members,
but 🤷

Closes #2015
This commit is contained in:
Martin Hořeňovský 2020-09-06 13:10:43 +02:00
parent 90aeffb97d
commit cc18bd719d
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
12 changed files with 32 additions and 31 deletions

View File

@ -62,6 +62,7 @@ function(add_warnings_to_targets targets)
"-Wcall-to-pure-virtual-from-ctor-dtor" "-Wcall-to-pure-virtual-from-ctor-dtor"
"-Wdeprecated-register" "-Wdeprecated-register"
"-Wsuggest-override" "-Wsuggest-override"
"-Wshadow"
) )
foreach(warning ${CHECKED_WARNING_FLAGS}) foreach(warning ${CHECKED_WARNING_FLAGS})
add_cxx_flag_if_supported_to_targets(${warning} "${targets}") add_cxx_flag_if_supported_to_targets(${warning} "${targets}")

View File

@ -33,12 +33,12 @@
namespace Catch { namespace Catch {
namespace Benchmark { namespace Benchmark {
struct Benchmark { struct Benchmark {
Benchmark(std::string &&name) Benchmark(std::string&& benchmarkName)
: name(std::move(name)) {} : name(std::move(benchmarkName)) {}
template <class FUN> template <class FUN>
Benchmark(std::string &&name, FUN &&func) Benchmark(std::string&& benchmarkName , FUN &&func)
: fun(std::move(func)), name(std::move(name)) {} : fun(std::move(func)), name(std::move(benchmarkName)) {}
template <typename Clock> template <typename Clock>
ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const { ExecutionPlan<FloatDuration<Clock>> prepare(const IConfig &cfg, Environment<FloatDuration<Clock>> env) const {

View File

@ -44,11 +44,11 @@ namespace Catch {
template <typename Fun> template <typename Fun>
void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); } void measure(Fun&& fun) { measure(std::forward<Fun>(fun), is_callable<Fun(int)>()); }
int runs() const { return k; } int runs() const { return repeats; }
Chronometer(Detail::ChronometerConcept& meter, int k) Chronometer(Detail::ChronometerConcept& meter, int repeats_)
: impl(&meter) : impl(&meter)
, k(k) {} , repeats(repeats_) {}
private: private:
template <typename Fun> template <typename Fun>
@ -60,13 +60,13 @@ namespace Catch {
void measure(Fun&& fun, std::true_type) { void measure(Fun&& fun, std::true_type) {
Detail::optimizer_barrier(); Detail::optimizer_barrier();
impl->start(); impl->start();
for (int i = 0; i < k; ++i) invoke_deoptimized(fun, i); for (int i = 0; i < repeats; ++i) invoke_deoptimized(fun, i);
impl->finish(); impl->finish();
Detail::optimizer_barrier(); Detail::optimizer_barrier();
} }
Detail::ChronometerConcept* impl; Detail::ChronometerConcept* impl;
int k; int repeats;
}; };
} // namespace Benchmark } // namespace Benchmark
} // namespace Catch } // namespace Catch

View File

@ -48,8 +48,8 @@ namespace Catch {
}; };
template <typename Fun> template <typename Fun>
struct model : public callable { struct model : public callable {
model(Fun&& fun) : fun(std::move(fun)) {} model(Fun&& fun_) : fun(std::move(fun_)) {}
model(Fun const& fun) : fun(fun) {} model(Fun const& fun_) : fun(fun_) {}
model<Fun>* clone() const override { return new model<Fun>(*this); } model<Fun>* clone() const override { return new model<Fun>(*this); }

View File

@ -78,8 +78,8 @@ namespace Catch {
TokenStream::TokenStream( Args const& args ): TokenStream::TokenStream( Args const& args ):
TokenStream( args.m_args.begin(), args.m_args.end() ) {} TokenStream( args.m_args.begin(), args.m_args.end() ) {}
TokenStream::TokenStream( Iterator it, Iterator itEnd ): TokenStream::TokenStream( Iterator it_, Iterator itEnd_ ):
it( it ), itEnd( itEnd ) { it( it_ ), itEnd( itEnd_ ) {
loadBuffer(); loadBuffer();
} }

View File

@ -26,7 +26,7 @@ namespace Catch {
struct lineOfChars { struct lineOfChars {
char c; char c;
constexpr lineOfChars( char c ): c( c ) {} constexpr lineOfChars( char c_ ): c( c_ ) {}
friend std::ostream& operator<<( std::ostream& out, lineOfChars value ); friend std::ostream& operator<<( std::ostream& out, lineOfChars value );
}; };

View File

@ -371,7 +371,7 @@ Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltyp
Matchers.tests.cpp:<line number>: passed: 1, MatcherA() && MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 ) Matchers.tests.cpp:<line number>: passed: 1, MatcherA() && MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 )
Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Detail::MatchAnyOfGeneric<MatcherA, Catch::Matchers::Detail::MatchNotOfGeneric<MatcherB>> >::value' Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Detail::MatchAnyOfGeneric<MatcherA, Catch::Matchers::Detail::MatchNotOfGeneric<MatcherB>> >::value'
Matchers.tests.cpp:<line number>: passed: 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 ) Matchers.tests.cpp:<line number>: passed: 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 )
Matchers.tests.cpp:<line number>: passed: vec, Predicate<std::vector<int>>([](auto const& vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) for: { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } ) Matchers.tests.cpp:<line number>: passed: vec, Predicate<std::vector<int>>([](auto const& v) { return std::all_of(v.begin(), v.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) for: { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } )
Matchers.tests.cpp:<line number>: passed: str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and ends with: "bar" ) Matchers.tests.cpp:<line number>: passed: str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and ends with: "bar" )
Matchers.tests.cpp:<line number>: passed: str, StartsWith("foo") && !EqualsRange(bad_arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and not Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } and ends with: "bar" ) Matchers.tests.cpp:<line number>: passed: str, StartsWith("foo") && !EqualsRange(bad_arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and not Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } and ends with: "bar" )
Matchers.tests.cpp:<line number>: passed: str, EqualsRange(arr) && StartsWith("foo") && EndsWith("bar") for: "foobar" ( Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and starts with: "foo" and ends with: "bar" ) Matchers.tests.cpp:<line number>: passed: str, EqualsRange(arr) && StartsWith("foo") && EndsWith("bar") for: "foobar" ( Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and starts with: "foo" and ends with: "bar" )
@ -1014,7 +1014,7 @@ Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'Message fro
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'Message from section two' Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'Message from section two'
Matchers.tests.cpp:<line number>: passed: (EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed Matchers.tests.cpp:<line number>: passed: (EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed
Matchers.tests.cpp:<line number>: passed: &EvilMatcher(), EvilAddressOfOperatorUsed Matchers.tests.cpp:<line number>: passed: &EvilMatcher(), EvilAddressOfOperatorUsed
Matchers.tests.cpp:<line number>: passed: EvilMatcher() || EvilMatcher() && !EvilMatcher() Matchers.tests.cpp:<line number>: passed: EvilMatcher() || (EvilMatcher() && !EvilMatcher())
Matchers.tests.cpp:<line number>: passed: (EvilMatcher() && EvilMatcher()) || !EvilMatcher() Matchers.tests.cpp:<line number>: passed: (EvilMatcher() && EvilMatcher()) || !EvilMatcher()
CmdLine.tests.cpp:<line number>: passed: spec.hasFilters() == false for: false == false CmdLine.tests.cpp:<line number>: passed: spec.hasFilters() == false for: false == false
CmdLine.tests.cpp:<line number>: passed: spec.matches( *tcA ) == false for: false == false CmdLine.tests.cpp:<line number>: passed: spec.matches( *tcA ) == false for: false == false

View File

@ -3037,7 +3037,7 @@ Matchers.tests.cpp:<line number>
............................................................................... ...............................................................................
Matchers.tests.cpp:<line number>: PASSED: Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( vec, Predicate<std::vector<int>>([](auto const& vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) ) REQUIRE_THAT( vec, Predicate<std::vector<int>>([](auto const& v) { return std::all_of(v.begin(), v.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) )
with expansion: with expansion:
{ 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5,
3, 1 } ) 3, 1 } )
@ -7500,7 +7500,7 @@ Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_THROWS_AS( &EvilMatcher(), EvilAddressOfOperatorUsed ) REQUIRE_THROWS_AS( &EvilMatcher(), EvilAddressOfOperatorUsed )
Matchers.tests.cpp:<line number>: PASSED: Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_NOTHROW( EvilMatcher() || EvilMatcher() && !EvilMatcher() ) REQUIRE_NOTHROW( EvilMatcher() || (EvilMatcher() && !EvilMatcher()) )
Matchers.tests.cpp:<line number>: PASSED: Matchers.tests.cpp:<line number>: PASSED:
REQUIRE_NOTHROW( (EvilMatcher() && EvilMatcher()) || !EvilMatcher() ) REQUIRE_NOTHROW( (EvilMatcher() && EvilMatcher()) || !EvilMatcher() )

View File

@ -741,7 +741,7 @@ ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || !Matche
# Combining only templated matchers # Combining only templated matchers
ok {test-number} - 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 ) ok {test-number} - 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 )
# Combining templated and concrete matchers # Combining templated and concrete matchers
ok {test-number} - vec, Predicate<std::vector<int>>([](auto const& vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) for: { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } ) ok {test-number} - vec, Predicate<std::vector<int>>([](auto const& v) { return std::all_of(v.begin(), v.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) for: { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } )
# Combining templated and concrete matchers # Combining templated and concrete matchers
ok {test-number} - str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and ends with: "bar" ) ok {test-number} - str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and ends with: "bar" )
# Combining templated and concrete matchers # Combining templated and concrete matchers
@ -1951,7 +1951,7 @@ ok {test-number} - (EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed
# Overloaded comma or address-of operators are not used # Overloaded comma or address-of operators are not used
ok {test-number} - &EvilMatcher(), EvilAddressOfOperatorUsed ok {test-number} - &EvilMatcher(), EvilAddressOfOperatorUsed
# Overloaded comma or address-of operators are not used # Overloaded comma or address-of operators are not used
ok {test-number} - EvilMatcher() || EvilMatcher() && !EvilMatcher() ok {test-number} - EvilMatcher() || (EvilMatcher() && !EvilMatcher())
# Overloaded comma or address-of operators are not used # Overloaded comma or address-of operators are not used
ok {test-number} - (EvilMatcher() && EvilMatcher()) || !EvilMatcher() ok {test-number} - (EvilMatcher() && EvilMatcher()) || !EvilMatcher()
# Parse test names and tags # Parse test names and tags

View File

@ -3223,7 +3223,7 @@ Nor would this
<TestCase name="Combining templated and concrete matchers" tags="[matchers][templated]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <TestCase name="Combining templated and concrete matchers" tags="[matchers][templated]" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original> <Original>
vec, Predicate&lt;std::vector&lt;int>>([](auto const&amp; vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") &amp;&amp; !EqualsRange(a) vec, Predicate&lt;std::vector&lt;int>>([](auto const&amp; v) { return std::all_of(v.begin(), v.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") &amp;&amp; !EqualsRange(a)
</Original> </Original>
<Expanded> <Expanded>
{ 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } ) { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } )
@ -9042,10 +9042,10 @@ Nor would this
</Expression> </Expression>
<Expression success="true" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <Expression success="true" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original> <Original>
EvilMatcher() || EvilMatcher() &amp;&amp; !EvilMatcher() EvilMatcher() || (EvilMatcher() &amp;&amp; !EvilMatcher())
</Original> </Original>
<Expanded> <Expanded>
EvilMatcher() || EvilMatcher() &amp;&amp; !EvilMatcher() EvilMatcher() || (EvilMatcher() &amp;&amp; !EvilMatcher())
</Expanded> </Expanded>
</Expression> </Expression>
<Expression success="true" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" > <Expression success="true" type="REQUIRE_NOTHROW" filename="tests/<exe-name>/UsageTests/Matchers.tests.cpp" >

View File

@ -68,7 +68,7 @@ TEST_CASE("unique_ptr reimplementation: basic functionality", "[internals][uniqu
namespace { namespace {
struct base { struct base {
int i; int i;
base(int i) :i(i) {} base(int i_) :i(i_) {}
}; };
struct derived : base { using base::base; }; struct derived : base { using base::base; };
struct unrelated {}; struct unrelated {};

View File

@ -711,22 +711,22 @@ namespace { namespace MatchersTests {
template<typename Range> template<typename Range>
struct EqualsRangeMatcher : Catch::Matchers::MatcherGenericBase { struct EqualsRangeMatcher : Catch::Matchers::MatcherGenericBase {
EqualsRangeMatcher(Range const& range) : range{ range } {} EqualsRangeMatcher(Range const& range) : m_range{ range } {}
template<typename OtherRange> template<typename OtherRange>
bool match(OtherRange const& other) const { bool match(OtherRange const& other) const {
using std::begin; using std::begin;
using std::end; using std::end;
return std::equal(begin(range), end(range), begin(other), end(other)); return std::equal(begin(m_range), end(m_range), begin(other), end(other));
} }
std::string describe() const override { std::string describe() const override {
return "Equals: " + Catch::rangeToString(range); return "Equals: " + Catch::rangeToString(m_range);
} }
private: private:
Range const& range; Range const& m_range;
}; };
template<typename Range> template<typename Range>
@ -750,8 +750,8 @@ namespace { namespace MatchersTests {
std::array<int, 3> a{{ 5, 3, 1 }}; std::array<int, 3> a{{ 5, 3, 1 }};
REQUIRE_THAT(vec, REQUIRE_THAT(vec,
Predicate<std::vector<int>>([](auto const& vec) { Predicate<std::vector<int>>([](auto const& v) {
return std::all_of(vec.begin(), vec.end(), [](int elem) { return std::all_of(v.begin(), v.end(), [](int elem) {
return elem % 2 == 1; return elem % 2 == 1;
}); });
}, "All elements are odd") && }, "All elements are odd") &&
@ -948,7 +948,7 @@ namespace { namespace MatchersTests {
TEST_CASE("Overloaded comma or address-of operators are not used", "[matchers][templated]") { TEST_CASE("Overloaded comma or address-of operators are not used", "[matchers][templated]") {
REQUIRE_THROWS_AS((EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed); REQUIRE_THROWS_AS((EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed);
REQUIRE_THROWS_AS(&EvilMatcher(), EvilAddressOfOperatorUsed); REQUIRE_THROWS_AS(&EvilMatcher(), EvilAddressOfOperatorUsed);
REQUIRE_NOTHROW(EvilMatcher() || EvilMatcher() && !EvilMatcher()); REQUIRE_NOTHROW(EvilMatcher() || (EvilMatcher() && !EvilMatcher()));
REQUIRE_NOTHROW((EvilMatcher() && EvilMatcher()) || !EvilMatcher()); REQUIRE_NOTHROW((EvilMatcher() && EvilMatcher()) || !EvilMatcher());
} }