Skip to content

Commit

Permalink
🎨 🐛 Rename all shadowed types and variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jgopel committed Nov 2, 2020
1 parent 112755c commit 212efbd
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 36 deletions.
6 changes: 3 additions & 3 deletions include/fmt/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ class format_string_compiler : public error_handler {
repl.arg_id = part_.part_kind == part::kind::arg_index
? arg_ref<Char>(part_.val.arg_index)
: arg_ref<Char>(part_.val.str);
auto part = part::make_replacement(repl);
part.arg_id_end = begin;
handler_(part);
auto replacement_part = part::make_replacement(repl);
replacement_part.arg_id_end = begin;
handler_(replacement_part);
return it;
}
};
Expand Down
4 changes: 2 additions & 2 deletions include/fmt/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ struct ostream_params {
ostream_params() {}

template <typename... T>
ostream_params(T... params, int oflag) : ostream_params(params...) {
this->oflag = oflag;
ostream_params(T... params, int new_oflag) : ostream_params(params...) {
oflag = new_oflag;
}

template <typename... T>
Expand Down
4 changes: 2 additions & 2 deletions test/chrono-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ TEST(TimeTest, TimePoint) {

#define EXPECT_TIME(spec, time, duration) \
{ \
std::locale loc("ja_JP.utf8"); \
EXPECT_EQ(format_tm(time, spec, loc), \
std::locale jp_loc("ja_JP.utf8"); \
EXPECT_EQ(format_tm(time, spec, jp_loc), \
fmt::format(loc, "{:" spec "}", duration)); \
}

Expand Down
14 changes: 7 additions & 7 deletions test/core-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ template <typename T> struct mock_buffer final : buffer<T> {

void grow(size_t capacity) { this->set(this->data(), do_grow(capacity)); }

mock_buffer(T* data = nullptr, size_t capacity = 0) {
this->set(data, capacity);
mock_buffer(T* data = nullptr, size_t buf_capacity = 0) {
this->set(data, buf_capacity);
ON_CALL(*this, do_grow(_)).WillByDefault(Invoke([](size_t capacity) {
return capacity;
}));
Expand Down Expand Up @@ -224,9 +224,9 @@ struct custom_context {
};

bool called;
fmt::format_parse_context ctx;
fmt::format_parse_context parse_ctx;

fmt::format_parse_context& parse_context() { return ctx; }
fmt::format_parse_context& parse_context() { return parse_ctx; }
void advance_to(const char*) {}
};

Expand Down Expand Up @@ -688,9 +688,9 @@ TYPED_TEST(IsStringTest, IsString) {
EXPECT_TRUE(fmt::detail::is_string<fmt::basic_string_view<TypeParam>>::value);
EXPECT_TRUE(
fmt::detail::is_string<derived_from_string_view<TypeParam>>::value);
using string_view = fmt::detail::std_string_view<TypeParam>;
EXPECT_TRUE(std::is_empty<string_view>::value !=
fmt::detail::is_string<string_view>::value);
using fmt_string_view = fmt::detail::std_string_view<TypeParam>;
EXPECT_TRUE(std::is_empty<fmt_string_view>::value !=
fmt::detail::is_string<fmt_string_view>::value);
EXPECT_TRUE(fmt::detail::is_string<my_ns::my_string<TypeParam>>::value);
EXPECT_FALSE(fmt::detail::is_string<my_ns::non_string>::value);
}
Expand Down
24 changes: 12 additions & 12 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>> std_allocator;

static void check_move_buffer(
const char* str, basic_memory_buffer<char, 5, TestAllocator>& buffer) {
const char* str, basic_memory_buffer<char, 5, std_allocator>& buffer) {
std::allocator<char>* alloc = buffer.get_allocator().get();
basic_memory_buffer<char, 5, TestAllocator> buffer2(std::move(buffer));
basic_memory_buffer<char, 5, std_allocator> buffer2(std::move(buffer));
// Move shouldn't destroy the inline content of the first buffer.
EXPECT_EQ(str, std::string(&buffer[0], buffer.size()));
EXPECT_EQ(str, std::string(&buffer2[0], buffer2.size()));
Expand All @@ -236,7 +236,7 @@ static void check_move_buffer(

TEST(MemoryBufferTest, MoveCtorInlineBuffer) {
std::allocator<char> alloc;
basic_memory_buffer<char, 5, TestAllocator> buffer((TestAllocator(&alloc)));
basic_memory_buffer<char, 5, std_allocator> buffer((std_allocator(&alloc)));
const char test[] = "test";
buffer.append(string_view(test, 4));
check_move_buffer("test", buffer);
Expand All @@ -248,14 +248,14 @@ TEST(MemoryBufferTest, MoveCtorInlineBuffer) {

TEST(MemoryBufferTest, MoveCtorDynamicBuffer) {
std::allocator<char> alloc;
basic_memory_buffer<char, 4, TestAllocator> buffer((TestAllocator(&alloc)));
basic_memory_buffer<char, 4, std_allocator> buffer((std_allocator(&alloc)));
const char test[] = "test";
buffer.append(test, test + 4);
const char* inline_buffer_ptr = &buffer[0];
// Adding one more character causes the content to move from the inline to
// a dynamically allocated buffer.
buffer.push_back('a');
basic_memory_buffer<char, 4, TestAllocator> buffer2(std::move(buffer));
basic_memory_buffer<char, 4, std_allocator> buffer2(std::move(buffer));
// Move should rip the guts of the first buffer.
EXPECT_EQ(inline_buffer_ptr, &buffer[0]);
EXPECT_EQ("testa", std::string(&buffer2[0], buffer2.size()));
Expand Down Expand Up @@ -446,9 +446,9 @@ TEST(UtilTest, FormatSystemError) {
}

TEST(UtilTest, SystemError) {
fmt::system_error e(EDOM, "test");
EXPECT_EQ(fmt::format("test: {}", get_system_error(EDOM)), e.what());
EXPECT_EQ(EDOM, e.error_code());
fmt::system_error test_error(EDOM, "test");
EXPECT_EQ(fmt::format("test: {}", get_system_error(EDOM)), test_error.what());
EXPECT_EQ(EDOM, test_error.error_code());

fmt::system_error error(0, "");
try {
Expand Down Expand Up @@ -2097,7 +2097,7 @@ struct test_format_specs_handler {
enum Result { NONE, PLUS, MINUS, SPACE, HASH, ZERO, ERROR };
Result res = NONE;

fmt::align_t align = fmt::align::none;
fmt::align_t alignment = fmt::align::none;
char fill = 0;
int width = 0;
fmt::detail::arg_ref<char> width_ref;
Expand All @@ -2111,15 +2111,15 @@ struct test_format_specs_handler {
FMT_CONSTEXPR test_format_specs_handler(
const test_format_specs_handler& other)
: res(other.res),
align(other.align),
alignment(other.alignment),
fill(other.fill),
width(other.width),
width_ref(other.width_ref),
precision(other.precision),
precision_ref(other.precision_ref),
type(other.type) {}

FMT_CONSTEXPR void on_align(fmt::align_t a) { align = a; }
FMT_CONSTEXPR void on_align(fmt::align_t a) { alignment = a; }
FMT_CONSTEXPR void on_fill(fmt::string_view f) { fill = f[0]; }
FMT_CONSTEXPR void on_plus() { res = PLUS; }
FMT_CONSTEXPR void on_minus() { res = MINUS; }
Expand Down
12 changes: 5 additions & 7 deletions test/locale-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,13 @@ template <class charT> struct formatter<std::complex<double>, charT> {
FormatContext& ctx) {
detail::handle_dynamic_spec<detail::precision_checker>(
specs_.precision, specs_.precision_ref, ctx);
auto format_specs = std::string();
if (specs_.precision > 0)
format_specs = fmt::format(".{}", specs_.precision);
if (specs_.type)
format_specs += specs_.type;
auto specs = std::string();
if (specs_.precision > 0) specs = fmt::format(".{}", specs_.precision);
if (specs_.type) specs += specs_.type;
auto real = fmt::format(ctx.locale().template get<std::locale>(),
"{:" + format_specs + "}", c.real());
"{:" + specs + "}", c.real());
auto imag = fmt::format(ctx.locale().template get<std::locale>(),
"{:" + format_specs + "}", c.imag());
"{:" + specs + "}", c.imag());
auto fill_align_width = std::string();
if (specs_.width > 0)
fill_align_width = fmt::format(">{}", specs_.width);
Expand Down
5 changes: 3 additions & 2 deletions test/ostream-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {

struct test_buffer final : fmt::detail::buffer<char> {
explicit test_buffer(size_t size)
: fmt::detail::buffer<char>(nullptr, size, size) {}
: fmt::detail::buffer<char>(nullptr, size, size) {}
void grow(size_t) {}
} buffer(max_size);

Expand All @@ -165,7 +165,8 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
} streambuf;

struct test_ostream : std::ostream {
explicit test_ostream(mock_streambuf& buffer) : std::ostream(&buffer) {}
explicit test_ostream(mock_streambuf& output_buffer)
: std::ostream(&output_buffer) {}
} os(streambuf);

testing::InSequence sequence;
Expand Down
2 changes: 1 addition & 1 deletion test/std-format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ template <> struct std::formatter<S> {
size_t width_arg_id = 0;

// Parses a width argument id in the format { <digit> }.
constexpr auto parse(format_parse_context& ctx) {
auto parse(format_parse_context& ctx) {
auto iter = ctx.begin();
// auto get_char = [&]() { return iter != ctx.end() ? *iter : 0; };
auto get_char = [&]() { return iter != ctx.end() ? *iter : '\0'; };
Expand Down

0 comments on commit 212efbd

Please sign in to comment.