Skip to content

Commit

Permalink
Remove debugging output from integer range checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmmr committed Dec 12, 2022
1 parent 46d781e commit b408c1c
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion hilti/toolchain/src/compiler/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ ctor : CBOOL { $$ = hilti::ctor::Bool($1, __
| CSTRING { $$ = hilti::ctor::String($1, __loc__); }
| CUINTEGER { $$ = hilti::ctor::UnsignedInteger($1, 64, __loc__); }
| '+' CUINTEGER { if ( $2 > static_cast<uint64_t>(std::numeric_limits<int64_t>::max()) )
logger().error("integer constant out of range C1", __loc__.location());
logger().error("integer constant out of range", __loc__.location());

$$ = hilti::ctor::SignedInteger($2, 64, __loc__);
}
Expand Down
6 changes: 3 additions & 3 deletions hilti/toolchain/src/compiler/visitors/constant-folder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ struct VisitorConstantFolder : public visitor::PreOrder<std::optional<Ctor>, Vis
// Helper to cast an uint64 to int64, with range check.
int64_t to_int64(uint64_t x, position_t& p) {
if ( x > static_cast<uint64_t>(std::numeric_limits<int64_t>::max()) )
throw hilti::rt::OutOfRange("integer value out of range A1");
throw hilti::rt::OutOfRange("integer value out of range");

return static_cast<int64_t>(x);
}
Expand All @@ -75,7 +75,7 @@ struct VisitorConstantFolder : public visitor::PreOrder<std::optional<Ctor>, Vis
// Helper to cast an int64 to uint64, with range check.
uint64_t to_uint64(int64_t x, position_t& p) {
if ( x < 0 )
throw hilti::rt::OutOfRange("integer value out of range A2");
throw hilti::rt::OutOfRange("integer value out of range");

return static_cast<uint64_t>(x);
}
Expand All @@ -96,7 +96,7 @@ struct VisitorConstantFolder : public visitor::PreOrder<std::optional<Ctor>, Vis
return std::nullopt;

if ( op->value() > std::abs(std::numeric_limits<int64_t>::min()) )
throw hilti::rt::OutOfRange("integer value out of range A3");
throw hilti::rt::OutOfRange("integer value out of range");

return ctor::SignedInteger(-static_cast<int64_t>(op->value()), op->width(), p.node.meta());
}
Expand Down
4 changes: 2 additions & 2 deletions hilti/toolchain/src/compiler/visitors/validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ struct VisitorPost : public hilti::visitor::PreOrder<void, VisitorPost>, public
auto [min, max] = util::signed_integer_range(n.width());

if ( n.value() < min || n.value() > max )
error("integer value out of range for type B1", p);
error("integer value out of range for type", p);
}

void operator()(const ctor::Set& n, position_t p) {
Expand All @@ -273,7 +273,7 @@ struct VisitorPost : public hilti::visitor::PreOrder<void, VisitorPost>, public
auto [min, max] = util::unsigned_integer_range(n.width());

if ( n.value() < min || n.value() > max )
error("integer value out of range for type B2", p);
error("integer value out of range for type", p);
}

