Skip to content
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

Fix clang tidy errors #148

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler+runtime/src/cpp/jank/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ extern "C"
jank_object_ptr jank_list_create(uint64_t const size, ...)
{
/* NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) */
va_list args;
va_list args{};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to merge the changes in this file, but not in lex.cpp. Those are out of date and not what we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropping this one and sent another one instead: #157

va_start(args, size);

native_vector<object_ptr> v;
Expand All @@ -414,7 +414,7 @@ extern "C"
jank_object_ptr jank_vector_create(uint64_t const size, ...)
{
/* NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) */
va_list args;
va_list args{};
va_start(args, size);

obj::transient_vector trans;
Expand All @@ -433,7 +433,7 @@ extern "C"
jank_object_ptr jank_map_create(uint64_t const pairs, ...)
{
/* NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) */
va_list args;
va_list args{};
va_start(args, pairs);

/* TODO: Could optimize to build an array map, if it's small enough. */
Expand All @@ -454,7 +454,7 @@ extern "C"
jank_object_ptr jank_set_create(uint64_t const size, ...)
{
/* NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg) */
va_list args;
va_list args{};
va_start(args, size);

obj::transient_hash_set trans;
Expand Down
20 changes: 16 additions & 4 deletions compiler+runtime/src/cpp/jank/read/lex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ namespace jank::read
return none;
}

static int cast_char32_t_as_int(char32_t const c)
{
if(c > static_cast<char32_t>(INT_MAX))
{
throw std::runtime_error("Value out of range for wint_t");
}

// Perform the safe conversion
auto const safe_char = static_cast<int>(c);
return safe_char;
}

static result<codepoint, error>
convert_to_codepoint(native_persistent_string_view const sv, size_t const pos)
{
Expand Down Expand Up @@ -313,7 +325,7 @@ namespace jank::read

static native_bool is_symbol_char(char32_t const c)
{
return !std::iswspace(c) && !is_special_char(c)
return !std::iswspace(cast_char32_t_as_int(c)) && !is_special_char(c)
&& (std::iswalnum(static_cast<wint_t>(c)) != 0 || c == '_' || c == '-' || c == '/'
|| c == '?' || c == '!' || c == '+' || c == '*' || c == '=' || c == '.' || c == '&'
|| c == '<' || c == '>' || c == '#' || c == '%' || is_utf8_char(c));
Expand Down Expand Up @@ -377,7 +389,7 @@ namespace jank::read
auto const ch(peek());
pos++;

if(ch.is_err() || std::iswspace(ch.expect_ok().character))
if(ch.is_err() || std::iswspace(cast_char32_t_as_int(ch.expect_ok().character)))
{
return err(error{ token_start, "Expecting a valid character literal after \\" });
}
Expand Down Expand Up @@ -514,7 +526,7 @@ namespace jank::read
return err(
error{ token_start, pos, "invalid ratio: expecting an integer denominator" });
}
else if(std::iswdigit(c) == 0)
else if(std::iswdigit(cast_char32_t_as_int(c)) == 0)
{
if(expecting_exponent)
{
Expand Down Expand Up @@ -631,7 +643,7 @@ namespace jank::read

auto const oc(peek());
auto const c(oc.expect_ok().character);
if(oc.is_err() || std::iswspace(c))
if(oc.is_err() || std::iswspace(cast_char32_t_as_int(c)))
{
++pos;
return err(
Expand Down