Skip to content

Commit

Permalink
Fix: return in non-void function in testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanFoo0523 committed Jul 18, 2024
1 parent 9ea9738 commit 9fb5084
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
4 changes: 3 additions & 1 deletion test/single_file/decltype_cast_function_call.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
long bar() {}
long bar() {
return 1LL;
}

void foo() {
unsigned x = (decltype(bar())) 'a';
Expand Down
18 changes: 14 additions & 4 deletions test/single_file/decltype_cast_function_call.cc.expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
long bar() {}

#include <cinttypes>
#include <cstddef>
#include <functional>
Expand Down Expand Up @@ -27,7 +25,7 @@ static bool __dredd_enabled_mutation(int local_mutation_id) {
if (!token.empty()) {
int value = std::stoi(token);
int local_value = value - 0;
if (local_value >= 0 && local_value < 3) {
if (local_value >= 0 && local_value < 7) {
enabled_bitset[local_value / 64] |= (static_cast<uint64_t>(1) << (local_value % 64));
some_mutation_enabled = true;
}
Expand All @@ -52,6 +50,18 @@ static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg,
return arg;
}

static long __dredd_replace_expr_long_one(long arg, int local_mutation_id) {
if (!__dredd_some_mutation_enabled) return arg;
if (__dredd_enabled_mutation(local_mutation_id + 0)) return ~(arg);
if (__dredd_enabled_mutation(local_mutation_id + 1)) return 0;
if (__dredd_enabled_mutation(local_mutation_id + 2)) return -1;
return arg;
}

long bar() {
if (!__dredd_enabled_mutation(3)) { return __dredd_replace_expr_long_one(1LL, 0); }
}

void foo() {
unsigned x = __dredd_replace_expr_unsigned_int_constant((decltype(bar())) 'a', 0);
unsigned x = __dredd_replace_expr_unsigned_int_constant((decltype(bar())) 'a', 4);
}
32 changes: 28 additions & 4 deletions test/single_file/decltype_cast_function_call.cc.noopt.expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
long bar() {}

#include <cinttypes>
#include <cstddef>
#include <functional>
Expand Down Expand Up @@ -27,7 +25,7 @@ static bool __dredd_enabled_mutation(int local_mutation_id) {
if (!token.empty()) {
int value = std::stoi(token);
int local_value = value - 0;
if (local_value >= 0 && local_value < 4) {
if (local_value >= 0 && local_value < 17) {
enabled_bitset[local_value / 64] |= (static_cast<uint64_t>(1) << (local_value % 64));
some_mutation_enabled = true;
}
Expand All @@ -53,6 +51,32 @@ static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int loca
return arg;
}

static long long __dredd_replace_expr_long_long(long long arg, int local_mutation_id) {
if (!__dredd_some_mutation_enabled) return arg;
if (__dredd_enabled_mutation(local_mutation_id + 0)) return !(arg);
if (__dredd_enabled_mutation(local_mutation_id + 1)) return ~(arg);
if (__dredd_enabled_mutation(local_mutation_id + 2)) return -(arg);
if (__dredd_enabled_mutation(local_mutation_id + 3)) return 0;
if (__dredd_enabled_mutation(local_mutation_id + 4)) return 1;
if (__dredd_enabled_mutation(local_mutation_id + 5)) return -1;
return arg;
}

static long __dredd_replace_expr_long(long arg, int local_mutation_id) {
if (!__dredd_some_mutation_enabled) return arg;
if (__dredd_enabled_mutation(local_mutation_id + 0)) return !(arg);
if (__dredd_enabled_mutation(local_mutation_id + 1)) return ~(arg);
if (__dredd_enabled_mutation(local_mutation_id + 2)) return -(arg);
if (__dredd_enabled_mutation(local_mutation_id + 3)) return 0;
if (__dredd_enabled_mutation(local_mutation_id + 4)) return 1;
if (__dredd_enabled_mutation(local_mutation_id + 5)) return -1;
return arg;
}

long bar() {
if (!__dredd_enabled_mutation(12)) { return __dredd_replace_expr_long(__dredd_replace_expr_long_long(1LL, 0), 6); }
}

void foo() {
unsigned x = __dredd_replace_expr_unsigned_int((decltype(bar())) 'a', 0);
unsigned x = __dredd_replace_expr_unsigned_int((decltype(bar())) 'a', 13);
}

0 comments on commit 9fb5084

Please sign in to comment.