Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/bbannier/iwyu-pre-commit'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Oct 14, 2024
2 parents fdb8faf + 1ae5994 commit f06bd93
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.12.0-dev.136 | 2024-10-14 14:20:16 +0200

* Disable cpplint iwyu check. (Benjamin Bannier, Corelight)

* Replace a few C-style casts with `static_cast`. (Benjamin Bannier, Corelight)

1.12.0-dev.133 | 2024-10-08 21:50:53 +0200

* Document `continue` statements. (Evan Typanski, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Copyright (c) 2020-2023 by the Zeek Project. See LICENSE for details.
filter=-,+build/include_what_you_use,+readability/casting
filter=-,+readability/casting
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.12.0-dev.133
1.12.0-dev.136
2 changes: 1 addition & 1 deletion hilti/runtime/include/types/integer.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ inline hilti::rt::integer::safe<UINT> bits(hilti::rt::integer::safe<UINT> v, uin
if ( range == width )
return v;

const auto mask = ((uint64_t(1) << range) - uint64_t(1U)) << lower;
const auto mask = ((static_cast<uint64_t>(1) << range) - static_cast<uint64_t>(1U)) << lower;
return (v & mask) >> lower;
}

Expand Down
12 changes: 6 additions & 6 deletions hilti/runtime/src/tests/integer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ TEST_CASE("flip32") {
const auto max = std::numeric_limits<uint32_t>::max();

// NOLINTNEXTLINE(bugprone-integer-division)
CHECK_EQ(integer::flip32(max / 2), std::pow(uint64_t(256), 4) - 256 / 2 - 1);
CHECK_EQ(integer::flip32(max / 2), std::pow(static_cast<uint64_t>(256), 4) - 256 / 2 - 1);

CHECK_EQ(integer::flip32(max - 3), std::pow(uint64_t(256), 4) - std::pow(256, 3) * 3 - 1);
CHECK_EQ(integer::flip32(max - 2), std::pow(uint64_t(256), 4) - std::pow(256, 3) * 2 - 1);
CHECK_EQ(integer::flip32(max - 1), std::pow(uint64_t(256), 4) - std::pow(256, 3) * 1 - 1);
CHECK_EQ(integer::flip32(max - 0), std::pow(uint64_t(256), 4) - std::pow(256, 3) * 0 - 1);
CHECK_EQ(integer::flip32(max - 3), std::pow(static_cast<uint64_t>(256), 4) - std::pow(256, 3) * 3 - 1);
CHECK_EQ(integer::flip32(max - 2), std::pow(static_cast<uint64_t>(256), 4) - std::pow(256, 3) * 2 - 1);
CHECK_EQ(integer::flip32(max - 1), std::pow(static_cast<uint64_t>(256), 4) - std::pow(256, 3) * 1 - 1);
CHECK_EQ(integer::flip32(max - 0), std::pow(static_cast<uint64_t>(256), 4) - std::pow(256, 3) * 0 - 1);
}

TEST_CASE("flip64") {
CHECK_EQ(integer::flip64(0), 0);
CHECK_EQ(integer::flip64(1), std::pow(uint64_t(256), 7) * 1);
CHECK_EQ(integer::flip64(1), std::pow(static_cast<uint64_t>(256), 7) * 1);
CHECK_EQ(integer::flip64(2), std::pow(256, 7) * 2);
CHECK_EQ(integer::flip64(3), std::pow(256, 7) * 3);

Expand Down
4 changes: 2 additions & 2 deletions hilti/toolchain/src/compiler/coercer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ struct VisitorCtor : visitor::PreOrder {
switch ( t->isWildcard() ? 64 : t->width() ) {
case 8:
if ( static_cast<double>(int8_t(d)) == d )
result = builder->ctorSignedInteger(int64_t(d), 8, n->meta());
result = builder->ctorSignedInteger(static_cast<int64_t>(d), 8, n->meta());
break;

case 16:
Expand Down Expand Up @@ -167,7 +167,7 @@ struct VisitorCtor : visitor::PreOrder {

case 16:
if ( static_cast<double>(static_cast<uint16_t>(d)) == d )
result = builder->ctorUnsignedInteger(uint64_t(d), 16, n->meta());
result = builder->ctorUnsignedInteger(static_cast<uint64_t>(d), 16, n->meta());
break;

case 32:
Expand Down

0 comments on commit f06bd93

Please sign in to comment.