void operator()(const ctor::Vector& n, position_t p) {
Expand Down
2 changes: 1 addition & 1 deletion spicy/toolchain/src/compiler/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ ctor : CADDRESS { $$ = hilti::ctor::Address(hil
| CSTRING { $$ = hilti::ctor::String($1, __loc__); }
| CUINTEGER { $$ = hilti::ctor::UnsignedInteger($1, 64, __loc__); }
| '+' CUINTEGER { if ( $2 > static_cast<uint64_t>(std::numeric_limits<int64_t>::max()) )
hilti::logger().error("integer constant out of range C1", __loc__.location());
hilti::logger().error("integer constant out of range", __loc__.location());

$$ = hilti::ctor::SignedInteger($2, 64, __loc__);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Baseline/hilti.types.integer.ctor-fail-2/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:2:18: integer value out of range A3
[error] hiltic: errors encountered during normalizing
[error] <...>/ctor-fail.hlt:2:18: integer value out of range
[error] hiltic: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/hilti.types.integer.ctor-fail-3/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:2:12: integer value out of range A2
[error] hiltic: errors encountered during normalizing
[error] <...>/ctor-fail.hlt:2:12: integer value out of range
[error] hiltic: aborting after errors
2 changes: 1 addition & 1 deletion tests/Baseline/hilti.types.integer.ctor-fail-4/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:2:12: integer value out of range for type B2
[error] <...>/ctor-fail.hlt:2:12: integer value out of range for type
[error] hiltic: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/hilti.types.integer.ctor-fail-5/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:2:12: integer value out of range A2
[error] hiltic: errors encountered during normalizing
[error] <...>/ctor-fail.hlt:2:12: integer value out of range
[error] hiltic: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/hilti.types.integer.ctor-fail-6/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:2:12: integer value out of range A2
[error] hiltic: errors encountered during normalizing
[error] <...>/ctor-fail.hlt:2:12: integer value out of range
[error] hiltic: aborting after errors
2 changes: 1 addition & 1 deletion tests/Baseline/hilti.types.integer.ctor-fail-7/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:2:12: integer value out of range for type B1
[error] <...>/ctor-fail.hlt:2:12: integer value out of range for type
[error] hiltic: aborting after errors
2 changes: 1 addition & 1 deletion tests/Baseline/hilti.types.integer.ctor-fail-8/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:2:12: integer constant out of range C1
[error] <...>/ctor-fail.hlt:2:12: integer constant out of range
[error] hiltic: parse error
4 changes: 2 additions & 2 deletions tests/Baseline/hilti.types.integer.ctor-fail/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.hlt:7:12: integer value out of range A1
[error] hiltic: errors encountered during normalizing
[error] <...>/ctor-fail.hlt:7:12: integer value out of range
[error] hiltic: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/spicy.types.integer.ctor-fail-3/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.spicy:1:28: unsigned integer value out of range
[error] spicyc: errors encountered during normalizing
[error] <...>/ctor-fail.spicy:1:28: integer value out of range
[error] spicyc: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/spicy.types.integer.ctor-fail-4/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.spicy:1:29: unsigned integer value out of range
[error] spicyc: errors encountered during normalizing
[error] <...>/ctor-fail.spicy:1:29: integer value out of range
[error] spicyc: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/spicy.types.integer.ctor-fail-5/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.spicy:1:27: unsigned integer value out of range
[error] spicyc: errors encountered during normalizing
[error] <...>/ctor-fail.spicy:1:27: integer value out of range
[error] spicyc: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/spicy.types.integer.ctor-fail-6/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.spicy:1:29: unsigned integer value out of range
[error] spicyc: errors encountered during normalizing
[error] <...>/ctor-fail.spicy:1:29: integer value out of range
[error] spicyc: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/spicy.types.integer.ctor-fail-8/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.spicy:4:17: signed integer value out of range
[error] spicyc: errors encountered during normalizing
[error] <...>/ctor-fail.spicy:4:17: integer value out of range
[error] spicyc: aborting after errors
4 changes: 2 additions & 2 deletions tests/Baseline/spicy.types.integer.ctor-fail-9/output
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
[error] <...>/ctor-fail.spicy:3:23: signed integer value out of range
[error] spicyc: parse error
[error] <...>/ctor-fail.spicy:3:23: integer value out of range
[error] spicyc: aborting after errors
16 changes: 8 additions & 8 deletions tests/hilti/types/integer/ctor-fail.hlt
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@
# @TEST-DOC: Test a series of out-of-range integer constructors.

module Test {
global x = int64(9223372036854775808); # max_int64 + 1 / A1
global x = int64(9223372036854775808); # max_int64 + 1
}

@TEST-START-NEXT
module Test {
global x = int64(-9223372036854775809); # min_int64 - 1 / A3
global x = int64(-9223372036854775809); # min_int64 - 1
}

@TEST-START-NEXT
module Test {
global x = uint64(-1); # < 0 / A2
global x = uint64(-1);
}

@TEST-START-NEXT
module Test {
global x = uint8(256); # B2
global x = uint8(256);
}

@TEST-START-NEXT
module Test {
global x = uint8(-256); # A2
global x = uint8(-256);
}

@TEST-START-NEXT
module Test {
global x = uint8(-1); # A2
global x = uint8(-1);
}

@TEST-START-NEXT
module Test {
global x = int8(128); # B1
global x = int8(128);
}

@TEST-START-NEXT
module Test {
global x = +9223372036854775808; # C1
global x = +9223372036854775808;
}

0 comments on commit b408c1c

Please sign in to comment.