-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename all shadowed types and variables and enable Wshadow when in pedantic mode #1965
Conversation
d1f3483
to
609c5fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Mostly looks good but please fix CI build failures and address inline comments.
include/fmt/os.h
Outdated
ostream_params(T... params, int oflag) : ostream_params(params...) { | ||
this->oflag = oflag; | ||
ostream_params(T... params, int new_oflag) : ostream_params(params...) { | ||
this->oflag = new_oflag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this->
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
test/core-test.cc
Outdated
@@ -213,12 +213,12 @@ struct custom_context { | |||
|
|||
template <typename T> struct formatter_type { | |||
template <typename ParseContext> | |||
auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { | |||
return ctx.begin(); | |||
auto parse(ParseContext& parse_ctx) -> decltype(parse_ctx.begin()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep argument names as is but rename the data member to parse_ctx
since it has wider scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - I'm glad you looked at that one, I had a feeling that the situation might be something like this but I didn't want to be too aggressive so I tried my best to keep the scope very local.
test/format-test.cc
Outdated
@@ -219,12 +219,12 @@ TEST(AllocatorTest, allocator_ref) { | |||
check_forwarding(alloc, ref3); | |||
} | |||
|
|||
typedef allocator_ref<std::allocator<char>> TestAllocator; | |||
typedef allocator_ref<std::allocator<char>> StdAllocator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's follow the naming conventions while at it:
using std_allocator = allocator_ref<std::allocator<char>>;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Done
187b3b0
to
9cc2342
Compare
A few more build failures: https://travis-ci.org/github/fmtlib/fmt/jobs/740386845 |
9cc2342
to
87b4d2a
Compare
I can't get this last set of errors to reproduce locally for reasons that are not clear to me, so there might be a bit of churn with using CI to find the errors. |
51fbcd4
to
40dab6e
Compare
Just in case anyone else encounters the issue of not being able to reproduce errors locally - the C++ standard seems to matter to at least GCC for whether or not |
test/format-test.cc
Outdated
s = fmt::detail::bit_cast<uint32_pair>(uint64_t(~0ull)); | ||
s = fmt::detail::bit_cast<uint32_pair>(~0ull); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks unrelated and technically not correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, sorry about that - fixed.
test/std-format-test.cc
Outdated
constexpr auto parse(format_parse_context& ctx) { | ||
auto parse(format_parse_context& ctx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, sorry about that - fixed
Problem: - All `-Wshadow` warnings are fixed but there is nothing stopping them from being reintroduced. Solution: - Fail pedantic builds on `-Wshadow` warnings. This allows CI to prevent reoccurrence of the warning. Notes: - Not enabling `-Wshadow` for gcc versions 4 or lower because the warning is much more aggressive there to the point that it's mostly just noise.
40dab6e
to
82f6af4
Compare
@jgopel thank you for doing this. It was annoying my team for some time now :) |
Merged, thanks! |
I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.