From 8553f5acd2deb073ae4f71d904cd157b68c3c85b Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 12:14:30 +0000 Subject: [PATCH 01/15] Refactor mutation_replace_binary_operator to use macros --- src/libdredd/include/libdredd/mutation.h | 3 +- .../include/libdredd/mutation_remove_stmt.h | 3 +- .../mutation_replace_binary_operator.h | 29 ++- .../include/libdredd/mutation_replace_expr.h | 3 +- .../mutation_replace_unary_operator.h | 3 +- src/libdredd/include/libdredd/util.h | 2 + .../include/libdredd/mutate_ast_consumer.h | 3 +- src/libdredd/src/mutate_ast_consumer.cc | 21 +- src/libdredd/src/mutation_remove_stmt.cc | 4 +- .../src/mutation_replace_binary_operator.cc | 205 ++++++++++-------- src/libdredd/src/mutation_replace_expr.cc | 4 +- .../src/mutation_replace_unary_operator.cc | 4 +- src/libdredd/src/util.cc | 8 + .../src/mutation_remove_stmt_test.cc | 3 +- .../mutation_replace_binary_operator_test.cc | 3 +- .../src/mutation_replace_expr_test.cc | 4 +- .../mutation_replace_unary_operator_test.cc | 3 +- 17 files changed, 188 insertions(+), 117 deletions(-) diff --git a/src/libdredd/include/libdredd/mutation.h b/src/libdredd/include/libdredd/mutation.h index 56c93438..ac8fee9a 100644 --- a/src/libdredd/include/libdredd/mutation.h +++ b/src/libdredd/include/libdredd/mutation.h @@ -53,7 +53,8 @@ class Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const = 0; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const = 0; }; } // namespace dredd diff --git a/src/libdredd/include/libdredd/mutation_remove_stmt.h b/src/libdredd/include/libdredd/mutation_remove_stmt.h index b0f0f8ad..db915e14 100644 --- a/src/libdredd/include/libdredd/mutation_remove_stmt.h +++ b/src/libdredd/include/libdredd/mutation_remove_stmt.h @@ -40,7 +40,8 @@ class MutationRemoveStmt : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; private: // Helper method to determine whether the token immediately following the diff --git a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h index e07b0734..7a67cc58 100644 --- a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h @@ -42,14 +42,17 @@ class MutationReplaceBinaryOperator : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; private: std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& lhs_type, - const std::string& rhs_type, bool optimise_mutations, - bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& lhs_type, const std::string& rhs_type, + bool optimise_mutations, bool only_track_mutant_coverage, + int& mutation_id, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; void ReplaceOperator(const std::string& lhs_type, const std::string& rhs_type, @@ -62,6 +65,8 @@ class MutationReplaceBinaryOperator : public Mutation { std::string GetFunctionName(bool optimise_mutations, clang::ASTContext& ast_context) const; + static std::string OpKindToString(clang::BinaryOperatorKind kind); + [[nodiscard]] bool IsRedundantReplacementOperator( clang::BinaryOperatorKind operator_kind, const clang::ASTContext& ast_context) const; @@ -76,18 +81,28 @@ class MutationReplaceBinaryOperator : public Mutation { [[nodiscard]] bool IsValidReplacementOperator( clang::BinaryOperatorKind operator_kind) const; + static std::string GenerateArgumentReplacementMacro( + const std::string& name, const std::string& arg_evaluated); + // Replaces binary expressions with either the left or right operand. void GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; + static std::string GenerateBinaryOperatorMacro( + const std::string& name, const std::string& arg1_evaluated, + const clang::BinaryOperatorKind& operator_kind, + const std::string& arg2_evaluated); + // Replaces binary operators with other valid binary operators. void GenerateBinaryOperatorReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; diff --git a/src/libdredd/include/libdredd/mutation_replace_expr.h b/src/libdredd/include/libdredd/mutation_replace_expr.h index fee39226..cdb4df42 100644 --- a/src/libdredd/include/libdredd/mutation_replace_expr.h +++ b/src/libdredd/include/libdredd/mutation_replace_expr.h @@ -41,7 +41,8 @@ class MutationReplaceExpr : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; static void ApplyCppTypeModifiers(const clang::Expr& expr, std::string& type); diff --git a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h index 24c6f621..a7c0aafb 100644 --- a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h @@ -41,7 +41,8 @@ class MutationReplaceUnaryOperator : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; private: std::string GenerateMutatorFunction( diff --git a/src/libdredd/include/libdredd/util.h b/src/libdredd/include/libdredd/util.h index da47090a..53633a9b 100644 --- a/src/libdredd/include/libdredd/util.h +++ b/src/libdredd/include/libdredd/util.h @@ -128,6 +128,8 @@ bool EvaluateAsFloat(const clang::Expr& expr, bool IsCxx11ConstantExpr(const clang::Expr& expr, const clang::ASTContext& ast_context); +std::string GenerateMutatorMacro(const std::string& name, + const std::string& args_evaluated); } // namespace dredd #endif // LIBDREDD_UTIL_H diff --git a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h index 6cefda09..ff0ee38c 100644 --- a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h +++ b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h @@ -66,7 +66,8 @@ class MutateAstConsumer : public clang::ASTConsumer { protobufs::MutationTreeNode ApplyMutations( const MutationTreeNode& mutation_tree_node, int initial_mutation_id, clang::ASTContext& context, - std::unordered_set& dredd_declarations); + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros); const clang::CompilerInstance* compiler_instance_; diff --git a/src/libdredd/src/mutate_ast_consumer.cc b/src/libdredd/src/mutate_ast_consumer.cc index 99b5dd85..8756dbb0 100644 --- a/src/libdredd/src/mutate_ast_consumer.cc +++ b/src/libdredd/src/mutate_ast_consumer.cc @@ -74,6 +74,7 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { // converted to an ordered set so that declarations can be added to the source // file in a deterministic order. std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; protobufs::MutationInfoForFile mutation_info_for_file; mutation_info_for_file.set_filename( @@ -83,7 +84,7 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { .str()); *mutation_info_for_file.mutable_mutation_tree_root() = ApplyMutations(visitor_->GetMutations(), initial_mutation_id, ast_context, - dredd_declarations); + dredd_declarations, dredd_macros); if (initial_mutation_id == *mutation_id_) { // No possibilities for mutation were found; nothing else to do. @@ -111,6 +112,15 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Rewrite failed.\n"); } + std::set sorted_dredd_macros; + sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); + for (const auto& macro : sorted_dredd_macros) { + const bool rewriter_result = + rewriter_.InsertTextBefore(start_of_source_file, macro); + (void)rewriter_result; // Keep release-mode compilers happy. + assert(!rewriter_result && "Rewrite failed.\n"); + } + const std::string dredd_prelude = compiler_instance_->getLangOpts().CPlusPlus ? GetDreddPreludeCpp(initial_mutation_id) @@ -361,7 +371,8 @@ std::string MutateAstConsumer::GetDreddPreludeC(int initial_mutation_id) const { protobufs::MutationTreeNode MutateAstConsumer::ApplyMutations( const MutationTreeNode& mutation_tree_node, int initial_mutation_id, clang::ASTContext& context, - std::unordered_set& dredd_declarations) { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) { assert(!(mutation_tree_node.IsEmpty() && mutation_tree_node.GetChildren().size() == 1) && "The mutation tree should already be compressed."); @@ -369,15 +380,15 @@ protobufs::MutationTreeNode MutateAstConsumer::ApplyMutations( for (const auto& child : mutation_tree_node.GetChildren()) { assert(!child->IsEmpty() && "The mutation tree should not have empty subtrees."); - *result.add_children() = ApplyMutations(*child, initial_mutation_id, - context, dredd_declarations); + *result.add_children() = ApplyMutations( + *child, initial_mutation_id, context, dredd_declarations, dredd_macros); } for (const auto& mutation : mutation_tree_node.GetMutations()) { const int mutation_id_old = *mutation_id_; const auto mutation_group = mutation->Apply( context, compiler_instance_->getPreprocessor(), optimise_mutations_, only_track_mutant_coverage_, initial_mutation_id, *mutation_id_, - rewriter_, dredd_declarations); + rewriter_, dredd_declarations, dredd_macros); if (*mutation_id_ > mutation_id_old) { // Only add the result of applying the mutation if it had an effect. *result.add_mutation_groups() = mutation_group; diff --git a/src/libdredd/src/mutation_remove_stmt.cc b/src/libdredd/src/mutation_remove_stmt.cc index 344f990b..d5bc0e47 100644 --- a/src/libdredd/src/mutation_remove_stmt.cc +++ b/src/libdredd/src/mutation_remove_stmt.cc @@ -42,8 +42,10 @@ protobufs::MutationGroup MutationRemoveStmt::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { (void)dredd_declarations; // Unused. + (void)dredd_macros; // Unused. (void)optimise_mutations; // Unused. // The protobuf object for the mutation, which will be wrapped in a diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index eac4bfac..266f06fa 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -84,104 +84,81 @@ bool MutationReplaceBinaryOperator::IsValidReplacementOperator( operator_kind == clang::BO_XorAssign)); } -std::string MutationReplaceBinaryOperator::GetFunctionName( - bool optimise_mutations, clang::ASTContext& ast_context) const { - std::string result = "__dredd_replace_binary_operator_"; - - // A string corresponding to the binary operator forms part of the name of the - // mutation function, to differentiate mutation functions for different - // operators - switch (binary_operator_->getOpcode()) { +std::string MutationReplaceBinaryOperator::OpKindToString( + clang::BinaryOperatorKind kind) { + switch (kind) { case clang::BinaryOperatorKind::BO_Add: - result += "Add"; - break; + return "Add"; case clang::BinaryOperatorKind::BO_Div: - result += "Div"; - break; + return "Div"; case clang::BinaryOperatorKind::BO_Mul: - result += "Mul"; - break; + return "Mul"; case clang::BinaryOperatorKind::BO_Rem: - result += "Rem"; - break; + return "Rem"; case clang::BinaryOperatorKind::BO_Sub: - result += "Sub"; - break; + return "Sub"; case clang::BinaryOperatorKind::BO_AddAssign: - result += "AddAssign"; - break; + return "AddAssign"; case clang::BinaryOperatorKind::BO_AndAssign: - result += "AndAssign"; - break; + return "AndAssign"; case clang::BinaryOperatorKind::BO_Assign: - result += "Assign"; - break; + return "Assign"; case clang::BinaryOperatorKind::BO_DivAssign: - result += "DivAssign"; - break; + return "DivAssign"; case clang::BinaryOperatorKind::BO_MulAssign: - result += "MulAssign"; - break; + return "MulAssign"; case clang::BinaryOperatorKind::BO_OrAssign: - result += "OrAssign"; - break; + return "OrAssign"; case clang::BinaryOperatorKind::BO_RemAssign: - result += "RemAssign"; - break; + return "RemAssign"; case clang::BinaryOperatorKind::BO_ShlAssign: - result += "ShlAssign"; - break; + return "ShlAssign"; case clang::BinaryOperatorKind::BO_ShrAssign: - result += "ShrAssign"; - break; + return "ShrAssign"; case clang::BinaryOperatorKind::BO_SubAssign: - result += "SubAssign"; - break; + return "SubAssign"; case clang::BinaryOperatorKind::BO_XorAssign: - result += "XorAssign"; - break; + return "XorAssign"; case clang::BinaryOperatorKind::BO_And: - result += "And"; - break; + return "And"; case clang::BinaryOperatorKind::BO_Or: - result += "Or"; - break; + return "Or"; case clang::BinaryOperatorKind::BO_Xor: - result += "Xor"; - break; + return "Xor"; case clang::BinaryOperatorKind::BO_LAnd: - result += "LAnd"; - break; + return "LAnd"; case clang::BinaryOperatorKind::BO_LOr: - result += "LOr"; - break; + return "LOr"; case clang::BinaryOperatorKind::BO_EQ: - result += "EQ"; - break; + return "EQ"; case clang::BinaryOperatorKind::BO_GE: - result += "GE"; - break; + return "GE"; case clang::BinaryOperatorKind::BO_GT: - result += "GT"; - break; + return "GT"; case clang::BinaryOperatorKind::BO_LE: - result += "LE"; - break; + return "LE"; case clang::BinaryOperatorKind::BO_LT: - result += "LT"; - break; + return "LT"; case clang::BinaryOperatorKind::BO_NE: - result += "NE"; - break; + return "NE"; case clang::BinaryOperatorKind::BO_Shl: - result += "Shl"; - break; + return "Shl"; case clang::BinaryOperatorKind::BO_Shr: - result += "Shr"; - break; + return "Shr"; default: assert(false && "Unsupported opcode"); + return ""; } +} + +std::string MutationReplaceBinaryOperator::GetFunctionName( + bool optimise_mutations, clang::ASTContext& ast_context) const { + std::string result = "__dredd_replace_binary_operator_"; + + // A string corresponding to the binary operator forms part of the name of the + // mutation function, to differentiate mutation functions for different + // operators + result += OpKindToString(binary_operator_->getOpcode()); std::string lhs_qualifier; @@ -254,9 +231,15 @@ std::string MutationReplaceBinaryOperator::GetFunctionName( return result; } +std::string MutationReplaceBinaryOperator::GenerateArgumentReplacementMacro( + const std::string& name, const std::string& arg_evaluated) { + return GenerateMutatorMacro(name, arg_evaluated); +} + void MutationReplaceBinaryOperator::GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { @@ -302,9 +285,16 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getLHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return " << arg1_evaluated - << ";\n"; + // TODO(JamesLee-Jones): Replace with arg replacement macro. + const std::string macro_name = "REPLACE_BINARY_ARG1"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert( + GenerateArgumentReplacementMacro(macro_name, arg1_evaluated)); + // new_function << " if (__dredd_enabled_mutation(local_mutation_id + // + " + // << mutation_id_offset << ")) return " << + // arg1_evaluated + // << ";\n"; } AddMutationInstance( mutation_id_base, @@ -329,9 +319,15 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getRHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return " << arg2_evaluated - << ";\n"; + const std::string macro_name = "REPLACE_BINARY_ARG2"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert( + GenerateArgumentReplacementMacro(macro_name, arg2_evaluated)); + // new_function << " if (__dredd_enabled_mutation(local_mutation_id + // + " + // << mutation_id_offset << ")) return " << + // arg2_evaluated + // << ";\n"; } AddMutationInstance( mutation_id_base, @@ -340,20 +336,39 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( } } +std::string MutationReplaceBinaryOperator::GenerateBinaryOperatorMacro( + const std::string& name, const std::string& arg1_evaluated, + const clang::BinaryOperatorKind& operator_kind, + const std::string& arg2_evaluated) { + const std::string args_evaluated = + arg1_evaluated + + clang::BinaryOperator::getOpcodeStr(operator_kind).str() + arg2_evaluated; + return GenerateMutatorMacro(name, args_evaluated); +} + void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return " << arg1_evaluated - << " " - << clang::BinaryOperator::getOpcodeStr(operator_kind).str() - << " " << arg2_evaluated << ";\n"; + // TODO(JamesLee-Jones): Replace with replacement macro. + const std::string macro_name = "REPLACE_" + OpKindToString(operator_kind); + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert(GenerateBinaryOperatorMacro( + macro_name, arg1_evaluated, operator_kind, arg2_evaluated)); + // new_function << " if (__dredd_enabled_mutation(local_mutation_id + // + " + // << mutation_id_offset << ")) return " << + // arg1_evaluated + // << " " + // << + // clang::BinaryOperator::getOpcodeStr(operator_kind).str() + // << " " << arg2_evaluated << ";\n"; } AddMutationInstance(mutation_id_base, OperatorKindToAction(operator_kind), mutation_id_offset, protobuf_message); @@ -435,10 +450,11 @@ MutationReplaceBinaryOperator::GetReplacementOperators( } std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& lhs_type, - const std::string& rhs_type, bool optimise_mutations, - bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& lhs_type, const std::string& rhs_type, + bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { std::stringstream new_function; new_function << "static " << result_type << " " << function_name << "("; @@ -483,6 +499,7 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( if (!only_track_mutant_coverage) { // Quickly apply the original operator if no mutant is enabled (which will // be the common case). + // TODO(JamesLee-Jones): Replace with pre-processing macro. new_function << " if (!__dredd_some_mutation_enabled) return " << arg1_evaluated << " " << clang::BinaryOperator::getOpcodeStr( @@ -492,18 +509,19 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( } GenerateBinaryOperatorReplacement( - arg1_evaluated, arg2_evaluated, ast_context, optimise_mutations, - only_track_mutant_coverage, mutation_id, new_function, mutation_id_offset, - protobuf_message); - GenerateArgumentReplacement(arg1_evaluated, arg2_evaluated, ast_context, - optimise_mutations, only_track_mutant_coverage, - mutation_id, new_function, mutation_id_offset, - protobuf_message); + arg1_evaluated, arg2_evaluated, ast_context, dredd_macros, + optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, + mutation_id_offset, protobuf_message); + GenerateArgumentReplacement( + arg1_evaluated, arg2_evaluated, ast_context, dredd_macros, + optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, + mutation_id_offset, protobuf_message); if (only_track_mutant_coverage) { new_function << " __dredd_record_covered_mutants(local_mutation_id, " + std::to_string(mutation_id_offset) + ");\n"; } + // TODO(JamesLee-Jones): Replace with return macro. new_function << " return " << arg1_evaluated << " " << clang::BinaryOperator::getOpcodeStr( binary_operator_->getOpcode()) @@ -523,7 +541,8 @@ protobufs::MutationGroup MutationReplaceBinaryOperator::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceBinaryOperator inner_result; @@ -609,8 +628,8 @@ protobufs::MutationGroup MutationReplaceBinaryOperator::Apply( rewriter); const std::string new_function = GenerateMutatorFunction( - ast_context, new_function_name, result_type, lhs_type, rhs_type, - optimise_mutations, only_track_mutant_coverage, mutation_id, + ast_context, dredd_macros, new_function_name, result_type, lhs_type, + rhs_type, optimise_mutations, only_track_mutant_coverage, mutation_id, inner_result); assert(!new_function.empty() && "Unsupported opcode."); diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 79f358e2..067002bc 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -596,11 +596,13 @@ protobufs::MutationGroup MutationReplaceExpr::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceExpr inner_result; + (void)dredd_macros; inner_result.mutable_start()->set_line(info_for_source_range_.GetStartLine()); inner_result.mutable_start()->set_column( info_for_source_range_.GetStartColumn()); diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index b9db1c3f..6c9353d2 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -339,11 +339,13 @@ protobufs::MutationGroup MutationReplaceUnaryOperator::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceUnaryOperator inner_result; + (void)dredd_macros; inner_result.set_operator_( ClangOperatorKindToProtobufOperatorKind(unary_operator_->getOpcode())); diff --git a/src/libdredd/src/util.cc b/src/libdredd/src/util.cc index 53591ddc..c1e6c666 100644 --- a/src/libdredd/src/util.cc +++ b/src/libdredd/src/util.cc @@ -129,4 +129,12 @@ bool IsCxx11ConstantExpr(const clang::Expr& expr, return !expr.isValueDependent() && expr.isCXX11ConstantExpr(ast_context); } +std::string GenerateMutatorMacro(const std::string& name, + const std::string& args_evaluated) { + return "#define " + name + + "(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id " + "+ mutation_id_offset)) return " + + args_evaluated + "\n"; +} + } // namespace dredd diff --git a/src/libdreddtest/src/mutation_remove_stmt_test.cc b/src/libdreddtest/src/mutation_remove_stmt_test.cc index 315d2c9b..5088a871 100644 --- a/src/libdreddtest/src/mutation_remove_stmt_test.cc +++ b/src/libdreddtest/src/mutation_remove_stmt_test.cc @@ -47,9 +47,10 @@ void TestRemoval(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation_supplier(ast_unit->getPreprocessor(), ast_unit->getASTContext()) .Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), true, - false, 0, mutation_id, rewriter, dredd_declarations); + false, 0, mutation_id, rewriter, dredd_declarations, dredd_macros); ASSERT_EQ(1, mutation_id); ASSERT_EQ(0, dredd_declarations.size()); const clang::RewriteBuffer* rewrite_buffer = rewriter.getRewriteBufferFor( diff --git a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc index 2a5bef1c..ff2ab550 100644 --- a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc @@ -57,9 +57,10 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), optimise_mutations, false, 0, mutation_id, rewriter, - dredd_declarations); + dredd_declarations, dredd_macros); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); diff --git a/src/libdreddtest/src/mutation_replace_expr_test.cc b/src/libdreddtest/src/mutation_replace_expr_test.cc index d416e996..12727f3b 100644 --- a/src/libdreddtest/src/mutation_replace_expr_test.cc +++ b/src/libdreddtest/src/mutation_replace_expr_test.cc @@ -60,8 +60,10 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), true, - false, 0, mutation_id, rewriter, dredd_declarations); + false, 0, mutation_id, rewriter, dredd_declarations, + dredd_macros); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); diff --git a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc index c31780bc..77eb2b26 100644 --- a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc @@ -57,9 +57,10 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), optimise_mutations, false, 0, mutation_id, rewriter, - dredd_declarations); + dredd_declarations, dredd_macros); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); From 2222ccc304dc88cd3f787914b0673c844e1b8faf Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 17:16:11 +0000 Subject: [PATCH 02/15] Replace mutations with single macro --- .../include/libdredd/mutation_replace_expr.h | 22 ++- src/libdredd/include/libdredd/util.h | 2 - .../include/libdredd/mutate_ast_consumer.h | 6 + src/libdredd/src/mutate_ast_consumer.cc | 32 +++- .../src/mutation_replace_binary_operator.cc | 64 ++++--- src/libdredd/src/mutation_replace_expr.cc | 161 ++++++++++++------ .../src/mutation_replace_unary_operator.cc | 25 +-- src/libdredd/src/util.cc | 8 - 8 files changed, 199 insertions(+), 121 deletions(-) diff --git a/src/libdredd/include/libdredd/mutation_replace_expr.h b/src/libdredd/include/libdredd/mutation_replace_expr.h index cdb4df42..6d67d85c 100644 --- a/src/libdredd/include/libdredd/mutation_replace_expr.h +++ b/src/libdredd/include/libdredd/mutation_replace_expr.h @@ -95,25 +95,33 @@ class MutationReplaceExpr : public Mutation { // Replace expressions with constants. void GenerateConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateBooleanConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateIntegerConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateFloatConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; @@ -121,6 +129,7 @@ class MutationReplaceExpr : public Mutation { // Insert valid unary operators such as !, ~, ++ and --. void GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, @@ -128,6 +137,7 @@ class MutationReplaceExpr : public Mutation { void GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, @@ -135,12 +145,14 @@ class MutationReplaceExpr : public Mutation { void GenerateUnaryOperatorInsertionBeforeLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, + clang::ASTContext& ast_context, std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, const std::string& input_type, bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const; diff --git a/src/libdredd/include/libdredd/util.h b/src/libdredd/include/libdredd/util.h index 53633a9b..da47090a 100644 --- a/src/libdredd/include/libdredd/util.h +++ b/src/libdredd/include/libdredd/util.h @@ -128,8 +128,6 @@ bool EvaluateAsFloat(const clang::Expr& expr, bool IsCxx11ConstantExpr(const clang::Expr& expr, const clang::ASTContext& ast_context); -std::string GenerateMutatorMacro(const std::string& name, - const std::string& args_evaluated); } // namespace dredd #endif // LIBDREDD_UTIL_H diff --git a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h index ff0ee38c..c2d30aef 100644 --- a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h +++ b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h @@ -47,6 +47,12 @@ class MutateAstConsumer : public clang::ASTConsumer { void HandleTranslationUnit(clang::ASTContext& ast_context) override; private: + std::string GetMutationMacro() const; + + std::string GetMutationPreludeMacro() const; + + std::string GetMutationResultMacro() const; + [[nodiscard]] std::string GetDreddPreludeCpp(int initial_mutation_id) const; [[nodiscard]] std::string GetRegularDreddPreludeCpp( diff --git a/src/libdredd/src/mutate_ast_consumer.cc b/src/libdredd/src/mutate_ast_consumer.cc index 8756dbb0..9a2894d9 100644 --- a/src/libdredd/src/mutate_ast_consumer.cc +++ b/src/libdredd/src/mutate_ast_consumer.cc @@ -112,14 +112,18 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Rewrite failed.\n"); } - std::set sorted_dredd_macros; - sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); - for (const auto& macro : sorted_dredd_macros) { - const bool rewriter_result = - rewriter_.InsertTextBefore(start_of_source_file, macro); - (void)rewriter_result; // Keep release-mode compilers happy. - assert(!rewriter_result && "Rewrite failed.\n"); - } + (void) dredd_macros; + rewriter_.InsertTextBefore(start_of_source_file, GetMutationPreludeMacro()); + rewriter_.InsertTextBefore(start_of_source_file, GetMutationMacro()); + rewriter_.InsertTextBefore(start_of_source_file, GetMutationResultMacro()); +// std::set sorted_dredd_macros; +// sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); +// for (const auto& macro : sorted_dredd_macros) { +// const bool rewriter_result = +// rewriter_.InsertTextBefore(start_of_source_file, macro); +// (void)rewriter_result; // Keep release-mode compilers happy. +// assert(!rewriter_result && "Rewrite failed.\n"); +// } const std::string dredd_prelude = compiler_instance_->getLangOpts().CPlusPlus @@ -136,6 +140,18 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Something went wrong emitting rewritten files."); } +std::string MutateAstConsumer::GetMutationMacro() const { + return "#define MUTATION(mutation_id_offset, arg) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg\n\n"; +} + +std::string MutateAstConsumer::GetMutationPreludeMacro() const { + return "#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg\n\n"; +} + +std::string MutateAstConsumer::GetMutationResultMacro() const { + return "#define MUTATION_RESULT(arg) arg\n\n"; +} + std::string MutateAstConsumer::GetRegularDreddPreludeCpp( int initial_mutation_id) const { // The number of mutations applied to this file is known. diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index 266f06fa..083fa959 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -231,11 +231,6 @@ std::string MutationReplaceBinaryOperator::GetFunctionName( return result; } -std::string MutationReplaceBinaryOperator::GenerateArgumentReplacementMacro( - const std::string& name, const std::string& arg_evaluated) { - return GenerateMutatorMacro(name, arg_evaluated); -} - void MutationReplaceBinaryOperator::GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, const clang::ASTContext& ast_context, @@ -243,6 +238,7 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { + (void) dredd_macros; if (optimise_mutations) { switch (binary_operator_->getOpcode()) { case clang::BO_GT: @@ -286,10 +282,10 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( *binary_operator_->getLHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { // TODO(JamesLee-Jones): Replace with arg replacement macro. - const std::string macro_name = "REPLACE_BINARY_ARG1"; - new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; - dredd_macros.insert( - GenerateArgumentReplacementMacro(macro_name, arg1_evaluated)); +// const std::string macro_name = "REPLACE_BINARY_ARG1"; + new_function << " MUTATION(" << mutation_id_offset << ", " << arg1_evaluated << ");\n"; +// dredd_macros.insert( +// GenerateArgumentReplacementMacro(macro_name, arg1_evaluated)); // new_function << " if (__dredd_enabled_mutation(local_mutation_id // + " // << mutation_id_offset << ")) return " << @@ -319,10 +315,10 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getRHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_BINARY_ARG2"; - new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; - dredd_macros.insert( - GenerateArgumentReplacementMacro(macro_name, arg2_evaluated)); +// const std::string macro_name = "REPLACE_BINARY_ARG2"; + new_function << " MUTATION(" << mutation_id_offset << ", " << arg2_evaluated << ");\n"; +// dredd_macros.insert( +// GenerateArgumentReplacementMacro(macro_name, arg2_evaluated)); // new_function << " if (__dredd_enabled_mutation(local_mutation_id // + " // << mutation_id_offset << ")) return " << @@ -336,16 +332,6 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( } } -std::string MutationReplaceBinaryOperator::GenerateBinaryOperatorMacro( - const std::string& name, const std::string& arg1_evaluated, - const clang::BinaryOperatorKind& operator_kind, - const std::string& arg2_evaluated) { - const std::string args_evaluated = - arg1_evaluated + - clang::BinaryOperator::getOpcodeStr(operator_kind).str() + arg2_evaluated; - return GenerateMutatorMacro(name, args_evaluated); -} - void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, const clang::ASTContext& ast_context, @@ -353,14 +339,16 @@ void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { + (void) dredd_macros; for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { // TODO(JamesLee-Jones): Replace with replacement macro. - const std::string macro_name = "REPLACE_" + OpKindToString(operator_kind); - new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; - dredd_macros.insert(GenerateBinaryOperatorMacro( - macro_name, arg1_evaluated, operator_kind, arg2_evaluated)); +// const std::string macro_name = "REPLACE_" + OpKindToString(operator_kind); + new_function << " MUTATION(" << mutation_id_offset << ", " << arg1_evaluated << clang::BinaryOperator::getOpcodeStr(operator_kind).str() << arg2_evaluated << ");\n"; + +// dredd_macros.insert(GenerateBinaryOperatorMacro( +// macro_name, arg1_evaluated, operator_kind, arg2_evaluated)); // new_function << " if (__dredd_enabled_mutation(local_mutation_id // + " // << mutation_id_offset << ")) return " << @@ -500,12 +488,18 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( // Quickly apply the original operator if no mutant is enabled (which will // be the common case). // TODO(JamesLee-Jones): Replace with pre-processing macro. - new_function << " if (!__dredd_some_mutation_enabled) return " - << arg1_evaluated << " " - << clang::BinaryOperator::getOpcodeStr( - binary_operator_->getOpcode()) - .str() - << " " << arg2_evaluated << ";\n"; + new_function << " MUTATION_PRELUDE(" + << arg1_evaluated << " " + << clang::BinaryOperator::getOpcodeStr( + binary_operator_->getOpcode()) + .str() + << " " << arg2_evaluated << ");\n"; +// new_function << " if (!__dredd_some_mutation_enabled) return " +// << arg1_evaluated << " " +// << clang::BinaryOperator::getOpcodeStr( +// binary_operator_->getOpcode()) +// .str() +// << " " << arg2_evaluated << ";\n"; } GenerateBinaryOperatorReplacement( @@ -522,11 +516,11 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( std::to_string(mutation_id_offset) + ");\n"; } // TODO(JamesLee-Jones): Replace with return macro. - new_function << " return " << arg1_evaluated << " " + new_function << " return MUTATION_RESULT(" << arg1_evaluated << " " << clang::BinaryOperator::getOpcodeStr( binary_operator_->getOpcode()) .str() - << " " << arg2_evaluated << ";\n"; + << " " << arg2_evaluated << ");\n"; new_function << "}\n\n"; diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 067002bc..8715e621 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -179,25 +179,33 @@ bool MutationReplaceExpr::IsRedundantOperatorInsertion( void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { + (void) dredd_macros; if (!expr_->isLValue() || !CanMutateLValue(ast_context, *expr_)) { return; } if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return ++(" << arg_evaluated - << ");\n"; +// const std::string macro_name = "REPLACE_EXPR_INC"; + new_function << " MUTATION(" << mutation_id_offset << ", ++(" << arg_evaluated << "));\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "++(" + arg_evaluated +")")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return ++(" << arg_evaluated +// << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreInc, mutation_id_offset, protobuf_message); if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return --(" << arg_evaluated - << ");\n"; +// const std::string macro_name = "REPLACE_EXPR_DEC"; + new_function << " MUTATION(" << mutation_id_offset << ", --(" << arg_evaluated <<"));\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "--(" + arg_evaluated +")")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return --(" << arg_evaluated +// << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreDec, @@ -206,10 +214,12 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { + (void) dredd_macros; if (expr_->isLValue()) { return; } @@ -220,9 +230,12 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return !(" << arg_evaluated - << ");\n"; +// const std::string macro_name = "REPLACE_EXPR_LNOT"; + new_function << " MUTATION(" << mutation_id_offset << ", !(" << arg_evaluated << "));\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "!(" + arg_evaluated +")")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return !(" << arg_evaluated +// << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertLNot, @@ -235,9 +248,12 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return ~(" << arg_evaluated - << ");\n"; +// const std::string macro_name = "REPLACE_EXPR_NOT"; + new_function << " MUTATION(" << mutation_id_offset << ", ~(" << arg_evaluated << "));\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "~(" + arg_evaluated +")")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return ~(" << arg_evaluated +// << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertNot, @@ -250,9 +266,12 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return -(" << arg_evaluated - << ");\n"; +// const std::string macro_name = "REPLACE_EXPR_MINUS"; + new_function << " MUTATION(" << mutation_id_offset << ", -(" << arg_evaluated << "));\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "-(" + arg_evaluated +")")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return -(" << arg_evaluated +// << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertMinus, @@ -263,42 +282,48 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { GenerateUnaryOperatorInsertionBeforeLValue( - arg_evaluated, ast_context, only_track_mutant_coverage, mutation_id_base, + arg_evaluated, ast_context, dredd_macros, only_track_mutant_coverage, mutation_id_base, new_function, mutation_id_offset, protobuf_message); GenerateUnaryOperatorInsertionBeforeNonLValue( - arg_evaluated, ast_context, optimise_mutations, + arg_evaluated, ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id_base, new_function, mutation_id_offset, protobuf_message); } void MutationReplaceExpr::GenerateConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { if (!expr_->isLValue()) { GenerateBooleanConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, + ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id_base, new_function, mutation_id_offset, protobuf_message); GenerateIntegerConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, + ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id_base, new_function, mutation_id_offset, protobuf_message); GenerateFloatConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, + ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id_base, new_function, mutation_id_offset, protobuf_message); } } void MutationReplaceExpr::GenerateFloatConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { + (void) dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isFloatingPoint()) { @@ -306,8 +331,11 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 0.0, ast_context)) { // Replace floating point expression with 0.0 if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return 0.0;\n"; +// const std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; + new_function << " MUTATION(" << mutation_id_offset << ", 0.0);\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "0.0")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return 0.0;\n"; } AddMutationInstance( mutation_id_base, @@ -319,8 +347,11 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 1.0, ast_context)) { // Replace floating point expression with 1.0 if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return 1.0;\n"; +// const std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; + new_function << " MUTATION(" << mutation_id_offset << ", 1.0);\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "1.0")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return 1.0;\n"; } AddMutationInstance( mutation_id_base, @@ -332,8 +363,11 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, -1.0, ast_context)) { // Replace floating point expression with -1.0 if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return -1.0;\n"; +// const std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; + new_function << " MUTATION(" << mutation_id_offset << ", -1.0);\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1.0")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return -1.0;\n"; } AddMutationInstance( mutation_id_base, @@ -343,18 +377,24 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( } } void MutationReplaceExpr::GenerateIntegerConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { + (void) dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isInteger() && !exprType.isBooleanType()) { if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 0, ast_context)) { // Replace expression with 0 if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return 0;\n"; +// const std::string macro_name = "REPLACE_EXPR_INT_ZERO"; + new_function << " MUTATION(" << mutation_id_offset << ", 0);\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "0")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return 0;\n"; } AddMutationInstance( mutation_id_base, @@ -365,8 +405,11 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 1, ast_context)) { // Replace expression with 1 if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return 1;\n"; +// const std::string macro_name = "REPLACE_EXPR_INT_ONE"; + new_function << " MUTATION(" << mutation_id_offset << ", 1);\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "1")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return 1;\n"; } AddMutationInstance( mutation_id_base, @@ -380,8 +423,11 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( !ExprIsEquivalentToInt(*expr_, -1, ast_context)) { // Replace signed integer expression with -1 if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return -1;\n"; +// const std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; + new_function << " MUTATION(" << mutation_id_offset << ", -1);\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return -1;\n"; } AddMutationInstance( mutation_id_base, @@ -391,10 +437,13 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( } } void MutationReplaceExpr::GenerateBooleanConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { + (void) dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isBooleanType()) { @@ -403,10 +452,13 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(true, ast_context))) { // Replace expression with true if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return " - << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") - << ";\n"; +// const std::string macro_name = "REPLACE_EXPR_TRUE"; + new_function << " MUTATION(" << mutation_id_offset << ", " << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") << ");\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, ast_context.getLangOpts().CPlusPlus ? "true" : "1")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return " +// << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") +// << ";\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::ReplaceWithTrue, @@ -418,10 +470,13 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(false, ast_context))) { // Replace expression with false if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return " - << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") - << ";\n"; +// const std::string macro_name = "REPLACE_EXPR_FALSE"; + new_function << " MUTATION(" << mutation_id_offset << ", " << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") << ");\n"; +// dredd_macros.insert(GenerateMutatorMacro(macro_name, ast_context.getLangOpts().CPlusPlus ? "false" : "0")); +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return " +// << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") +// << ";\n"; } AddMutationInstance( mutation_id_base, @@ -432,7 +487,8 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( } std::string MutationReplaceExpr::GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, + clang::ASTContext& ast_context, std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, const std::string& input_type, bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const { @@ -459,18 +515,19 @@ std::string MutationReplaceExpr::GenerateMutatorFunction( if (!only_track_mutant_coverage) { // Quickly apply the original operator if no mutant is enabled (which will // be the common case). - new_function << " if (!__dredd_some_mutation_enabled) return " - << arg_evaluated << ";\n"; + new_function << " MUTATION_PRELUDE(" << arg_evaluated << ");\n"; +// new_function << " if (!__dredd_some_mutation_enabled) return " +// << arg_evaluated << ";\n"; } int mutation_id_offset = 0; - GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, optimise_mutations, + GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, mutation_id_offset, protobuf_message); GenerateConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, mutation_id, + ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, mutation_id_offset, protobuf_message); if (only_track_mutant_coverage) { @@ -478,7 +535,8 @@ std::string MutationReplaceExpr::GenerateMutatorFunction( std::to_string(mutation_id_offset) + ");\n"; } - new_function << " return " << arg_evaluated << ";\n"; +// new_function << " return " << arg_evaluated << ";\n"; + new_function << " return MUTATION_RESULT(" << arg_evaluated << ");\n"; new_function << "}\n\n"; mutation_id += mutation_id_offset; @@ -602,7 +660,6 @@ protobufs::MutationGroup MutationReplaceExpr::Apply( // MutationGroup. protobufs::MutationReplaceExpr inner_result; - (void)dredd_macros; inner_result.mutable_start()->set_line(info_for_source_range_.GetStartLine()); inner_result.mutable_start()->set_column( info_for_source_range_.GetStartColumn()); @@ -636,7 +693,7 @@ protobufs::MutationGroup MutationReplaceExpr::Apply( ast_context, preprocessor, rewriter); const std::string new_function = GenerateMutatorFunction( - ast_context, new_function_name, result_type, input_type, + ast_context, dredd_macros, new_function_name, result_type, input_type, optimise_mutations, only_track_mutant_coverage, mutation_id, inner_result); assert(!new_function.empty() && "Unsupported expression."); diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index 6c9353d2..35850931 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -207,18 +207,19 @@ std::string MutationReplaceUnaryOperator::GenerateMutatorFunction( if (!only_track_mutant_coverage) { // Quickly apply the original operator if no mutant is enabled (which will // be the common case). - new_function << " if (!__dredd_some_mutation_enabled) return "; +// new_function << " if (!__dredd_some_mutation_enabled) return "; + new_function << " MUTATION_PRELUDE("; if (IsPrefix(unary_operator_->getOpcode())) { new_function << clang::UnaryOperator::getOpcodeStr( unary_operator_->getOpcode()) .str() - << arg_evaluated + ";\n"; + << arg_evaluated + ");\n"; } else { new_function << arg_evaluated << clang::UnaryOperator::getOpcodeStr( unary_operator_->getOpcode()) .str() - << ";\n"; + << ");\n"; } } @@ -235,11 +236,11 @@ std::string MutationReplaceUnaryOperator::GenerateMutatorFunction( const std::string opcode_string = clang::UnaryOperator::getOpcodeStr(unary_operator_->getOpcode()).str(); - new_function << " return " + new_function << " return MUTATION_RESULT(" << (IsPrefix(unary_operator_->getOpcode()) ? opcode_string : "") << arg_evaluated << (IsPrefix(unary_operator_->getOpcode()) ? "" : opcode_string) - << ";\n"; + << ");\n"; new_function << "}\n\n"; @@ -304,15 +305,16 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( continue; } if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset << ")) return "; + new_function << " MUTATION(" << mutation_id_offset << ", "; +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset << ")) return "; if (IsPrefix(operator_kind)) { new_function << clang::UnaryOperator::getOpcodeStr(operator_kind).str() << arg_evaluated + ";\n"; } else { new_function << arg_evaluated << clang::UnaryOperator::getOpcodeStr(operator_kind).str() - << ";\n"; + << ");\n"; } } AddMutationInstance(mutation_id_base, OperatorKindToAction(operator_kind), @@ -324,9 +326,10 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( // another mutation. if (!optimise_mutations || !IsOperatorSelfInverse()) { if (!only_track_mutant_coverage) { - new_function << " if (__dredd_enabled_mutation(local_mutation_id + " - << mutation_id_offset - << ")) return " + arg_evaluated + ";\n"; + new_function << " MUTATION(" << mutation_id_offset << ", " << arg_evaluated << ");\n"; +// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " +// << mutation_id_offset +// << ")) return " + arg_evaluated + ";\n"; } AddMutationInstance( mutation_id_base, diff --git a/src/libdredd/src/util.cc b/src/libdredd/src/util.cc index c1e6c666..53591ddc 100644 --- a/src/libdredd/src/util.cc +++ b/src/libdredd/src/util.cc @@ -129,12 +129,4 @@ bool IsCxx11ConstantExpr(const clang::Expr& expr, return !expr.isValueDependent() && expr.isCXX11ConstantExpr(ast_context); } -std::string GenerateMutatorMacro(const std::string& name, - const std::string& args_evaluated) { - return "#define " + name + - "(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id " - "+ mutation_id_offset)) return " + - args_evaluated + "\n"; -} - } // namespace dredd From 38f8a9f06ccf2f8ad916c179407831c753d0ef04 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 17:16:38 +0000 Subject: [PATCH 03/15] Formatting --- .../include/libdredd/mutation_replace_expr.h | 37 ++- src/libdredd/src/mutate_ast_consumer.cc | 25 +- .../src/mutation_replace_binary_operator.cc | 59 +++-- src/libdredd/src/mutation_replace_expr.cc | 245 ++++++++++-------- .../src/mutation_replace_unary_operator.cc | 17 +- 5 files changed, 208 insertions(+), 175 deletions(-) diff --git a/src/libdredd/include/libdredd/mutation_replace_expr.h b/src/libdredd/include/libdredd/mutation_replace_expr.h index 6d67d85c..d14a9574 100644 --- a/src/libdredd/include/libdredd/mutation_replace_expr.h +++ b/src/libdredd/include/libdredd/mutation_replace_expr.h @@ -96,32 +96,28 @@ class MutationReplaceExpr : public Mutation { // Replace expressions with constants. void GenerateConstantReplacement( clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateBooleanConstantReplacement( clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateIntegerConstantReplacement( const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateFloatConstantReplacement( const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; @@ -129,18 +125,16 @@ class MutationReplaceExpr : public Mutation { // Insert valid unary operators such as !, ~, ++ and --. void GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateUnaryOperatorInsertionBeforeLValue( @@ -151,11 +145,12 @@ class MutationReplaceExpr : public Mutation { protobufs::MutationReplaceExpr& protobuf_message) const; std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, std::unordered_set& dredd_macros, - const std::string& function_name, - const std::string& result_type, const std::string& input_type, - bool optimise_mutations, bool only_track_mutant_coverage, - int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const; + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& input_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, + protobufs::MutationReplaceExpr& protobuf_message) const; [[nodiscard]] std::string GetFunctionName( bool optimise_mutations, clang::ASTContext& ast_context) const; diff --git a/src/libdredd/src/mutate_ast_consumer.cc b/src/libdredd/src/mutate_ast_consumer.cc index 9a2894d9..792e2c71 100644 --- a/src/libdredd/src/mutate_ast_consumer.cc +++ b/src/libdredd/src/mutate_ast_consumer.cc @@ -112,18 +112,18 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Rewrite failed.\n"); } - (void) dredd_macros; + (void)dredd_macros; rewriter_.InsertTextBefore(start_of_source_file, GetMutationPreludeMacro()); rewriter_.InsertTextBefore(start_of_source_file, GetMutationMacro()); rewriter_.InsertTextBefore(start_of_source_file, GetMutationResultMacro()); -// std::set sorted_dredd_macros; -// sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); -// for (const auto& macro : sorted_dredd_macros) { -// const bool rewriter_result = -// rewriter_.InsertTextBefore(start_of_source_file, macro); -// (void)rewriter_result; // Keep release-mode compilers happy. -// assert(!rewriter_result && "Rewrite failed.\n"); -// } + // std::set sorted_dredd_macros; + // sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); + // for (const auto& macro : sorted_dredd_macros) { + // const bool rewriter_result = + // rewriter_.InsertTextBefore(start_of_source_file, macro); + // (void)rewriter_result; // Keep release-mode compilers happy. + // assert(!rewriter_result && "Rewrite failed.\n"); + // } const std::string dredd_prelude = compiler_instance_->getLangOpts().CPlusPlus @@ -141,11 +141,14 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { } std::string MutateAstConsumer::GetMutationMacro() const { - return "#define MUTATION(mutation_id_offset, arg) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg\n\n"; + return "#define MUTATION(mutation_id_offset, arg) if " + "(__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) " + "return arg\n\n"; } std::string MutateAstConsumer::GetMutationPreludeMacro() const { - return "#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg\n\n"; + return "#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) " + "return arg\n\n"; } std::string MutateAstConsumer::GetMutationResultMacro() const { diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index 083fa959..5a097b5f 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -238,7 +238,7 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { - (void) dredd_macros; + (void)dredd_macros; if (optimise_mutations) { switch (binary_operator_->getOpcode()) { case clang::BO_GT: @@ -282,10 +282,11 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( *binary_operator_->getLHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { // TODO(JamesLee-Jones): Replace with arg replacement macro. -// const std::string macro_name = "REPLACE_BINARY_ARG1"; - new_function << " MUTATION(" << mutation_id_offset << ", " << arg1_evaluated << ");\n"; -// dredd_macros.insert( -// GenerateArgumentReplacementMacro(macro_name, arg1_evaluated)); + // const std::string macro_name = "REPLACE_BINARY_ARG1"; + new_function << " MUTATION(" << mutation_id_offset << ", " + << arg1_evaluated << ");\n"; + // dredd_macros.insert( + // GenerateArgumentReplacementMacro(macro_name, arg1_evaluated)); // new_function << " if (__dredd_enabled_mutation(local_mutation_id // + " // << mutation_id_offset << ")) return " << @@ -315,10 +316,11 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getRHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_BINARY_ARG2"; - new_function << " MUTATION(" << mutation_id_offset << ", " << arg2_evaluated << ");\n"; -// dredd_macros.insert( -// GenerateArgumentReplacementMacro(macro_name, arg2_evaluated)); + // const std::string macro_name = "REPLACE_BINARY_ARG2"; + new_function << " MUTATION(" << mutation_id_offset << ", " + << arg2_evaluated << ");\n"; + // dredd_macros.insert( + // GenerateArgumentReplacementMacro(macro_name, arg2_evaluated)); // new_function << " if (__dredd_enabled_mutation(local_mutation_id // + " // << mutation_id_offset << ")) return " << @@ -339,16 +341,20 @@ void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { - (void) dredd_macros; + (void)dredd_macros; for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { // TODO(JamesLee-Jones): Replace with replacement macro. -// const std::string macro_name = "REPLACE_" + OpKindToString(operator_kind); - new_function << " MUTATION(" << mutation_id_offset << ", " << arg1_evaluated << clang::BinaryOperator::getOpcodeStr(operator_kind).str() << arg2_evaluated << ");\n"; - -// dredd_macros.insert(GenerateBinaryOperatorMacro( -// macro_name, arg1_evaluated, operator_kind, arg2_evaluated)); + // const std::string macro_name = "REPLACE_" + + // OpKindToString(operator_kind); + new_function << " MUTATION(" << mutation_id_offset << ", " + << arg1_evaluated + << clang::BinaryOperator::getOpcodeStr(operator_kind).str() + << arg2_evaluated << ");\n"; + + // dredd_macros.insert(GenerateBinaryOperatorMacro( + // macro_name, arg1_evaluated, operator_kind, arg2_evaluated)); // new_function << " if (__dredd_enabled_mutation(local_mutation_id // + " // << mutation_id_offset << ")) return " << @@ -488,18 +494,17 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( // Quickly apply the original operator if no mutant is enabled (which will // be the common case). // TODO(JamesLee-Jones): Replace with pre-processing macro. - new_function << " MUTATION_PRELUDE(" - << arg1_evaluated << " " - << clang::BinaryOperator::getOpcodeStr( - binary_operator_->getOpcode()) - .str() - << " " << arg2_evaluated << ");\n"; -// new_function << " if (!__dredd_some_mutation_enabled) return " -// << arg1_evaluated << " " -// << clang::BinaryOperator::getOpcodeStr( -// binary_operator_->getOpcode()) -// .str() -// << " " << arg2_evaluated << ";\n"; + new_function << " MUTATION_PRELUDE(" << arg1_evaluated << " " + << clang::BinaryOperator::getOpcodeStr( + binary_operator_->getOpcode()) + .str() + << " " << arg2_evaluated << ");\n"; + // new_function << " if (!__dredd_some_mutation_enabled) return " + // << arg1_evaluated << " " + // << clang::BinaryOperator::getOpcodeStr( + // binary_operator_->getOpcode()) + // .str() + // << " " << arg2_evaluated << ";\n"; } GenerateBinaryOperatorReplacement( diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 8715e621..7e8d0cca 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -183,29 +183,33 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void) dredd_macros; + (void)dredd_macros; if (!expr_->isLValue() || !CanMutateLValue(ast_context, *expr_)) { return; } if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_INC"; - new_function << " MUTATION(" << mutation_id_offset << ", ++(" << arg_evaluated << "));\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "++(" + arg_evaluated +")")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return ++(" << arg_evaluated -// << ");\n"; + // const std::string macro_name = "REPLACE_EXPR_INC"; + new_function << " MUTATION(" << mutation_id_offset << ", ++(" + << arg_evaluated << "));\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "++(" + + // arg_evaluated +")")); new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return ++(" << arg_evaluated + // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreInc, mutation_id_offset, protobuf_message); if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_DEC"; - new_function << " MUTATION(" << mutation_id_offset << ", --(" << arg_evaluated <<"));\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "--(" + arg_evaluated +")")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return --(" << arg_evaluated -// << ");\n"; + // const std::string macro_name = "REPLACE_EXPR_DEC"; + new_function << " MUTATION(" << mutation_id_offset << ", --(" + << arg_evaluated << "));\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "--(" + + // arg_evaluated +")")); new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return --(" << arg_evaluated + // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreDec, @@ -214,12 +218,11 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void) dredd_macros; + (void)dredd_macros; if (expr_->isLValue()) { return; } @@ -230,12 +233,15 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_LNOT"; - new_function << " MUTATION(" << mutation_id_offset << ", !(" << arg_evaluated << "));\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "!(" + arg_evaluated +")")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return !(" << arg_evaluated -// << ");\n"; + // const std::string macro_name = "REPLACE_EXPR_LNOT"; + new_function << " MUTATION(" << mutation_id_offset << ", !(" + << arg_evaluated << "));\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "!(" + + // arg_evaluated +")")); new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return !(" << + // arg_evaluated + // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertLNot, @@ -248,12 +254,15 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_NOT"; - new_function << " MUTATION(" << mutation_id_offset << ", ~(" << arg_evaluated << "));\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "~(" + arg_evaluated +")")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return ~(" << arg_evaluated -// << ");\n"; + // const std::string macro_name = "REPLACE_EXPR_NOT"; + new_function << " MUTATION(" << mutation_id_offset << ", ~(" + << arg_evaluated << "));\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "~(" + + // arg_evaluated +")")); new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return ~(" << + // arg_evaluated + // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertNot, @@ -266,12 +275,15 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_MINUS"; - new_function << " MUTATION(" << mutation_id_offset << ", -(" << arg_evaluated << "));\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "-(" + arg_evaluated +")")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return -(" << arg_evaluated -// << ");\n"; + // const std::string macro_name = "REPLACE_EXPR_MINUS"; + new_function << " MUTATION(" << mutation_id_offset << ", -(" + << arg_evaluated << "));\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "-(" + + // arg_evaluated +")")); new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return -(" << + // arg_evaluated + // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertMinus, @@ -282,14 +294,13 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { GenerateUnaryOperatorInsertionBeforeLValue( - arg_evaluated, ast_context, dredd_macros, only_track_mutant_coverage, mutation_id_base, - new_function, mutation_id_offset, protobuf_message); + arg_evaluated, ast_context, dredd_macros, only_track_mutant_coverage, + mutation_id_base, new_function, mutation_id_offset, protobuf_message); GenerateUnaryOperatorInsertionBeforeNonLValue( arg_evaluated, ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id_base, new_function, @@ -298,32 +309,33 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertion( void MutationReplaceExpr::GenerateConstantReplacement( clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { if (!expr_->isLValue()) { GenerateBooleanConstantReplacement( - ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, - mutation_id_base, new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, + only_track_mutant_coverage, mutation_id_base, new_function, + mutation_id_offset, protobuf_message); GenerateIntegerConstantReplacement( - ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, - mutation_id_base, new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, + only_track_mutant_coverage, mutation_id_base, new_function, + mutation_id_offset, protobuf_message); GenerateFloatConstantReplacement( - ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, - mutation_id_base, new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, + only_track_mutant_coverage, mutation_id_base, new_function, + mutation_id_offset, protobuf_message); } } void MutationReplaceExpr::GenerateFloatConstantReplacement( const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void) dredd_macros; + (void)dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isFloatingPoint()) { @@ -331,11 +343,12 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 0.0, ast_context)) { // Replace floating point expression with 0.0 if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; + // const std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; new_function << " MUTATION(" << mutation_id_offset << ", 0.0);\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "0.0")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return 0.0;\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "0.0")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return 0.0;\n"; } AddMutationInstance( mutation_id_base, @@ -347,11 +360,12 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 1.0, ast_context)) { // Replace floating point expression with 1.0 if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; + // const std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", 1.0);\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "1.0")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return 1.0;\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "1.0")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return 1.0;\n"; } AddMutationInstance( mutation_id_base, @@ -363,11 +377,12 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, -1.0, ast_context)) { // Replace floating point expression with -1.0 if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; + // const std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", -1.0);\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1.0")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return -1.0;\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1.0")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return -1.0;\n"; } AddMutationInstance( mutation_id_base, @@ -378,23 +393,23 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( } void MutationReplaceExpr::GenerateIntegerConstantReplacement( const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void) dredd_macros; + (void)dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isInteger() && !exprType.isBooleanType()) { if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 0, ast_context)) { // Replace expression with 0 if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_INT_ZERO"; + // const std::string macro_name = "REPLACE_EXPR_INT_ZERO"; new_function << " MUTATION(" << mutation_id_offset << ", 0);\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "0")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return 0;\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "0")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return 0;\n"; } AddMutationInstance( mutation_id_base, @@ -405,11 +420,12 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 1, ast_context)) { // Replace expression with 1 if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_INT_ONE"; + // const std::string macro_name = "REPLACE_EXPR_INT_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", 1);\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "1")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return 1;\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "1")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return 1;\n"; } AddMutationInstance( mutation_id_base, @@ -423,11 +439,12 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( !ExprIsEquivalentToInt(*expr_, -1, ast_context)) { // Replace signed integer expression with -1 if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; + // const std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", -1);\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return -1;\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return -1;\n"; } AddMutationInstance( mutation_id_base, @@ -438,12 +455,11 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( } void MutationReplaceExpr::GenerateBooleanConstantReplacement( clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - bool optimise_mutations, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void) dredd_macros; + (void)dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isBooleanType()) { @@ -452,13 +468,18 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(true, ast_context))) { // Replace expression with true if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_TRUE"; - new_function << " MUTATION(" << mutation_id_offset << ", " << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") << ");\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, ast_context.getLangOpts().CPlusPlus ? "true" : "1")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return " -// << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") -// << ";\n"; + // const std::string macro_name = "REPLACE_EXPR_TRUE"; + new_function << " MUTATION(" << mutation_id_offset << ", " + << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") + << ");\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, + // ast_context.getLangOpts().CPlusPlus ? "true" : "1")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return " + // << (ast_context.getLangOpts().CPlusPlus ? "true" + // : "1") + // << ";\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::ReplaceWithTrue, @@ -470,13 +491,18 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(false, ast_context))) { // Replace expression with false if (!only_track_mutant_coverage) { -// const std::string macro_name = "REPLACE_EXPR_FALSE"; - new_function << " MUTATION(" << mutation_id_offset << ", " << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") << ");\n"; -// dredd_macros.insert(GenerateMutatorMacro(macro_name, ast_context.getLangOpts().CPlusPlus ? "false" : "0")); -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return " -// << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") -// << ";\n"; + // const std::string macro_name = "REPLACE_EXPR_FALSE"; + new_function << " MUTATION(" << mutation_id_offset << ", " + << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") + << ");\n"; + // dredd_macros.insert(GenerateMutatorMacro(macro_name, + // ast_context.getLangOpts().CPlusPlus ? "false" : "0")); + // new_function << " if + // (__dredd_enabled_mutation(local_mutation_id + " + // << mutation_id_offset << ")) return " + // << (ast_context.getLangOpts().CPlusPlus ? "false" + // : "0") + // << ";\n"; } AddMutationInstance( mutation_id_base, @@ -487,10 +513,11 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( } std::string MutationReplaceExpr::GenerateMutatorFunction( - clang::ASTContext& ast_context, std::unordered_set& dredd_macros, - const std::string& function_name, - const std::string& result_type, const std::string& input_type, - bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& input_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const { std::stringstream new_function; new_function << "static " << result_type << " " << function_name << "("; @@ -516,26 +543,26 @@ std::string MutationReplaceExpr::GenerateMutatorFunction( // Quickly apply the original operator if no mutant is enabled (which will // be the common case). new_function << " MUTATION_PRELUDE(" << arg_evaluated << ");\n"; -// new_function << " if (!__dredd_some_mutation_enabled) return " -// << arg_evaluated << ";\n"; + // new_function << " if (!__dredd_some_mutation_enabled) return " + // << arg_evaluated << ";\n"; } int mutation_id_offset = 0; - GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, dredd_macros, optimise_mutations, - only_track_mutant_coverage, mutation_id, - new_function, mutation_id_offset, + GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, dredd_macros, + optimise_mutations, only_track_mutant_coverage, + mutation_id, new_function, mutation_id_offset, protobuf_message); GenerateConstantReplacement( - ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id, - new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, + mutation_id, new_function, mutation_id_offset, protobuf_message); if (only_track_mutant_coverage) { new_function << " __dredd_record_covered_mutants(local_mutation_id, " + std::to_string(mutation_id_offset) + ");\n"; } -// new_function << " return " << arg_evaluated << ";\n"; + // new_function << " return " << arg_evaluated << ";\n"; new_function << " return MUTATION_RESULT(" << arg_evaluated << ");\n"; new_function << "}\n\n"; diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index 35850931..7e850049 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -207,7 +207,7 @@ std::string MutationReplaceUnaryOperator::GenerateMutatorFunction( if (!only_track_mutant_coverage) { // Quickly apply the original operator if no mutant is enabled (which will // be the common case). -// new_function << " if (!__dredd_some_mutation_enabled) return "; + // new_function << " if (!__dredd_some_mutation_enabled) return "; new_function << " MUTATION_PRELUDE("; if (IsPrefix(unary_operator_->getOpcode())) { new_function << clang::UnaryOperator::getOpcodeStr( @@ -306,8 +306,9 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( } if (!only_track_mutant_coverage) { new_function << " MUTATION(" << mutation_id_offset << ", "; -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset << ")) return "; + // new_function << " if (__dredd_enabled_mutation(local_mutation_id + // + " + // << mutation_id_offset << ")) return "; if (IsPrefix(operator_kind)) { new_function << clang::UnaryOperator::getOpcodeStr(operator_kind).str() << arg_evaluated + ";\n"; @@ -326,10 +327,12 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( // another mutation. if (!optimise_mutations || !IsOperatorSelfInverse()) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", " << arg_evaluated << ");\n"; -// new_function << " if (__dredd_enabled_mutation(local_mutation_id + " -// << mutation_id_offset -// << ")) return " + arg_evaluated + ";\n"; + new_function << " MUTATION(" << mutation_id_offset << ", " + << arg_evaluated << ");\n"; + // new_function << " if (__dredd_enabled_mutation(local_mutation_id + // + " + // << mutation_id_offset + // << ")) return " + arg_evaluated + ";\n"; } AddMutationInstance( mutation_id_base, From 1a3f8414c4048f27aba06989ebe8f2a19adb48f2 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 17:38:15 +0000 Subject: [PATCH 04/15] Tidy up --- src/libdredd/include/libdredd/mutation.h | 3 +- .../include/libdredd/mutation_remove_stmt.h | 3 +- .../mutation_replace_binary_operator.h | 19 +-- .../include/libdredd/mutation_replace_expr.h | 38 ++--- .../mutation_replace_unary_operator.h | 3 +- .../include/libdredd/mutate_ast_consumer.h | 9 +- src/libdredd/src/mutate_ast_consumer.cc | 27 +-- src/libdredd/src/mutation_remove_stmt.cc | 4 +- .../src/mutation_replace_binary_operator.cc | 76 ++------- src/libdredd/src/mutation_replace_expr.cc | 157 ++++-------------- .../src/mutation_replace_unary_operator.cc | 12 +- .../src/mutation_remove_stmt_test.cc | 3 +- .../mutation_replace_binary_operator_test.cc | 3 +- .../src/mutation_replace_expr_test.cc | 4 +- .../mutation_replace_unary_operator_test.cc | 3 +- 15 files changed, 88 insertions(+), 276 deletions(-) diff --git a/src/libdredd/include/libdredd/mutation.h b/src/libdredd/include/libdredd/mutation.h index ac8fee9a..56c93438 100644 --- a/src/libdredd/include/libdredd/mutation.h +++ b/src/libdredd/include/libdredd/mutation.h @@ -53,8 +53,7 @@ class Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const = 0; + std::unordered_set& dredd_declarations) const = 0; }; } // namespace dredd diff --git a/src/libdredd/include/libdredd/mutation_remove_stmt.h b/src/libdredd/include/libdredd/mutation_remove_stmt.h index db915e14..b0f0f8ad 100644 --- a/src/libdredd/include/libdredd/mutation_remove_stmt.h +++ b/src/libdredd/include/libdredd/mutation_remove_stmt.h @@ -40,8 +40,7 @@ class MutationRemoveStmt : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const override; + std::unordered_set& dredd_declarations) const override; private: // Helper method to determine whether the token immediately following the diff --git a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h index 7a67cc58..84d962cd 100644 --- a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h @@ -42,17 +42,14 @@ class MutationReplaceBinaryOperator : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const override; + std::unordered_set& dredd_declarations) const override; private: std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - const std::string& function_name, const std::string& result_type, - const std::string& lhs_type, const std::string& rhs_type, - bool optimise_mutations, bool only_track_mutant_coverage, - int& mutation_id, + clang::ASTContext& ast_context, const std::string& function_name, + const std::string& result_type, const std::string& lhs_type, + const std::string& rhs_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; void ReplaceOperator(const std::string& lhs_type, const std::string& rhs_type, @@ -87,8 +84,7 @@ class MutationReplaceBinaryOperator : public Mutation { // Replaces binary expressions with either the left or right operand. void GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; @@ -101,8 +97,7 @@ class MutationReplaceBinaryOperator : public Mutation { // Replaces binary operators with other valid binary operators. void GenerateBinaryOperatorReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; diff --git a/src/libdredd/include/libdredd/mutation_replace_expr.h b/src/libdredd/include/libdredd/mutation_replace_expr.h index d14a9574..fee39226 100644 --- a/src/libdredd/include/libdredd/mutation_replace_expr.h +++ b/src/libdredd/include/libdredd/mutation_replace_expr.h @@ -41,8 +41,7 @@ class MutationReplaceExpr : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const override; + std::unordered_set& dredd_declarations) const override; static void ApplyCppTypeModifiers(const clang::Expr& expr, std::string& type); @@ -95,29 +94,25 @@ class MutationReplaceExpr : public Mutation { // Replace expressions with constants. void GenerateConstantReplacement( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateBooleanConstantReplacement( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateIntegerConstantReplacement( - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateFloatConstantReplacement( - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; @@ -125,32 +120,29 @@ class MutationReplaceExpr : public Mutation { // Insert valid unary operators such as !, ~, ++ and --. void GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, - bool only_track_mutant_coverage, int mutation_id_base, - std::stringstream& new_function, int& mutation_id_offset, + bool optimise_mutations, bool only_track_mutant_coverage, + int mutation_id_base, std::stringstream& new_function, + int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, - bool only_track_mutant_coverage, int mutation_id_base, - std::stringstream& new_function, int& mutation_id_offset, + bool optimise_mutations, bool only_track_mutant_coverage, + int mutation_id_base, std::stringstream& new_function, + int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateUnaryOperatorInsertionBeforeLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - const std::string& function_name, const std::string& result_type, - const std::string& input_type, bool optimise_mutations, - bool only_track_mutant_coverage, int& mutation_id, - protobufs::MutationReplaceExpr& protobuf_message) const; + clang::ASTContext& ast_context, const std::string& function_name, + const std::string& result_type, const std::string& input_type, + bool optimise_mutations, bool only_track_mutant_coverage, + int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const; [[nodiscard]] std::string GetFunctionName( bool optimise_mutations, clang::ASTContext& ast_context) const; diff --git a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h index a7c0aafb..24c6f621 100644 --- a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h @@ -41,8 +41,7 @@ class MutationReplaceUnaryOperator : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const override; + std::unordered_set& dredd_declarations) const override; private: std::string GenerateMutatorFunction( diff --git a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h index c2d30aef..09df536e 100644 --- a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h +++ b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h @@ -47,11 +47,11 @@ class MutateAstConsumer : public clang::ASTConsumer { void HandleTranslationUnit(clang::ASTContext& ast_context) override; private: - std::string GetMutationMacro() const; + static std::string GetMutationMacro(); - std::string GetMutationPreludeMacro() const; + static std::string GetMutationPreludeMacro(); - std::string GetMutationResultMacro() const; + static std::string GetMutationResultMacro(); [[nodiscard]] std::string GetDreddPreludeCpp(int initial_mutation_id) const; @@ -72,8 +72,7 @@ class MutateAstConsumer : public clang::ASTConsumer { protobufs::MutationTreeNode ApplyMutations( const MutationTreeNode& mutation_tree_node, int initial_mutation_id, clang::ASTContext& context, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros); + std::unordered_set& dredd_declarations); const clang::CompilerInstance* compiler_instance_; diff --git a/src/libdredd/src/mutate_ast_consumer.cc b/src/libdredd/src/mutate_ast_consumer.cc index 792e2c71..f7dfbf8c 100644 --- a/src/libdredd/src/mutate_ast_consumer.cc +++ b/src/libdredd/src/mutate_ast_consumer.cc @@ -74,7 +74,6 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { // converted to an ordered set so that declarations can be added to the source // file in a deterministic order. std::unordered_set dredd_declarations; - std::unordered_set dredd_macros; protobufs::MutationInfoForFile mutation_info_for_file; mutation_info_for_file.set_filename( @@ -84,7 +83,7 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { .str()); *mutation_info_for_file.mutable_mutation_tree_root() = ApplyMutations(visitor_->GetMutations(), initial_mutation_id, ast_context, - dredd_declarations, dredd_macros); + dredd_declarations); if (initial_mutation_id == *mutation_id_) { // No possibilities for mutation were found; nothing else to do. @@ -112,18 +111,9 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Rewrite failed.\n"); } - (void)dredd_macros; rewriter_.InsertTextBefore(start_of_source_file, GetMutationPreludeMacro()); rewriter_.InsertTextBefore(start_of_source_file, GetMutationMacro()); rewriter_.InsertTextBefore(start_of_source_file, GetMutationResultMacro()); - // std::set sorted_dredd_macros; - // sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); - // for (const auto& macro : sorted_dredd_macros) { - // const bool rewriter_result = - // rewriter_.InsertTextBefore(start_of_source_file, macro); - // (void)rewriter_result; // Keep release-mode compilers happy. - // assert(!rewriter_result && "Rewrite failed.\n"); - // } const std::string dredd_prelude = compiler_instance_->getLangOpts().CPlusPlus @@ -140,18 +130,18 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Something went wrong emitting rewritten files."); } -std::string MutateAstConsumer::GetMutationMacro() const { +std::string MutateAstConsumer::GetMutationMacro() { return "#define MUTATION(mutation_id_offset, arg) if " "(__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) " "return arg\n\n"; } -std::string MutateAstConsumer::GetMutationPreludeMacro() const { +std::string MutateAstConsumer::GetMutationPreludeMacro() { return "#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) " "return arg\n\n"; } -std::string MutateAstConsumer::GetMutationResultMacro() const { +std::string MutateAstConsumer::GetMutationResultMacro() { return "#define MUTATION_RESULT(arg) arg\n\n"; } @@ -390,8 +380,7 @@ std::string MutateAstConsumer::GetDreddPreludeC(int initial_mutation_id) const { protobufs::MutationTreeNode MutateAstConsumer::ApplyMutations( const MutationTreeNode& mutation_tree_node, int initial_mutation_id, clang::ASTContext& context, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) { + std::unordered_set& dredd_declarations) { assert(!(mutation_tree_node.IsEmpty() && mutation_tree_node.GetChildren().size() == 1) && "The mutation tree should already be compressed."); @@ -399,15 +388,15 @@ protobufs::MutationTreeNode MutateAstConsumer::ApplyMutations( for (const auto& child : mutation_tree_node.GetChildren()) { assert(!child->IsEmpty() && "The mutation tree should not have empty subtrees."); - *result.add_children() = ApplyMutations( - *child, initial_mutation_id, context, dredd_declarations, dredd_macros); + *result.add_children() = ApplyMutations(*child, initial_mutation_id, + context, dredd_declarations); } for (const auto& mutation : mutation_tree_node.GetMutations()) { const int mutation_id_old = *mutation_id_; const auto mutation_group = mutation->Apply( context, compiler_instance_->getPreprocessor(), optimise_mutations_, only_track_mutant_coverage_, initial_mutation_id, *mutation_id_, - rewriter_, dredd_declarations, dredd_macros); + rewriter_, dredd_declarations); if (*mutation_id_ > mutation_id_old) { // Only add the result of applying the mutation if it had an effect. *result.add_mutation_groups() = mutation_group; diff --git a/src/libdredd/src/mutation_remove_stmt.cc b/src/libdredd/src/mutation_remove_stmt.cc index d5bc0e47..344f990b 100644 --- a/src/libdredd/src/mutation_remove_stmt.cc +++ b/src/libdredd/src/mutation_remove_stmt.cc @@ -42,10 +42,8 @@ protobufs::MutationGroup MutationRemoveStmt::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const { + std::unordered_set& dredd_declarations) const { (void)dredd_declarations; // Unused. - (void)dredd_macros; // Unused. (void)optimise_mutations; // Unused. // The protobuf object for the mutation, which will be wrapped in a diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index 5a097b5f..61cfe9af 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -233,12 +233,10 @@ std::string MutationReplaceBinaryOperator::GetFunctionName( void MutationReplaceBinaryOperator::GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { - (void)dredd_macros; if (optimise_mutations) { switch (binary_operator_->getOpcode()) { case clang::BO_GT: @@ -281,17 +279,8 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getLHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - // TODO(JamesLee-Jones): Replace with arg replacement macro. - // const std::string macro_name = "REPLACE_BINARY_ARG1"; new_function << " MUTATION(" << mutation_id_offset << ", " << arg1_evaluated << ");\n"; - // dredd_macros.insert( - // GenerateArgumentReplacementMacro(macro_name, arg1_evaluated)); - // new_function << " if (__dredd_enabled_mutation(local_mutation_id - // + " - // << mutation_id_offset << ")) return " << - // arg1_evaluated - // << ";\n"; } AddMutationInstance( mutation_id_base, @@ -316,16 +305,8 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getRHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_BINARY_ARG2"; new_function << " MUTATION(" << mutation_id_offset << ", " << arg2_evaluated << ");\n"; - // dredd_macros.insert( - // GenerateArgumentReplacementMacro(macro_name, arg2_evaluated)); - // new_function << " if (__dredd_enabled_mutation(local_mutation_id - // + " - // << mutation_id_offset << ")) return " << - // arg2_evaluated - // << ";\n"; } AddMutationInstance( mutation_id_base, @@ -336,33 +317,17 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { - (void)dredd_macros; for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { - // TODO(JamesLee-Jones): Replace with replacement macro. - // const std::string macro_name = "REPLACE_" + - // OpKindToString(operator_kind); new_function << " MUTATION(" << mutation_id_offset << ", " << arg1_evaluated << clang::BinaryOperator::getOpcodeStr(operator_kind).str() << arg2_evaluated << ");\n"; - - // dredd_macros.insert(GenerateBinaryOperatorMacro( - // macro_name, arg1_evaluated, operator_kind, arg2_evaluated)); - // new_function << " if (__dredd_enabled_mutation(local_mutation_id - // + " - // << mutation_id_offset << ")) return " << - // arg1_evaluated - // << " " - // << - // clang::BinaryOperator::getOpcodeStr(operator_kind).str() - // << " " << arg2_evaluated << ";\n"; } AddMutationInstance(mutation_id_base, OperatorKindToAction(operator_kind), mutation_id_offset, protobuf_message); @@ -444,11 +409,10 @@ MutationReplaceBinaryOperator::GetReplacementOperators( } std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - const std::string& function_name, const std::string& result_type, - const std::string& lhs_type, const std::string& rhs_type, - bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, const std::string& function_name, + const std::string& result_type, const std::string& lhs_type, + const std::string& rhs_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { std::stringstream new_function; new_function << "static " << result_type << " " << function_name << "("; @@ -493,28 +457,21 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( if (!only_track_mutant_coverage) { // Quickly apply the original operator if no mutant is enabled (which will // be the common case). - // TODO(JamesLee-Jones): Replace with pre-processing macro. new_function << " MUTATION_PRELUDE(" << arg1_evaluated << " " << clang::BinaryOperator::getOpcodeStr( binary_operator_->getOpcode()) .str() << " " << arg2_evaluated << ");\n"; - // new_function << " if (!__dredd_some_mutation_enabled) return " - // << arg1_evaluated << " " - // << clang::BinaryOperator::getOpcodeStr( - // binary_operator_->getOpcode()) - // .str() - // << " " << arg2_evaluated << ";\n"; } GenerateBinaryOperatorReplacement( - arg1_evaluated, arg2_evaluated, ast_context, dredd_macros, - optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, - mutation_id_offset, protobuf_message); - GenerateArgumentReplacement( - arg1_evaluated, arg2_evaluated, ast_context, dredd_macros, - optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, - mutation_id_offset, protobuf_message); + arg1_evaluated, arg2_evaluated, ast_context, optimise_mutations, + only_track_mutant_coverage, mutation_id, new_function, mutation_id_offset, + protobuf_message); + GenerateArgumentReplacement(arg1_evaluated, arg2_evaluated, ast_context, + optimise_mutations, only_track_mutant_coverage, + mutation_id, new_function, mutation_id_offset, + protobuf_message); if (only_track_mutant_coverage) { new_function << " __dredd_record_covered_mutants(local_mutation_id, " + @@ -540,8 +497,7 @@ protobufs::MutationGroup MutationReplaceBinaryOperator::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const { + std::unordered_set& dredd_declarations) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceBinaryOperator inner_result; @@ -627,8 +583,8 @@ protobufs::MutationGroup MutationReplaceBinaryOperator::Apply( rewriter); const std::string new_function = GenerateMutatorFunction( - ast_context, dredd_macros, new_function_name, result_type, lhs_type, - rhs_type, optimise_mutations, only_track_mutant_coverage, mutation_id, + ast_context, new_function_name, result_type, lhs_type, rhs_type, + optimise_mutations, only_track_mutant_coverage, mutation_id, inner_result); assert(!new_function.empty() && "Unsupported opcode."); diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 7e8d0cca..84b84cff 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -179,37 +179,23 @@ bool MutationReplaceExpr::IsRedundantOperatorInsertion( void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void)dredd_macros; if (!expr_->isLValue() || !CanMutateLValue(ast_context, *expr_)) { return; } if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_INC"; new_function << " MUTATION(" << mutation_id_offset << ", ++(" << arg_evaluated << "));\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "++(" + - // arg_evaluated +")")); new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return ++(" << arg_evaluated - // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreInc, mutation_id_offset, protobuf_message); if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_DEC"; new_function << " MUTATION(" << mutation_id_offset << ", --(" << arg_evaluated << "));\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "--(" + - // arg_evaluated +")")); new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return --(" << arg_evaluated - // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreDec, @@ -218,11 +204,10 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, - bool only_track_mutant_coverage, int mutation_id_base, - std::stringstream& new_function, int& mutation_id_offset, + bool optimise_mutations, bool only_track_mutant_coverage, + int mutation_id_base, std::stringstream& new_function, + int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void)dredd_macros; if (expr_->isLValue()) { return; } @@ -233,15 +218,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_LNOT"; new_function << " MUTATION(" << mutation_id_offset << ", !(" << arg_evaluated << "));\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "!(" + - // arg_evaluated +")")); new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return !(" << - // arg_evaluated - // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertLNot, @@ -254,15 +232,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_NOT"; new_function << " MUTATION(" << mutation_id_offset << ", ~(" << arg_evaluated << "));\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "~(" + - // arg_evaluated +")")); new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return ~(" << - // arg_evaluated - // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertNot, @@ -275,15 +246,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_MINUS"; new_function << " MUTATION(" << mutation_id_offset << ", -(" << arg_evaluated << "));\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "-(" + - // arg_evaluated +")")); new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return -(" << - // arg_evaluated - // << ");\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertMinus, @@ -294,48 +258,42 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, - bool only_track_mutant_coverage, int mutation_id_base, - std::stringstream& new_function, int& mutation_id_offset, + bool optimise_mutations, bool only_track_mutant_coverage, + int mutation_id_base, std::stringstream& new_function, + int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { GenerateUnaryOperatorInsertionBeforeLValue( - arg_evaluated, ast_context, dredd_macros, only_track_mutant_coverage, - mutation_id_base, new_function, mutation_id_offset, protobuf_message); + arg_evaluated, ast_context, only_track_mutant_coverage, mutation_id_base, + new_function, mutation_id_offset, protobuf_message); GenerateUnaryOperatorInsertionBeforeNonLValue( - arg_evaluated, ast_context, dredd_macros, optimise_mutations, + arg_evaluated, ast_context, optimise_mutations, only_track_mutant_coverage, mutation_id_base, new_function, mutation_id_offset, protobuf_message); } void MutationReplaceExpr::GenerateConstantReplacement( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { if (!expr_->isLValue()) { GenerateBooleanConstantReplacement( - ast_context, dredd_macros, optimise_mutations, - only_track_mutant_coverage, mutation_id_base, new_function, - mutation_id_offset, protobuf_message); + ast_context, optimise_mutations, only_track_mutant_coverage, + mutation_id_base, new_function, mutation_id_offset, protobuf_message); GenerateIntegerConstantReplacement( - ast_context, dredd_macros, optimise_mutations, - only_track_mutant_coverage, mutation_id_base, new_function, - mutation_id_offset, protobuf_message); + ast_context, optimise_mutations, only_track_mutant_coverage, + mutation_id_base, new_function, mutation_id_offset, protobuf_message); GenerateFloatConstantReplacement( - ast_context, dredd_macros, optimise_mutations, - only_track_mutant_coverage, mutation_id_base, new_function, - mutation_id_offset, protobuf_message); + ast_context, optimise_mutations, only_track_mutant_coverage, + mutation_id_base, new_function, mutation_id_offset, protobuf_message); } } void MutationReplaceExpr::GenerateFloatConstantReplacement( - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void)dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isFloatingPoint()) { @@ -343,12 +301,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 0.0, ast_context)) { // Replace floating point expression with 0.0 if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; new_function << " MUTATION(" << mutation_id_offset << ", 0.0);\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "0.0")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return 0.0;\n"; } AddMutationInstance( mutation_id_base, @@ -360,12 +313,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 1.0, ast_context)) { // Replace floating point expression with 1.0 if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", 1.0);\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "1.0")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return 1.0;\n"; } AddMutationInstance( mutation_id_base, @@ -377,12 +325,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, -1.0, ast_context)) { // Replace floating point expression with -1.0 if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", -1.0);\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1.0")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return -1.0;\n"; } AddMutationInstance( mutation_id_base, @@ -392,24 +335,17 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( } } void MutationReplaceExpr::GenerateIntegerConstantReplacement( - const clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + const clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void)dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isInteger() && !exprType.isBooleanType()) { if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 0, ast_context)) { // Replace expression with 0 if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_INT_ZERO"; new_function << " MUTATION(" << mutation_id_offset << ", 0);\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "0")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return 0;\n"; } AddMutationInstance( mutation_id_base, @@ -420,12 +356,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 1, ast_context)) { // Replace expression with 1 if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_INT_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", 1);\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "1")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return 1;\n"; } AddMutationInstance( mutation_id_base, @@ -439,12 +370,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( !ExprIsEquivalentToInt(*expr_, -1, ast_context)) { // Replace signed integer expression with -1 if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; new_function << " MUTATION(" << mutation_id_offset << ", -1);\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, "-1")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return -1;\n"; } AddMutationInstance( mutation_id_base, @@ -454,12 +380,10 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( } } void MutationReplaceExpr::GenerateBooleanConstantReplacement( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, bool optimise_mutations, + clang::ASTContext& ast_context, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { - (void)dredd_macros; const clang::BuiltinType& exprType = *expr_->getType()->getAs(); if (exprType.isBooleanType()) { @@ -468,18 +392,9 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(true, ast_context))) { // Replace expression with true if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_TRUE"; new_function << " MUTATION(" << mutation_id_offset << ", " << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") << ");\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, - // ast_context.getLangOpts().CPlusPlus ? "true" : "1")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return " - // << (ast_context.getLangOpts().CPlusPlus ? "true" - // : "1") - // << ";\n"; } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::ReplaceWithTrue, @@ -491,18 +406,9 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(false, ast_context))) { // Replace expression with false if (!only_track_mutant_coverage) { - // const std::string macro_name = "REPLACE_EXPR_FALSE"; new_function << " MUTATION(" << mutation_id_offset << ", " << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") << ");\n"; - // dredd_macros.insert(GenerateMutatorMacro(macro_name, - // ast_context.getLangOpts().CPlusPlus ? "false" : "0")); - // new_function << " if - // (__dredd_enabled_mutation(local_mutation_id + " - // << mutation_id_offset << ")) return " - // << (ast_context.getLangOpts().CPlusPlus ? "false" - // : "0") - // << ";\n"; } AddMutationInstance( mutation_id_base, @@ -513,11 +419,9 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( } std::string MutationReplaceExpr::GenerateMutatorFunction( - clang::ASTContext& ast_context, - std::unordered_set& dredd_macros, - const std::string& function_name, const std::string& result_type, - const std::string& input_type, bool optimise_mutations, - bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, const std::string& function_name, + const std::string& result_type, const std::string& input_type, + bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const { std::stringstream new_function; new_function << "static " << result_type << " " << function_name << "("; @@ -543,19 +447,17 @@ std::string MutationReplaceExpr::GenerateMutatorFunction( // Quickly apply the original operator if no mutant is enabled (which will // be the common case). new_function << " MUTATION_PRELUDE(" << arg_evaluated << ");\n"; - // new_function << " if (!__dredd_some_mutation_enabled) return " - // << arg_evaluated << ";\n"; } int mutation_id_offset = 0; - GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, dredd_macros, - optimise_mutations, only_track_mutant_coverage, - mutation_id, new_function, mutation_id_offset, + GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, optimise_mutations, + only_track_mutant_coverage, mutation_id, + new_function, mutation_id_offset, protobuf_message); GenerateConstantReplacement( - ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, - mutation_id, new_function, mutation_id_offset, protobuf_message); + ast_context, optimise_mutations, only_track_mutant_coverage, mutation_id, + new_function, mutation_id_offset, protobuf_message); if (only_track_mutant_coverage) { new_function << " __dredd_record_covered_mutants(local_mutation_id, " + @@ -681,8 +583,7 @@ protobufs::MutationGroup MutationReplaceExpr::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const { + std::unordered_set& dredd_declarations) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceExpr inner_result; @@ -720,7 +621,7 @@ protobufs::MutationGroup MutationReplaceExpr::Apply( ast_context, preprocessor, rewriter); const std::string new_function = GenerateMutatorFunction( - ast_context, dredd_macros, new_function_name, result_type, input_type, + ast_context, new_function_name, result_type, input_type, optimise_mutations, only_track_mutant_coverage, mutation_id, inner_result); assert(!new_function.empty() && "Unsupported expression."); diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index 7e850049..a153f719 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -207,7 +207,6 @@ std::string MutationReplaceUnaryOperator::GenerateMutatorFunction( if (!only_track_mutant_coverage) { // Quickly apply the original operator if no mutant is enabled (which will // be the common case). - // new_function << " if (!__dredd_some_mutation_enabled) return "; new_function << " MUTATION_PRELUDE("; if (IsPrefix(unary_operator_->getOpcode())) { new_function << clang::UnaryOperator::getOpcodeStr( @@ -306,9 +305,6 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( } if (!only_track_mutant_coverage) { new_function << " MUTATION(" << mutation_id_offset << ", "; - // new_function << " if (__dredd_enabled_mutation(local_mutation_id - // + " - // << mutation_id_offset << ")) return "; if (IsPrefix(operator_kind)) { new_function << clang::UnaryOperator::getOpcodeStr(operator_kind).str() << arg_evaluated + ";\n"; @@ -329,10 +325,6 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( if (!only_track_mutant_coverage) { new_function << " MUTATION(" << mutation_id_offset << ", " << arg_evaluated << ");\n"; - // new_function << " if (__dredd_enabled_mutation(local_mutation_id - // + " - // << mutation_id_offset - // << ")) return " + arg_evaluated + ";\n"; } AddMutationInstance( mutation_id_base, @@ -345,13 +337,11 @@ protobufs::MutationGroup MutationReplaceUnaryOperator::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations, - std::unordered_set& dredd_macros) const { + std::unordered_set& dredd_declarations) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceUnaryOperator inner_result; - (void)dredd_macros; inner_result.set_operator_( ClangOperatorKindToProtobufOperatorKind(unary_operator_->getOpcode())); diff --git a/src/libdreddtest/src/mutation_remove_stmt_test.cc b/src/libdreddtest/src/mutation_remove_stmt_test.cc index 5088a871..315d2c9b 100644 --- a/src/libdreddtest/src/mutation_remove_stmt_test.cc +++ b/src/libdreddtest/src/mutation_remove_stmt_test.cc @@ -47,10 +47,9 @@ void TestRemoval(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; - std::unordered_set dredd_macros; mutation_supplier(ast_unit->getPreprocessor(), ast_unit->getASTContext()) .Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), true, - false, 0, mutation_id, rewriter, dredd_declarations, dredd_macros); + false, 0, mutation_id, rewriter, dredd_declarations); ASSERT_EQ(1, mutation_id); ASSERT_EQ(0, dredd_declarations.size()); const clang::RewriteBuffer* rewrite_buffer = rewriter.getRewriteBufferFor( diff --git a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc index ff2ab550..2a5bef1c 100644 --- a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc @@ -57,10 +57,9 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; - std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), optimise_mutations, false, 0, mutation_id, rewriter, - dredd_declarations, dredd_macros); + dredd_declarations); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); diff --git a/src/libdreddtest/src/mutation_replace_expr_test.cc b/src/libdreddtest/src/mutation_replace_expr_test.cc index 12727f3b..d416e996 100644 --- a/src/libdreddtest/src/mutation_replace_expr_test.cc +++ b/src/libdreddtest/src/mutation_replace_expr_test.cc @@ -60,10 +60,8 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; - std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), true, - false, 0, mutation_id, rewriter, dredd_declarations, - dredd_macros); + false, 0, mutation_id, rewriter, dredd_declarations); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); diff --git a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc index 77eb2b26..c31780bc 100644 --- a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc @@ -57,10 +57,9 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; - std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), optimise_mutations, false, 0, mutation_id, rewriter, - dredd_declarations, dredd_macros); + dredd_declarations); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); From a8e10e6a9a5b6519b4a3bbe66c43a9bc742474f6 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 21:24:08 +0000 Subject: [PATCH 05/15] Use individual mutator functions --- src/libdredd/include/libdredd/mutation.h | 3 +- .../include/libdredd/mutation_remove_stmt.h | 3 +- .../mutation_replace_binary_operator.h | 27 ++-- .../include/libdredd/mutation_replace_expr.h | 38 +++-- .../mutation_replace_unary_operator.h | 20 ++- src/libdredd/include/libdredd/util.h | 2 + .../include/libdredd/mutate_ast_consumer.h | 9 +- src/libdredd/src/mutate_ast_consumer.cc | 38 ++--- src/libdredd/src/mutation_remove_stmt.cc | 4 +- .../src/mutation_replace_binary_operator.cc | 58 ++++--- src/libdredd/src/mutation_replace_expr.cc | 144 ++++++++++++------ .../src/mutation_replace_unary_operator.cc | 81 +++++----- src/libdredd/src/util.cc | 8 + .../src/mutation_remove_stmt_test.cc | 3 +- .../mutation_replace_binary_operator_test.cc | 3 +- .../src/mutation_replace_expr_test.cc | 4 +- .../mutation_replace_unary_operator_test.cc | 3 +- 17 files changed, 263 insertions(+), 185 deletions(-) diff --git a/src/libdredd/include/libdredd/mutation.h b/src/libdredd/include/libdredd/mutation.h index 56c93438..ac8fee9a 100644 --- a/src/libdredd/include/libdredd/mutation.h +++ b/src/libdredd/include/libdredd/mutation.h @@ -53,7 +53,8 @@ class Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const = 0; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const = 0; }; } // namespace dredd diff --git a/src/libdredd/include/libdredd/mutation_remove_stmt.h b/src/libdredd/include/libdredd/mutation_remove_stmt.h index b0f0f8ad..db915e14 100644 --- a/src/libdredd/include/libdredd/mutation_remove_stmt.h +++ b/src/libdredd/include/libdredd/mutation_remove_stmt.h @@ -40,7 +40,8 @@ class MutationRemoveStmt : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; private: // Helper method to determine whether the token immediately following the diff --git a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h index 84d962cd..ad1ba778 100644 --- a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h @@ -42,14 +42,17 @@ class MutationReplaceBinaryOperator : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; private: std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& lhs_type, - const std::string& rhs_type, bool optimise_mutations, - bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& lhs_type, const std::string& rhs_type, + bool optimise_mutations, bool only_track_mutant_coverage, + int& mutation_id, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; void ReplaceOperator(const std::string& lhs_type, const std::string& rhs_type, @@ -78,26 +81,20 @@ class MutationReplaceBinaryOperator : public Mutation { [[nodiscard]] bool IsValidReplacementOperator( clang::BinaryOperatorKind operator_kind) const; - static std::string GenerateArgumentReplacementMacro( - const std::string& name, const std::string& arg_evaluated); - // Replaces binary expressions with either the left or right operand. void GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; - static std::string GenerateBinaryOperatorMacro( - const std::string& name, const std::string& arg1_evaluated, - const clang::BinaryOperatorKind& operator_kind, - const std::string& arg2_evaluated); - // Replaces binary operators with other valid binary operators. void GenerateBinaryOperatorReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const; diff --git a/src/libdredd/include/libdredd/mutation_replace_expr.h b/src/libdredd/include/libdredd/mutation_replace_expr.h index fee39226..d14a9574 100644 --- a/src/libdredd/include/libdredd/mutation_replace_expr.h +++ b/src/libdredd/include/libdredd/mutation_replace_expr.h @@ -41,7 +41,8 @@ class MutationReplaceExpr : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; static void ApplyCppTypeModifiers(const clang::Expr& expr, std::string& type); @@ -94,25 +95,29 @@ class MutationReplaceExpr : public Mutation { // Replace expressions with constants. void GenerateConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateBooleanConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateIntegerConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateFloatConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; @@ -120,29 +125,32 @@ class MutationReplaceExpr : public Mutation { // Insert valid unary operators such as !, ~, ++ and --. void GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; void GenerateUnaryOperatorInsertionBeforeLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const; std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& input_type, - bool optimise_mutations, bool only_track_mutant_coverage, - int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const; + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& input_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, + protobufs::MutationReplaceExpr& protobuf_message) const; [[nodiscard]] std::string GetFunctionName( bool optimise_mutations, clang::ASTContext& ast_context) const; diff --git a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h index 24c6f621..1ac0a0eb 100644 --- a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h @@ -41,14 +41,16 @@ class MutationReplaceUnaryOperator : public Mutation { bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const override; + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const override; private: std::string GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& input_type, - bool optimise_mutations, bool only_track_mutant_coverage, - int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& input_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceUnaryOperator& protobuf_message) const; [[nodiscard]] static bool IsPrefix(clang::UnaryOperatorKind operator_kind); @@ -65,12 +67,14 @@ class MutationReplaceUnaryOperator : public Mutation { std::string GetFunctionName(bool optimise_mutations, clang::ASTContext& ast_context) const; + static std::string OpKindToString(clang::UnaryOperatorKind kind); + // Replaces unary operators with other valid unary operators. void GenerateUnaryOperatorReplacement( const std::string& arg_evaluated, const clang::ASTContext& ast_context, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceUnaryOperator& protobuf_message) const; static void AddMutationInstance( diff --git a/src/libdredd/include/libdredd/util.h b/src/libdredd/include/libdredd/util.h index da47090a..0959bf83 100644 --- a/src/libdredd/include/libdredd/util.h +++ b/src/libdredd/include/libdredd/util.h @@ -128,6 +128,8 @@ bool EvaluateAsFloat(const clang::Expr& expr, bool IsCxx11ConstantExpr(const clang::Expr& expr, const clang::ASTContext& ast_context); +std::string GenerateMutationMacro(const std::string& name, + const std::string& arg_evaluated); } // namespace dredd #endif // LIBDREDD_UTIL_H diff --git a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h index 09df536e..ff0ee38c 100644 --- a/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h +++ b/src/libdredd/include_private/include/libdredd/mutate_ast_consumer.h @@ -47,12 +47,6 @@ class MutateAstConsumer : public clang::ASTConsumer { void HandleTranslationUnit(clang::ASTContext& ast_context) override; private: - static std::string GetMutationMacro(); - - static std::string GetMutationPreludeMacro(); - - static std::string GetMutationResultMacro(); - [[nodiscard]] std::string GetDreddPreludeCpp(int initial_mutation_id) const; [[nodiscard]] std::string GetRegularDreddPreludeCpp( @@ -72,7 +66,8 @@ class MutateAstConsumer : public clang::ASTConsumer { protobufs::MutationTreeNode ApplyMutations( const MutationTreeNode& mutation_tree_node, int initial_mutation_id, clang::ASTContext& context, - std::unordered_set& dredd_declarations); + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros); const clang::CompilerInstance* compiler_instance_; diff --git a/src/libdredd/src/mutate_ast_consumer.cc b/src/libdredd/src/mutate_ast_consumer.cc index f7dfbf8c..8756dbb0 100644 --- a/src/libdredd/src/mutate_ast_consumer.cc +++ b/src/libdredd/src/mutate_ast_consumer.cc @@ -74,6 +74,7 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { // converted to an ordered set so that declarations can be added to the source // file in a deterministic order. std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; protobufs::MutationInfoForFile mutation_info_for_file; mutation_info_for_file.set_filename( @@ -83,7 +84,7 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { .str()); *mutation_info_for_file.mutable_mutation_tree_root() = ApplyMutations(visitor_->GetMutations(), initial_mutation_id, ast_context, - dredd_declarations); + dredd_declarations, dredd_macros); if (initial_mutation_id == *mutation_id_) { // No possibilities for mutation were found; nothing else to do. @@ -111,9 +112,14 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Rewrite failed.\n"); } - rewriter_.InsertTextBefore(start_of_source_file, GetMutationPreludeMacro()); - rewriter_.InsertTextBefore(start_of_source_file, GetMutationMacro()); - rewriter_.InsertTextBefore(start_of_source_file, GetMutationResultMacro()); + std::set sorted_dredd_macros; + sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); + for (const auto& macro : sorted_dredd_macros) { + const bool rewriter_result = + rewriter_.InsertTextBefore(start_of_source_file, macro); + (void)rewriter_result; // Keep release-mode compilers happy. + assert(!rewriter_result && "Rewrite failed.\n"); + } const std::string dredd_prelude = compiler_instance_->getLangOpts().CPlusPlus @@ -130,21 +136,6 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Something went wrong emitting rewritten files."); } -std::string MutateAstConsumer::GetMutationMacro() { - return "#define MUTATION(mutation_id_offset, arg) if " - "(__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) " - "return arg\n\n"; -} - -std::string MutateAstConsumer::GetMutationPreludeMacro() { - return "#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) " - "return arg\n\n"; -} - -std::string MutateAstConsumer::GetMutationResultMacro() { - return "#define MUTATION_RESULT(arg) arg\n\n"; -} - std::string MutateAstConsumer::GetRegularDreddPreludeCpp( int initial_mutation_id) const { // The number of mutations applied to this file is known. @@ -380,7 +371,8 @@ std::string MutateAstConsumer::GetDreddPreludeC(int initial_mutation_id) const { protobufs::MutationTreeNode MutateAstConsumer::ApplyMutations( const MutationTreeNode& mutation_tree_node, int initial_mutation_id, clang::ASTContext& context, - std::unordered_set& dredd_declarations) { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) { assert(!(mutation_tree_node.IsEmpty() && mutation_tree_node.GetChildren().size() == 1) && "The mutation tree should already be compressed."); @@ -388,15 +380,15 @@ protobufs::MutationTreeNode MutateAstConsumer::ApplyMutations( for (const auto& child : mutation_tree_node.GetChildren()) { assert(!child->IsEmpty() && "The mutation tree should not have empty subtrees."); - *result.add_children() = ApplyMutations(*child, initial_mutation_id, - context, dredd_declarations); + *result.add_children() = ApplyMutations( + *child, initial_mutation_id, context, dredd_declarations, dredd_macros); } for (const auto& mutation : mutation_tree_node.GetMutations()) { const int mutation_id_old = *mutation_id_; const auto mutation_group = mutation->Apply( context, compiler_instance_->getPreprocessor(), optimise_mutations_, only_track_mutant_coverage_, initial_mutation_id, *mutation_id_, - rewriter_, dredd_declarations); + rewriter_, dredd_declarations, dredd_macros); if (*mutation_id_ > mutation_id_old) { // Only add the result of applying the mutation if it had an effect. *result.add_mutation_groups() = mutation_group; diff --git a/src/libdredd/src/mutation_remove_stmt.cc b/src/libdredd/src/mutation_remove_stmt.cc index 344f990b..d5bc0e47 100644 --- a/src/libdredd/src/mutation_remove_stmt.cc +++ b/src/libdredd/src/mutation_remove_stmt.cc @@ -42,8 +42,10 @@ protobufs::MutationGroup MutationRemoveStmt::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { (void)dredd_declarations; // Unused. + (void)dredd_macros; // Unused. (void)optimise_mutations; // Unused. // The protobuf object for the mutation, which will be wrapped in a diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index 61cfe9af..da716a61 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -233,7 +233,8 @@ std::string MutationReplaceBinaryOperator::GetFunctionName( void MutationReplaceBinaryOperator::GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { @@ -279,8 +280,9 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getLHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", " - << arg1_evaluated << ");\n"; + const std::string macro_name = "REPLACE_BINARY_ARG1"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, arg1_evaluated)); } AddMutationInstance( mutation_id_base, @@ -305,8 +307,9 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getRHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", " - << arg2_evaluated << ");\n"; + const std::string macro_name = "REPLACE_BINARY_ARG2"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, arg2_evaluated)); } AddMutationInstance( mutation_id_base, @@ -317,17 +320,22 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", " - << arg1_evaluated - << clang::BinaryOperator::getOpcodeStr(operator_kind).str() - << arg2_evaluated << ");\n"; + const std::string macro_name = + "REPLACE_BINARY_" + OpKindToString(operator_kind); + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert(GenerateMutationMacro( + macro_name, + arg1_evaluated + " " + + clang::BinaryOperator::getOpcodeStr(operator_kind).str() + " " + + arg2_evaluated)); } AddMutationInstance(mutation_id_base, OperatorKindToAction(operator_kind), mutation_id_offset, protobuf_message); @@ -409,10 +417,11 @@ MutationReplaceBinaryOperator::GetReplacementOperators( } std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& lhs_type, - const std::string& rhs_type, bool optimise_mutations, - bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& lhs_type, const std::string& rhs_type, + bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceBinaryOperator& protobuf_message) const { std::stringstream new_function; new_function << "static " << result_type << " " << function_name << "("; @@ -465,13 +474,13 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( } GenerateBinaryOperatorReplacement( - arg1_evaluated, arg2_evaluated, ast_context, optimise_mutations, - only_track_mutant_coverage, mutation_id, new_function, mutation_id_offset, - protobuf_message); - GenerateArgumentReplacement(arg1_evaluated, arg2_evaluated, ast_context, - optimise_mutations, only_track_mutant_coverage, - mutation_id, new_function, mutation_id_offset, - protobuf_message); + arg1_evaluated, arg2_evaluated, ast_context, dredd_macros, + optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, + mutation_id_offset, protobuf_message); + GenerateArgumentReplacement( + arg1_evaluated, arg2_evaluated, ast_context, dredd_macros, + optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, + mutation_id_offset, protobuf_message); if (only_track_mutant_coverage) { new_function << " __dredd_record_covered_mutants(local_mutation_id, " + @@ -497,7 +506,8 @@ protobufs::MutationGroup MutationReplaceBinaryOperator::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceBinaryOperator inner_result; @@ -583,8 +593,8 @@ protobufs::MutationGroup MutationReplaceBinaryOperator::Apply( rewriter); const std::string new_function = GenerateMutatorFunction( - ast_context, new_function_name, result_type, lhs_type, rhs_type, - optimise_mutations, only_track_mutant_coverage, mutation_id, + ast_context, dredd_macros, new_function_name, result_type, lhs_type, + rhs_type, optimise_mutations, only_track_mutant_coverage, mutation_id, inner_result); assert(!new_function.empty() && "Unsupported opcode."); diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 84b84cff..aaf389fb 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -179,6 +179,7 @@ bool MutationReplaceExpr::IsRedundantOperatorInsertion( void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { @@ -186,16 +187,20 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( return; } if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", ++(" - << arg_evaluated << "));\n"; + const std::string macro_name = "MUTATION_EXPR_INC"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert( + GenerateMutationMacro(macro_name, "++(" + arg_evaluated + ")")); } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreInc, mutation_id_offset, protobuf_message); if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", --(" - << arg_evaluated << "));\n"; + const std::string macro_name = "MUTATION_EXPR_DEC"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert( + GenerateMutationMacro(macro_name, "--(" + arg_evaluated + ")")); } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertPreDec, @@ -204,9 +209,9 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( const std::string& arg_evaluated, clang::ASTContext& ast_context, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { if (expr_->isLValue()) { return; @@ -218,8 +223,11 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", !(" - << arg_evaluated << "));\n"; + const std::string macro_name = "MUTATION_EXPR_LNOT"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert( + GenerateMutationMacro(macro_name, "!(" + arg_evaluated + ")")); } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertLNot, @@ -232,8 +240,11 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", ~(" - << arg_evaluated << "));\n"; + const std::string macro_name = "MUTATION_EXPR_NOT"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert( + GenerateMutationMacro(macro_name, "~(" + arg_evaluated + ")")); } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertNot, @@ -246,8 +257,11 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", -(" - << arg_evaluated << "));\n"; + const std::string macro_name = "MUTATION_EXPR_MINUS"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert( + GenerateMutationMacro(macro_name, "-(" + arg_evaluated + ")")); } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::InsertMinus, @@ -258,39 +272,44 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( void MutationReplaceExpr::GenerateUnaryOperatorInsertion( const std::string& arg_evaluated, clang::ASTContext& ast_context, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { GenerateUnaryOperatorInsertionBeforeLValue( - arg_evaluated, ast_context, only_track_mutant_coverage, mutation_id_base, - new_function, mutation_id_offset, protobuf_message); + arg_evaluated, ast_context, dredd_macros, only_track_mutant_coverage, + mutation_id_base, new_function, mutation_id_offset, protobuf_message); GenerateUnaryOperatorInsertionBeforeNonLValue( - arg_evaluated, ast_context, optimise_mutations, + arg_evaluated, ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id_base, new_function, mutation_id_offset, protobuf_message); } void MutationReplaceExpr::GenerateConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { if (!expr_->isLValue()) { GenerateBooleanConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, - mutation_id_base, new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, + only_track_mutant_coverage, mutation_id_base, new_function, + mutation_id_offset, protobuf_message); GenerateIntegerConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, - mutation_id_base, new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, + only_track_mutant_coverage, mutation_id_base, new_function, + mutation_id_offset, protobuf_message); GenerateFloatConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, - mutation_id_base, new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, + only_track_mutant_coverage, mutation_id_base, new_function, + mutation_id_offset, protobuf_message); } } void MutationReplaceExpr::GenerateFloatConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { @@ -301,7 +320,10 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 0.0, ast_context)) { // Replace floating point expression with 0.0 if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", 0.0);\n"; + const std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, "0.0")); } AddMutationInstance( mutation_id_base, @@ -313,7 +335,10 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 1.0, ast_context)) { // Replace floating point expression with 1.0 if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", 1.0);\n"; + const std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, "1.0")); } AddMutationInstance( mutation_id_base, @@ -325,7 +350,10 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, -1.0, ast_context)) { // Replace floating point expression with -1.0 if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", -1.0);\n"; + const std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, "-1.0")); } AddMutationInstance( mutation_id_base, @@ -335,7 +363,8 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( } } void MutationReplaceExpr::GenerateIntegerConstantReplacement( - const clang::ASTContext& ast_context, bool optimise_mutations, + const clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { @@ -345,7 +374,10 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 0, ast_context)) { // Replace expression with 0 if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", 0);\n"; + const std::string macro_name = "REPLACE_EXPR_INT_ZERO"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, "0")); } AddMutationInstance( mutation_id_base, @@ -356,7 +388,10 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 1, ast_context)) { // Replace expression with 1 if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", 1);\n"; + const std::string macro_name = "REPLACE_EXPR_INT_ONE"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, "1")); } AddMutationInstance( mutation_id_base, @@ -370,7 +405,10 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( !ExprIsEquivalentToInt(*expr_, -1, ast_context)) { // Replace signed integer expression with -1 if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", -1);\n"; + const std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; + new_function << " " << macro_name << "(" << mutation_id_offset + << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, "-1")); } AddMutationInstance( mutation_id_base, @@ -380,7 +418,8 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( } } void MutationReplaceExpr::GenerateBooleanConstantReplacement( - clang::ASTContext& ast_context, bool optimise_mutations, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, bool optimise_mutations, bool only_track_mutant_coverage, int mutation_id_base, std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceExpr& protobuf_message) const { @@ -392,9 +431,11 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(true, ast_context))) { // Replace expression with true if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", " - << (ast_context.getLangOpts().CPlusPlus ? "true" : "1") + const std::string macro_name = "REPLACE_EXPR_TRUE"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert(GenerateMutationMacro( + macro_name, (ast_context.getLangOpts().CPlusPlus ? "true" : "1"))); } AddMutationInstance(mutation_id_base, protobufs::MutationReplaceExprAction::ReplaceWithTrue, @@ -406,9 +447,11 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(false, ast_context))) { // Replace expression with false if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", " - << (ast_context.getLangOpts().CPlusPlus ? "false" : "0") + const std::string macro_name = "REPLACE_EXPR_FALSE"; + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert(GenerateMutationMacro( + macro_name, (ast_context.getLangOpts().CPlusPlus ? "false" : "0"))); } AddMutationInstance( mutation_id_base, @@ -419,9 +462,11 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( } std::string MutationReplaceExpr::GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& input_type, - bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& input_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceExpr& protobuf_message) const { std::stringstream new_function; new_function << "static " << result_type << " " << function_name << "("; @@ -451,13 +496,13 @@ std::string MutationReplaceExpr::GenerateMutatorFunction( int mutation_id_offset = 0; - GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, optimise_mutations, - only_track_mutant_coverage, mutation_id, - new_function, mutation_id_offset, + GenerateUnaryOperatorInsertion(arg_evaluated, ast_context, dredd_macros, + optimise_mutations, only_track_mutant_coverage, + mutation_id, new_function, mutation_id_offset, protobuf_message); GenerateConstantReplacement( - ast_context, optimise_mutations, only_track_mutant_coverage, mutation_id, - new_function, mutation_id_offset, protobuf_message); + ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, + mutation_id, new_function, mutation_id_offset, protobuf_message); if (only_track_mutant_coverage) { new_function << " __dredd_record_covered_mutants(local_mutation_id, " + @@ -583,7 +628,8 @@ protobufs::MutationGroup MutationReplaceExpr::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceExpr inner_result; @@ -621,7 +667,7 @@ protobufs::MutationGroup MutationReplaceExpr::Apply( ast_context, preprocessor, rewriter); const std::string new_function = GenerateMutatorFunction( - ast_context, new_function_name, result_type, input_type, + ast_context, dredd_macros, new_function_name, result_type, input_type, optimise_mutations, only_track_mutant_coverage, mutation_id, inner_result); assert(!new_function.empty() && "Unsupported expression."); diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index a153f719..15aa3a76 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -93,38 +93,37 @@ bool MutationReplaceUnaryOperator::IsValidReplacementOperator( return true; } -std::string MutationReplaceUnaryOperator::GetFunctionName( - bool optimise_mutations, clang::ASTContext& ast_context) const { - std::string result = "__dredd_replace_unary_operator_"; - - // A string corresponding to the unary operator forms part of the name of the - // mutation function, to differentiate mutation functions for different - // operators - switch (unary_operator_->getOpcode()) { +std::string MutationReplaceUnaryOperator::OpKindToString( + clang::UnaryOperatorKind kind) { + switch (kind) { case clang::UnaryOperatorKind::UO_Minus: - result += "Minus"; - break; + return "Minus"; case clang::UnaryOperatorKind::UO_Not: - result += "Not"; - break; + return "Not"; case clang::UnaryOperatorKind::UO_PreDec: - result += "PreDec"; - break; + return "PreDec"; case clang::UnaryOperatorKind::UO_PostDec: - result += "PostDec"; - break; + return "PostDec"; case clang::UnaryOperatorKind::UO_PreInc: - result += "PreInc"; - break; + return "PreInc"; case clang::UnaryOperatorKind::UO_PostInc: - result += "PostInc"; - break; + return "PostInc"; case clang::UnaryOperatorKind::UO_LNot: - result += "LNot"; - break; + return "LNot"; default: assert(false && "Unsupported opcode"); + return ""; } +} + +std::string MutationReplaceUnaryOperator::GetFunctionName( + bool optimise_mutations, clang::ASTContext& ast_context) const { + std::string result = "__dredd_replace_unary_operator_"; + + // A string corresponding to the unary operator forms part of the name of the + // mutation function, to differentiate mutation functions for different + // operators + result += OpKindToString(unary_operator_->getOpcode()); if (unary_operator_->getSubExpr()->isLValue()) { const clang::QualType qualified_type = @@ -179,9 +178,11 @@ std::string MutationReplaceUnaryOperator::GetFunctionName( } std::string MutationReplaceUnaryOperator::GenerateMutatorFunction( - clang::ASTContext& ast_context, const std::string& function_name, - const std::string& result_type, const std::string& input_type, - bool optimise_mutations, bool only_track_mutant_coverage, int& mutation_id, + clang::ASTContext& ast_context, + std::unordered_set& dredd_macros, + const std::string& function_name, const std::string& result_type, + const std::string& input_type, bool optimise_mutations, + bool only_track_mutant_coverage, int& mutation_id, protobufs::MutationReplaceUnaryOperator& protobuf_message) const { std::stringstream new_function; new_function << "static " << result_type << " " << function_name << "("; @@ -224,7 +225,7 @@ std::string MutationReplaceUnaryOperator::GenerateMutatorFunction( int mutation_id_offset = 0; GenerateUnaryOperatorReplacement( - arg_evaluated, ast_context, optimise_mutations, + arg_evaluated, ast_context, dredd_macros, optimise_mutations, only_track_mutant_coverage, mutation_id, new_function, mutation_id_offset, protobuf_message); @@ -283,9 +284,9 @@ bool MutationReplaceUnaryOperator::IsRedundantReplacementOperator( void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( const std::string& arg_evaluated, const clang::ASTContext& ast_context, - bool optimise_mutations, bool only_track_mutant_coverage, - int mutation_id_base, std::stringstream& new_function, - int& mutation_id_offset, + std::unordered_set& dredd_macros, bool optimise_mutations, + bool only_track_mutant_coverage, int mutation_id_base, + std::stringstream& new_function, int& mutation_id_offset, protobufs::MutationReplaceUnaryOperator& protobuf_message) const { const std::vector candidate_replacement_operators = {clang::UnaryOperatorKind::UO_PreInc, @@ -304,14 +305,19 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( continue; } if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", "; + const std::string macro_name = + "REPLACE_UNARY_" + OpKindToString(operator_kind); + new_function << " " << macro_name << "(" << mutation_id_offset << ")\n"; if (IsPrefix(operator_kind)) { - new_function << clang::UnaryOperator::getOpcodeStr(operator_kind).str() - << arg_evaluated + ";\n"; + dredd_macros.insert(GenerateMutationMacro( + macro_name, + clang::UnaryOperator::getOpcodeStr(operator_kind).str() + + arg_evaluated)); } else { - new_function << arg_evaluated - << clang::UnaryOperator::getOpcodeStr(operator_kind).str() - << ");\n"; + dredd_macros.insert(GenerateMutationMacro( + macro_name, + arg_evaluated + + clang::UnaryOperator::getOpcodeStr(operator_kind).str())); } } AddMutationInstance(mutation_id_base, OperatorKindToAction(operator_kind), @@ -337,7 +343,8 @@ protobufs::MutationGroup MutationReplaceUnaryOperator::Apply( clang::ASTContext& ast_context, const clang::Preprocessor& preprocessor, bool optimise_mutations, bool only_track_mutant_coverage, int first_mutation_id_in_file, int& mutation_id, clang::Rewriter& rewriter, - std::unordered_set& dredd_declarations) const { + std::unordered_set& dredd_declarations, + std::unordered_set& dredd_macros) const { // The protobuf object for the mutation, which will be wrapped in a // MutationGroup. protobufs::MutationReplaceUnaryOperator inner_result; @@ -447,7 +454,7 @@ protobufs::MutationGroup MutationReplaceUnaryOperator::Apply( (void)rewriter_result; // Keep release-mode compilers happy. const std::string new_function = GenerateMutatorFunction( - ast_context, new_function_name, result_type, input_type, + ast_context, dredd_macros, new_function_name, result_type, input_type, optimise_mutations, only_track_mutant_coverage, mutation_id, inner_result); assert(!new_function.empty() && "Unsupported opcode."); diff --git a/src/libdredd/src/util.cc b/src/libdredd/src/util.cc index 53591ddc..94435322 100644 --- a/src/libdredd/src/util.cc +++ b/src/libdredd/src/util.cc @@ -129,4 +129,12 @@ bool IsCxx11ConstantExpr(const clang::Expr& expr, return !expr.isValueDependent() && expr.isCXX11ConstantExpr(ast_context); } +std::string GenerateMutationMacro(const std::string& name, + const std::string& args_evaluated) { + return "#define " + name + + "(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id " + "+ mutation_id_offset)) return " + + args_evaluated + "\n"; +} + } // namespace dredd diff --git a/src/libdreddtest/src/mutation_remove_stmt_test.cc b/src/libdreddtest/src/mutation_remove_stmt_test.cc index 315d2c9b..5088a871 100644 --- a/src/libdreddtest/src/mutation_remove_stmt_test.cc +++ b/src/libdreddtest/src/mutation_remove_stmt_test.cc @@ -47,9 +47,10 @@ void TestRemoval(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation_supplier(ast_unit->getPreprocessor(), ast_unit->getASTContext()) .Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), true, - false, 0, mutation_id, rewriter, dredd_declarations); + false, 0, mutation_id, rewriter, dredd_declarations, dredd_macros); ASSERT_EQ(1, mutation_id); ASSERT_EQ(0, dredd_declarations.size()); const clang::RewriteBuffer* rewrite_buffer = rewriter.getRewriteBufferFor( diff --git a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc index 2a5bef1c..ff2ab550 100644 --- a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc @@ -57,9 +57,10 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), optimise_mutations, false, 0, mutation_id, rewriter, - dredd_declarations); + dredd_declarations, dredd_macros); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); diff --git a/src/libdreddtest/src/mutation_replace_expr_test.cc b/src/libdreddtest/src/mutation_replace_expr_test.cc index d416e996..12727f3b 100644 --- a/src/libdreddtest/src/mutation_replace_expr_test.cc +++ b/src/libdreddtest/src/mutation_replace_expr_test.cc @@ -60,8 +60,10 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), true, - false, 0, mutation_id, rewriter, dredd_declarations); + false, 0, mutation_id, rewriter, dredd_declarations, + dredd_macros); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); diff --git a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc index c31780bc..77eb2b26 100644 --- a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc @@ -57,9 +57,10 @@ void TestReplacement(const std::string& original, const std::string& expected, ast_unit->getLangOpts()); int mutation_id = 0; std::unordered_set dredd_declarations; + std::unordered_set dredd_macros; mutation.Apply(ast_unit->getASTContext(), ast_unit->getPreprocessor(), optimise_mutations, false, 0, mutation_id, rewriter, - dredd_declarations); + dredd_declarations, dredd_macros); ASSERT_EQ(num_replacements, mutation_id); ASSERT_EQ(1, dredd_declarations.size()); ASSERT_EQ(expected_dredd_declaration, *dredd_declarations.begin()); From 683b2e9f665d3a83410d7ff456f8703d2c67e75f Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 21:50:26 +0000 Subject: [PATCH 06/15] Add prelude and return macros --- src/libdredd/include/libdredd/util.h | 4 ++++ src/libdredd/src/mutate_ast_consumer.cc | 5 +++++ src/libdredd/src/mutation_replace_binary_operator.cc | 2 +- src/libdredd/src/mutation_replace_expr.cc | 2 +- src/libdredd/src/mutation_replace_unary_operator.cc | 2 +- src/libdredd/src/util.cc | 9 +++++++++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/libdredd/include/libdredd/util.h b/src/libdredd/include/libdredd/util.h index 0959bf83..047bb829 100644 --- a/src/libdredd/include/libdredd/util.h +++ b/src/libdredd/include/libdredd/util.h @@ -128,8 +128,12 @@ bool EvaluateAsFloat(const clang::Expr& expr, bool IsCxx11ConstantExpr(const clang::Expr& expr, const clang::ASTContext& ast_context); +std::string GenerateMutationPrelude(); + std::string GenerateMutationMacro(const std::string& name, const std::string& arg_evaluated); + +std::string GenerateMutationReturn(); } // namespace dredd #endif // LIBDREDD_UTIL_H diff --git a/src/libdredd/src/mutate_ast_consumer.cc b/src/libdredd/src/mutate_ast_consumer.cc index 8756dbb0..147e025c 100644 --- a/src/libdredd/src/mutate_ast_consumer.cc +++ b/src/libdredd/src/mutate_ast_consumer.cc @@ -31,6 +31,7 @@ #include "clang/Frontend/CompilerInstance.h" #include "clang/Rewrite/Core/Rewriter.h" #include "libdredd/mutation.h" +#include "libdredd/util.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" @@ -112,6 +113,8 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Rewrite failed.\n"); } + rewriter_.InsertTextBefore(start_of_source_file, GenerateMutationPrelude()); + std::set sorted_dredd_macros; sorted_dredd_macros.insert(dredd_macros.begin(), dredd_macros.end()); for (const auto& macro : sorted_dredd_macros) { @@ -121,6 +124,8 @@ void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) { assert(!rewriter_result && "Rewrite failed.\n"); } + rewriter_.InsertTextBefore(start_of_source_file, GenerateMutationReturn()); + const std::string dredd_prelude = compiler_instance_->getLangOpts().CPlusPlus ? GetDreddPreludeCpp(initial_mutation_id) diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index da716a61..0a7ef5b0 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -487,7 +487,7 @@ std::string MutationReplaceBinaryOperator::GenerateMutatorFunction( std::to_string(mutation_id_offset) + ");\n"; } // TODO(JamesLee-Jones): Replace with return macro. - new_function << " return MUTATION_RESULT(" << arg1_evaluated << " " + new_function << " return MUTATION_RETURN(" << arg1_evaluated << " " << clang::BinaryOperator::getOpcodeStr( binary_operator_->getOpcode()) .str() diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index aaf389fb..bc8d4e0d 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -510,7 +510,7 @@ std::string MutationReplaceExpr::GenerateMutatorFunction( } // new_function << " return " << arg_evaluated << ";\n"; - new_function << " return MUTATION_RESULT(" << arg_evaluated << ");\n"; + new_function << " return MUTATION_RETURN(" << arg_evaluated << ");\n"; new_function << "}\n\n"; mutation_id += mutation_id_offset; diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index 15aa3a76..1b1064d1 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -236,7 +236,7 @@ std::string MutationReplaceUnaryOperator::GenerateMutatorFunction( const std::string opcode_string = clang::UnaryOperator::getOpcodeStr(unary_operator_->getOpcode()).str(); - new_function << " return MUTATION_RESULT(" + new_function << " return MUTATION_RETURN(" << (IsPrefix(unary_operator_->getOpcode()) ? opcode_string : "") << arg_evaluated << (IsPrefix(unary_operator_->getOpcode()) ? "" : opcode_string) diff --git a/src/libdredd/src/util.cc b/src/libdredd/src/util.cc index 94435322..dcf6546a 100644 --- a/src/libdredd/src/util.cc +++ b/src/libdredd/src/util.cc @@ -129,6 +129,11 @@ bool IsCxx11ConstantExpr(const clang::Expr& expr, return !expr.isValueDependent() && expr.isCXX11ConstantExpr(ast_context); } +std::string GenerateMutationPrelude() { + return "#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) " + "return arg\n"; +} + std::string GenerateMutationMacro(const std::string& name, const std::string& args_evaluated) { return "#define " + name + @@ -137,4 +142,8 @@ std::string GenerateMutationMacro(const std::string& name, args_evaluated + "\n"; } +std::string GenerateMutationReturn() { + return "#define MUTATION_RETURN(arg) arg\n"; +} + } // namespace dredd From 9f97b3b07a80ba4b49a5ac4b3220b3b4c7e54bf1 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 22:28:16 +0000 Subject: [PATCH 07/15] Add evaluation specifier --- src/libdredd/include/libdredd/util.h | 2 +- .../src/mutation_replace_binary_operator.cc | 18 ++++++-- src/libdredd/src/mutation_replace_expr.cc | 42 ++++++++++++------- .../src/mutation_replace_unary_operator.cc | 16 ++++--- src/libdredd/src/util.cc | 2 +- 5 files changed, 56 insertions(+), 24 deletions(-) diff --git a/src/libdredd/include/libdredd/util.h b/src/libdredd/include/libdredd/util.h index 047bb829..8252e295 100644 --- a/src/libdredd/include/libdredd/util.h +++ b/src/libdredd/include/libdredd/util.h @@ -130,7 +130,7 @@ bool IsCxx11ConstantExpr(const clang::Expr& expr, std::string GenerateMutationPrelude(); -std::string GenerateMutationMacro(const std::string& name, +std::string GenerateMutationMacro(std::string& name, const std::string& arg_evaluated); std::string GenerateMutationReturn(); diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index 0a7ef5b0..b009a7ec 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -280,7 +280,10 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getLHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_BINARY_ARG1"; + std::string macro_name = "REPLACE_BINARY_ARG1"; + if (binary_operator_->getLHS()->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, arg1_evaluated)); } @@ -307,7 +310,10 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( MutationReplaceExpr::ExprIsEquivalentToFloat( *binary_operator_->getRHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_BINARY_ARG2"; + std::string macro_name = "REPLACE_BINARY_ARG2"; + if (binary_operator_->getRHS()->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, arg2_evaluated)); } @@ -328,8 +334,14 @@ void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { - const std::string macro_name = + std::string macro_name = "REPLACE_BINARY_" + OpKindToString(operator_kind); + if (binary_operator_->getLHS()->HasSideEffects(ast_context)) { + macro_name += "_RHS_EVALUATED"; + } + if (binary_operator_->getLHS()->HasSideEffects(ast_context)) { + macro_name += "_RHS_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro( macro_name, diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index bc8d4e0d..3b996315 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -41,7 +41,6 @@ dredd::MutationReplaceExpr::MutationReplaceExpr( : expr_(&expr), info_for_source_range_(GetSourceRangeInMainFile(preprocessor, expr), ast_context) {} - std::string MutationReplaceExpr::GetFunctionName( bool optimise_mutations, clang::ASTContext& ast_context) const { std::string result = "__dredd_replace_expr_"; @@ -187,7 +186,10 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( return; } if (!only_track_mutant_coverage) { - const std::string macro_name = "MUTATION_EXPR_INC"; + std::string macro_name = "MUTATION_EXPR_INC"; + if (expr_->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( GenerateMutationMacro(macro_name, "++(" + arg_evaluated + ")")); @@ -197,7 +199,10 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( mutation_id_offset, protobuf_message); if (!only_track_mutant_coverage) { - const std::string macro_name = "MUTATION_EXPR_DEC"; + std::string macro_name = "MUTATION_EXPR_DEC"; + if (expr_->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( GenerateMutationMacro(macro_name, "--(" + arg_evaluated + ")")); @@ -223,7 +228,10 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { - const std::string macro_name = "MUTATION_EXPR_LNOT"; + std::string macro_name = "MUTATION_EXPR_LNOT"; + if (expr_->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( @@ -240,7 +248,10 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { - const std::string macro_name = "MUTATION_EXPR_NOT"; + std::string macro_name = "MUTATION_EXPR_NOT"; + if (expr_->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( @@ -257,7 +268,10 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { - const std::string macro_name = "MUTATION_EXPR_MINUS"; + std::string macro_name = "MUTATION_EXPR_MINUS"; + if (expr_->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( @@ -320,7 +334,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 0.0, ast_context)) { // Replace floating point expression with 0.0 if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; + std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "0.0")); @@ -335,7 +349,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 1.0, ast_context)) { // Replace floating point expression with 1.0 if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; + std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "1.0")); @@ -350,7 +364,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, -1.0, ast_context)) { // Replace floating point expression with -1.0 if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; + std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "-1.0")); @@ -374,7 +388,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 0, ast_context)) { // Replace expression with 0 if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_INT_ZERO"; + std::string macro_name = "REPLACE_EXPR_INT_ZERO"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "0")); @@ -388,7 +402,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 1, ast_context)) { // Replace expression with 1 if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_INT_ONE"; + std::string macro_name = "REPLACE_EXPR_INT_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "1")); @@ -405,7 +419,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( !ExprIsEquivalentToInt(*expr_, -1, ast_context)) { // Replace signed integer expression with -1 if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; + std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "-1")); @@ -431,7 +445,7 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(true, ast_context))) { // Replace expression with true if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_TRUE"; + std::string macro_name = "REPLACE_EXPR_TRUE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro( @@ -447,7 +461,7 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(false, ast_context))) { // Replace expression with false if (!only_track_mutant_coverage) { - const std::string macro_name = "REPLACE_EXPR_FALSE"; + std::string macro_name = "REPLACE_EXPR_FALSE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro( diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index 1b1064d1..d8f5f37c 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -305,9 +305,11 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( continue; } if (!only_track_mutant_coverage) { - const std::string macro_name = - "REPLACE_UNARY_" + OpKindToString(operator_kind); - new_function << " " << macro_name << "(" << mutation_id_offset << ")\n"; + std::string macro_name = "REPLACE_UNARY_" + OpKindToString(operator_kind); + if (unary_operator_->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; if (IsPrefix(operator_kind)) { dredd_macros.insert(GenerateMutationMacro( macro_name, @@ -329,8 +331,12 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( // another mutation. if (!optimise_mutations || !IsOperatorSelfInverse()) { if (!only_track_mutant_coverage) { - new_function << " MUTATION(" << mutation_id_offset << ", " - << arg_evaluated << ");\n"; + std::string macro_name = "REPLACE_UNARY_ARG"; + if (unary_operator_->HasSideEffects(ast_context)) { + macro_name += "_EVALUATED"; + } + new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; + dredd_macros.insert(GenerateMutationMacro(macro_name, arg_evaluated)); } AddMutationInstance( mutation_id_base, diff --git a/src/libdredd/src/util.cc b/src/libdredd/src/util.cc index dcf6546a..3adc5ff0 100644 --- a/src/libdredd/src/util.cc +++ b/src/libdredd/src/util.cc @@ -134,7 +134,7 @@ std::string GenerateMutationPrelude() { "return arg\n"; } -std::string GenerateMutationMacro(const std::string& name, +std::string GenerateMutationMacro(std::string& name, const std::string& args_evaluated) { return "#define " + name + "(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id " From 521c35fc06a8ac825d9fa941868aabf864a0014f Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 22:43:02 +0000 Subject: [PATCH 08/15] Fix macro name bug --- .../src/mutation_replace_binary_operator.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index b009a7ec..bce42990 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -281,7 +281,8 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( *binary_operator_->getLHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { std::string macro_name = "REPLACE_BINARY_ARG1"; - if (binary_operator_->getLHS()->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + binary_operator_->getLHS()->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; @@ -311,7 +312,9 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( *binary_operator_->getRHS(), -1.0, ast_context))) { if (!only_track_mutant_coverage) { std::string macro_name = "REPLACE_BINARY_ARG2"; - if (binary_operator_->getRHS()->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + (binary_operator_->isLogicalOp() || + binary_operator_->getRHS()->HasSideEffects(ast_context))) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; @@ -336,10 +339,13 @@ void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( if (!only_track_mutant_coverage) { std::string macro_name = "REPLACE_BINARY_" + OpKindToString(operator_kind); - if (binary_operator_->getLHS()->HasSideEffects(ast_context)) { - macro_name += "_RHS_EVALUATED"; + if (ast_context.getLangOpts().CPlusPlus && + binary_operator_->getLHS()->HasSideEffects(ast_context)) { + macro_name += "_LHS_EVALUATED"; } - if (binary_operator_->getLHS()->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + (binary_operator_->isLogicalOp() || + binary_operator_->getRHS()->HasSideEffects(ast_context))) { macro_name += "_RHS_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; From 8250e11bdc0b4ddf092c7405b1a51de21c49484c Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 23:05:11 +0000 Subject: [PATCH 09/15] Regenerate single_file tests --- src/libdredd/src/mutation_replace_expr.cc | 10 +- test/single_file/add.c.expected | 80 ++++--- test/single_file/add.c.noopt.expected | 56 +++-- test/single_file/add.cc.expected | 80 ++++--- test/single_file/add.cc.noopt.expected | 56 +++-- test/single_file/add_float.c.expected | 73 ++++--- test/single_file/add_float.c.noopt.expected | 96 +++++---- test/single_file/add_float.cc.expected | 73 ++++--- test/single_file/add_float.cc.noopt.expected | 96 +++++---- test/single_file/add_mul.c.expected | 97 +++++---- test/single_file/add_mul.c.noopt.expected | 73 ++++--- test/single_file/add_mul.cc.expected | 97 +++++---- test/single_file/add_mul.cc.noopt.expected | 73 ++++--- .../add_type_aliases.c.noopt.expected | 168 ++++++++------- .../add_type_aliases.cc.noopt.expected | 168 ++++++++------- test/single_file/assign.c.expected | 79 ++++--- test/single_file/assign.c.noopt.expected | 82 +++++--- test/single_file/assign.cc.expected | 79 ++++--- test/single_file/assign.cc.noopt.expected | 82 +++++--- test/single_file/auto.cc.expected | 48 +++-- test/single_file/auto.cc.noopt.expected | 34 +-- test/single_file/basic.c.expected | 12 +- test/single_file/basic.c.noopt.expected | 24 ++- test/single_file/basic.cc.expected | 12 +- test/single_file/basic.cc.noopt.expected | 24 ++- test/single_file/binary_lhs_zero.cc.expected | 66 +++--- .../binary_lhs_zero.cc.noopt.expected | 56 +++-- ..._long_and_long_name_clash.c.noopt.expected | 56 ++--- .../binary_no_arg_replacement.cc.expected | 85 ++++---- ...inary_no_arg_replacement.cc.noopt.expected | 92 ++++---- .../binary_operands_both_zero.c.expected | 111 ++++++---- ...binary_operands_both_zero.c.noopt.expected | 93 ++++++--- .../binary_operands_both_zero.cc.expected | 111 ++++++---- ...inary_operands_both_zero.cc.noopt.expected | 93 ++++++--- .../binary_redundant_name_clash.cc.expected | 49 +++-- ...ary_redundant_name_clash.cc.noopt.expected | 46 ++-- test/single_file/binary_rhs_zero.cc.expected | 66 +++--- .../binary_rhs_zero.cc.noopt.expected | 56 +++-- test/single_file/bitfield.c.expected | 24 ++- test/single_file/bitfield.c.noopt.expected | 24 ++- test/single_file/bitfield.cc.expected | 24 ++- test/single_file/bitfield.cc.noopt.expected | 43 ++-- test/single_file/bool_assignment.cc.expected | 16 +- .../bool_assignment.cc.noopt.expected | 15 +- ...lean_not_insertion_optimisation.c.expected | 24 ++- ...ot_insertion_optimisation.c.noopt.expected | 24 ++- ...ean_not_insertion_optimisation.cc.expected | 50 +++-- ...t_insertion_optimisation.cc.noopt.expected | 49 +++-- test/single_file/comma.c.expected | 58 +++--- test/single_file/comma.c.noopt.expected | 34 +-- test/single_file/comment.cc.expected | 9 +- test/single_file/comment.cc.noopt.expected | 15 +- .../comment_at_start_of_file.cc.expected | 21 +- ...comment_at_start_of_file.cc.noopt.expected | 24 ++- test/single_file/const_expr.cc.expected | 18 +- test/single_file/const_expr.cc.noopt.expected | 18 +- .../const_sized_array_int.c.expected | 12 +- .../const_sized_array_int.c.noopt.expected | 24 ++- .../const_sized_array_int.cc.expected | 12 +- .../const_sized_array_int.cc.noopt.expected | 24 ++- .../define_at_start_of_file.c.expected | 15 +- .../define_at_start_of_file.c.noopt.expected | 24 ++- .../define_in_first_decl.c.expected | 47 +++-- .../define_in_first_decl.c.noopt.expected | 46 ++-- .../define_in_first_decl.cc.expected | 47 +++-- .../define_in_first_decl.cc.noopt.expected | 46 ++-- test/single_file/enum.c.noopt.expected | 24 ++- test/single_file/expr_lvalue.c.expected | 82 +++++--- test/single_file/expr_lvalue.c.noopt.expected | 68 +++--- test/single_file/expr_lvalue.cc.expected | 82 +++++--- .../single_file/expr_lvalue.cc.noopt.expected | 68 +++--- test/single_file/expr_macro.c.expected | 2 + test/single_file/expr_macro.c.noopt.expected | 2 + test/single_file/expr_macro.cc.expected | 2 + test/single_file/expr_macro.cc.noopt.expected | 2 + test/single_file/float_binary_opts.c.expected | 53 +++-- .../float_binary_opts.c.noopt.expected | 37 ++-- .../single_file/float_binary_opts.cc.expected | 53 +++-- .../float_binary_opts.cc.noopt.expected | 37 ++-- test/single_file/float_unary_opt.c.expected | 21 +- .../float_unary_opt.c.noopt.expected | 28 ++- test/single_file/float_unary_opt.cc.expected | 21 +- .../float_unary_opt.cc.noopt.expected | 28 ++- test/single_file/floats.c.expected | 132 +++++++----- test/single_file/floats.c.noopt.expected | 124 ++++++----- test/single_file/floats.cc.expected | 132 +++++++----- test/single_file/floats.cc.noopt.expected | 124 ++++++----- test/single_file/initializer.c.expected | 56 +++-- test/single_file/initializer.c.noopt.expected | 56 +++-- test/single_file/initializer.cc.expected | 56 +++-- .../single_file/initializer.cc.noopt.expected | 56 +++-- test/single_file/initializer_list.cc.expected | 2 + .../initializer_list.cc.noopt.expected | 24 ++- test/single_file/lambda_capture.cc.expected | 38 ++-- .../lambda_capture.cc.noopt.expected | 24 ++- test/single_file/left_shift_opt.c.expected | 24 ++- .../left_shift_opt.c.noopt.expected | 37 ++-- test/single_file/left_shift_opt.cc.expected | 24 ++- .../left_shift_opt.cc.noopt.expected | 37 ++-- test/single_file/logical_and.c.expected | 34 +-- test/single_file/logical_and.c.noopt.expected | 34 +-- test/single_file/logical_and.cc.expected | 67 +++--- .../single_file/logical_and.cc.noopt.expected | 65 +++--- test/single_file/logical_and_div.cc.expected | 102 +++++---- .../logical_and_div.cc.noopt.expected | 109 ++++++---- test/single_file/logical_or.c.expected | 34 +-- test/single_file/logical_or.c.noopt.expected | 34 +-- test/single_file/logical_or.cc.expected | 67 +++--- test/single_file/logical_or.cc.noopt.expected | 65 +++--- test/single_file/misc002.cc.expected | 35 ++-- test/single_file/misc002.cc.noopt.expected | 61 ++++-- test/single_file/misc003.cc.expected | 2 + test/single_file/misc003.cc.noopt.expected | 2 + .../negative_switch_case.c.expected | 12 +- .../negative_switch_case.c.noopt.expected | 24 ++- .../negative_switch_case.cc.expected | 12 +- .../negative_switch_case.cc.noopt.expected | 24 ++- .../non_const_sized_array.c.expected | 70 ++++--- .../non_const_sized_array.c.noopt.expected | 56 +++-- .../non_const_sized_array.cc.expected | 21 +- .../non_const_sized_array.cc.noopt.expected | 24 ++- test/single_file/parens.cc.expected | 24 ++- test/single_file/parens.cc.noopt.expected | 34 +-- .../positive_int_as_minus_one.c.expected | 78 ++++--- ...positive_int_as_minus_one.c.noopt.expected | 84 +++++--- .../positive_int_as_minus_one.cc.expected | 78 ++++--- ...ositive_int_as_minus_one.cc.noopt.expected | 84 +++++--- test/single_file/post_inc_volatile.c.expected | 123 +++++++---- .../post_inc_volatile.c.noopt.expected | 109 ++++++---- .../single_file/post_inc_volatile.cc.expected | 142 ++++++++----- .../post_inc_volatile.cc.noopt.expected | 128 +++++++----- test/single_file/pre_dec_assign.cc.expected | 124 ++++++----- .../pre_dec_assign.cc.noopt.expected | 110 ++++++---- test/single_file/preprocessor_if.c.expected | 71 ++++--- .../preprocessor_if.c.noopt.expected | 74 ++++--- test/single_file/printing.c.expected | 2 + test/single_file/printing.c.noopt.expected | 24 ++- test/single_file/printing.cc.expected | 2 + test/single_file/printing.cc.noopt.expected | 2 + .../signed_int_constants.cc.expected | 74 ++++--- .../signed_int_constants.cc.noopt.expected | 47 +++-- test/single_file/sizeof_template.cc.expected | 18 +- .../sizeof_template.cc.noopt.expected | 18 +- test/single_file/sizeof_template2.cc.expected | 37 ++-- .../sizeof_template2.cc.noopt.expected | 49 +++-- .../static_initializer.cc.expected | 64 +++--- .../static_initializer.cc.noopt.expected | 56 +++-- .../structured_binding.cc.expected | 110 ++++++---- .../structured_binding.cc.noopt.expected | 108 ++++++---- test/single_file/template.cc.expected | 74 ++++--- test/single_file/template.cc.noopt.expected | 77 ++++--- .../template_instantiation.cc.expected | 12 +- .../template_instantiation.cc.noopt.expected | 24 ++- test/single_file/typedef.c.noopt.expected | 46 ++-- test/single_file/typedef.cc.noopt.expected | 46 ++-- test/single_file/unary.c.expected | 185 +++++++++------- test/single_file/unary.c.noopt.expected | 186 ++++++++++------- test/single_file/unary.cc.expected | 165 ++++++++------- test/single_file/unary.cc.noopt.expected | 197 ++++++++++-------- test/single_file/unary_logical_not.c.expected | 52 +++-- .../unary_logical_not.c.noopt.expected | 49 +++-- .../single_file/unary_logical_not.cc.expected | 52 +++-- .../unary_logical_not.cc.noopt.expected | 49 +++-- test/single_file/unary_minus.c.expected | 54 +++-- test/single_file/unary_minus.c.noopt.expected | 47 +++-- test/single_file/unary_minus.cc.expected | 54 +++-- .../single_file/unary_minus.cc.noopt.expected | 47 +++-- .../single_file/unary_operator_opt.c.expected | 54 +++-- .../unary_operator_opt.c.noopt.expected | 48 +++-- test/single_file/unsigned_int.c.expected | 64 +++--- .../single_file/unsigned_int.c.noopt.expected | 60 +++--- test/single_file/unsigned_int.cc.expected | 63 +++--- .../unsigned_int.cc.noopt.expected | 72 ++++--- test/single_file/using.cc.noopt.expected | 46 ++-- test/single_file/volatile.c.expected | 55 +++-- test/single_file/volatile.c.noopt.expected | 58 ++++-- test/single_file/volatile.cc.expected | 55 +++-- test/single_file/volatile.cc.noopt.expected | 58 ++++-- 178 files changed, 6149 insertions(+), 3823 deletions(-) diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 3b996315..7ef5b249 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -187,7 +187,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( } if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_INC"; - if (expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; @@ -200,7 +200,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_DEC"; - if (expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; @@ -229,7 +229,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_LNOT"; - if (expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset @@ -249,7 +249,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_NOT"; - if (expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset @@ -269,7 +269,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_MINUS"; - if (expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset diff --git a/test/single_file/add.c.expected b/test/single_file/add.c.expected index a5a6b094..288a4819 100644 --- a/test/single_file/add.c.expected +++ b/test/single_file/add.c.expected @@ -40,51 +40,67 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add.c.noopt.expected b/test/single_file/add.c.noopt.expected index 60632ba4..27ee0a40 100644 --- a/test/single_file/add.c.noopt.expected +++ b/test/single_file/add.c.noopt.expected @@ -40,33 +40,49 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add.cc.expected b/test/single_file/add.cc.expected index b4286cba..159053d7 100644 --- a/test/single_file/add.cc.expected +++ b/test/single_file/add.cc.expected @@ -42,51 +42,67 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add.cc.noopt.expected b/test/single_file/add.cc.noopt.expected index d80b67a4..cfa2aa18 100644 --- a/test/single_file/add.cc.noopt.expected +++ b/test/single_file/add.cc.noopt.expected @@ -42,33 +42,49 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add_float.c.expected b/test/single_file/add_float.c.expected index dc5a9f3c..d6aa6667 100644 --- a/test/single_file/add_float.c.expected +++ b/test/single_file/add_float.c.expected @@ -40,46 +40,65 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float_lvalue(float* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static float __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float* arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) -= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN((*arg1) = arg2); } static float __dredd_replace_binary_operator_Add_arg1_float_arg2_float(float arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add_float.c.noopt.expected b/test/single_file/add_float.c.noopt.expected index cbc735e5..615f1801 100644 --- a/test/single_file/add_float.c.noopt.expected +++ b/test/single_file/add_float.c.noopt.expected @@ -40,59 +40,81 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float_lvalue(float* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static float __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float* arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) -= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN((*arg1) = arg2); } static float __dredd_replace_binary_operator_Add_arg1_float_arg2_float(float arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/add_float.cc.expected b/test/single_file/add_float.cc.expected index bd19dacf..b816d465 100644 --- a/test/single_file/add_float.cc.expected +++ b/test/single_file/add_float.cc.expected @@ -42,46 +42,65 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static float& __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float& arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 -= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN(arg1 = arg2); } static float __dredd_replace_expr_float_lvalue(float& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static float __dredd_replace_binary_operator_Add_arg1_float_arg2_float(float arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add_float.cc.noopt.expected b/test/single_file/add_float.cc.noopt.expected index 64c3ffc2..831c87ab 100644 --- a/test/single_file/add_float.cc.noopt.expected +++ b/test/single_file/add_float.cc.noopt.expected @@ -42,59 +42,81 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float& __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float& arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 -= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN(arg1 = arg2); } static float __dredd_replace_expr_float_lvalue(float& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static float __dredd_replace_binary_operator_Add_arg1_float_arg2_float(float arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/add_mul.c.expected b/test/single_file/add_mul.c.expected index 8fee7775..bae545d0 100644 --- a/test/single_file/add_mul.c.expected +++ b/test/single_file/add_mul.c.expected @@ -40,62 +40,79 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Mul_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 * arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add_mul.c.noopt.expected b/test/single_file/add_mul.c.noopt.expected index 688b1c5b..d452e83f 100644 --- a/test/single_file/add_mul.c.noopt.expected +++ b/test/single_file/add_mul.c.noopt.expected @@ -40,44 +40,61 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Mul_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 * arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add_mul.cc.expected b/test/single_file/add_mul.cc.expected index 3e37d850..c59d3c8c 100644 --- a/test/single_file/add_mul.cc.expected +++ b/test/single_file/add_mul.cc.expected @@ -42,62 +42,79 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Mul_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 * arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add_mul.cc.noopt.expected b/test/single_file/add_mul.cc.noopt.expected index 5089250e..afeff625 100644 --- a/test/single_file/add_mul.cc.noopt.expected +++ b/test/single_file/add_mul.cc.noopt.expected @@ -42,44 +42,61 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Mul_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 * arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/add_type_aliases.c.noopt.expected b/test/single_file/add_type_aliases.c.noopt.expected index 00424d5f..ca44509d 100644 --- a/test/single_file/add_type_aliases.c.noopt.expected +++ b/test/single_file/add_type_aliases.c.noopt.expected @@ -40,116 +40,132 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long_lvalue(unsigned 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static unsigned long __dredd_replace_expr_unsigned_long(unsigned 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned long __dredd_replace_binary_operator_Add_arg1_unsigned_long_arg2_unsigned_long(unsigned long arg1, unsigned long arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_binary_operator_Add_arg1_unsigned_int_arg2_unsigned_int(unsigned int arg1, unsigned int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } static long __dredd_replace_expr_long_lvalue(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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static long __dredd_replace_binary_operator_Add_arg1_long_arg2_long(long arg1, long arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } #include diff --git a/test/single_file/add_type_aliases.cc.noopt.expected b/test/single_file/add_type_aliases.cc.noopt.expected index 087aed5a..6f47544c 100644 --- a/test/single_file/add_type_aliases.cc.noopt.expected +++ b/test/single_file/add_type_aliases.cc.noopt.expected @@ -42,116 +42,132 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long_lvalue(unsigned 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static unsigned long __dredd_replace_expr_unsigned_long(unsigned 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned long __dredd_replace_binary_operator_Add_arg1_unsigned_long_arg2_unsigned_long(unsigned long arg1, unsigned long arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_binary_operator_Add_arg1_unsigned_int_arg2_unsigned_int(unsigned int arg1, unsigned int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } static long __dredd_replace_expr_long_lvalue(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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static long __dredd_replace_binary_operator_Add_arg1_long_arg2_long(long arg1, long arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } #include diff --git a/test/single_file/assign.c.expected b/test/single_file/assign.c.expected index c94e399a..3cf00b9e 100644 --- a/test/single_file/assign.c.expected +++ b/test/single_file/assign.c.expected @@ -40,44 +40,61 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } int main() { diff --git a/test/single_file/assign.c.noopt.expected b/test/single_file/assign.c.noopt.expected index 882db8bf..5a3a5e59 100644 --- a/test/single_file/assign.c.noopt.expected +++ b/test/single_file/assign.c.noopt.expected @@ -40,45 +40,63 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } int main() { diff --git a/test/single_file/assign.cc.expected b/test/single_file/assign.cc.expected index 1d358437..8bcff7f2 100644 --- a/test/single_file/assign.cc.expected +++ b/test/single_file/assign.cc.expected @@ -42,44 +42,61 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/assign.cc.noopt.expected b/test/single_file/assign.cc.noopt.expected index 385d29f1..66653ea2 100644 --- a/test/single_file/assign.cc.noopt.expected +++ b/test/single_file/assign.cc.noopt.expected @@ -42,45 +42,63 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/auto.cc.expected b/test/single_file/auto.cc.expected index 317b0f50..d3850dda 100644 --- a/test/single_file/auto.cc.expected +++ b/test/single_file/auto.cc.expected @@ -42,32 +42,42 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int foo(int x) { diff --git a/test/single_file/auto.cc.noopt.expected b/test/single_file/auto.cc.noopt.expected index a039fbbf..d7805bbb 100644 --- a/test/single_file/auto.cc.noopt.expected +++ b/test/single_file/auto.cc.noopt.expected @@ -42,22 +42,32 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int foo(int x) { diff --git a/test/single_file/basic.c.expected b/test/single_file/basic.c.expected index e36beb46..79933fbc 100644 --- a/test/single_file/basic.c.expected +++ b/test/single_file/basic.c.expected @@ -40,11 +40,15 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/basic.c.noopt.expected b/test/single_file/basic.c.noopt.expected index f9efca8c..c9997672 100644 --- a/test/single_file/basic.c.noopt.expected +++ b/test/single_file/basic.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/basic.cc.expected b/test/single_file/basic.cc.expected index db57b374..2b5b82a7 100644 --- a/test/single_file/basic.cc.expected +++ b/test/single_file/basic.cc.expected @@ -42,11 +42,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/basic.cc.noopt.expected b/test/single_file/basic.cc.noopt.expected index f3a7eee8..53492aab 100644 --- a/test/single_file/basic.cc.noopt.expected +++ b/test/single_file/basic.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/binary_lhs_zero.cc.expected b/test/single_file/binary_lhs_zero.cc.expected index 12a7aad8..7174fbb1 100644 --- a/test/single_file/binary_lhs_zero.cc.expected +++ b/test/single_file/binary_lhs_zero.cc.expected @@ -42,46 +42,58 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_lhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Sub(0); + REPLACE_BINARY_ARG2(1); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_lhs_zero.cc.noopt.expected b/test/single_file/binary_lhs_zero.cc.noopt.expected index eb2343a1..820fe5f8 100644 --- a/test/single_file/binary_lhs_zero.cc.noopt.expected +++ b/test/single_file/binary_lhs_zero.cc.noopt.expected @@ -42,33 +42,49 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected b/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected index a92421c5..32c68f73 100644 --- a/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected +++ b/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static long long __dredd_replace_binary_operator_LAnd_arg1_long_long_arg2_long_lhs(long long arg, int local_mutation_id) { @@ -64,14 +72,14 @@ static long long __dredd_replace_binary_operator_LAnd_arg1_long_arg2_long_long_r 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static long __dredd_replace_binary_operator_LAnd_arg1_long_long_arg2_long_rhs(long arg, int local_mutation_id) { @@ -87,14 +95,14 @@ static long __dredd_replace_binary_operator_LAnd_arg1_long_arg2_long_long_lhs(lo return arg; } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_LAnd_arg1_long_long_arg2_long_outer(int arg, int local_mutation_id) { diff --git a/test/single_file/binary_no_arg_replacement.cc.expected b/test/single_file/binary_no_arg_replacement.cc.expected index 88fadba9..92fbaa28 100644 --- a/test/single_file/binary_no_arg_replacement.cc.expected +++ b/test/single_file/binary_no_arg_replacement.cc.expected @@ -42,61 +42,74 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return 1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ZERO(0); + REPLACE_EXPR_INT_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Sub_arg1_int_arg2_int_lhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg2; - return arg1 - arg2; + MUTATION_PRELUDE(arg1 - arg2); + REPLACE_BINARY_ARG2(0); + return MUTATION_RETURN(arg1 - arg2); } static int __dredd_replace_binary_operator_Mul_arg1_int_arg2_int_lhs_minus_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 * arg2); } static int __dredd_replace_binary_operator_Div_arg1_int_arg2_int_rhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - return arg1 / arg2; + MUTATION_PRELUDE(arg1 / arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Rem(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + return MUTATION_RETURN(arg1 / arg2); } int main() { diff --git a/test/single_file/binary_no_arg_replacement.cc.noopt.expected b/test/single_file/binary_no_arg_replacement.cc.noopt.expected index 954edb87..f8c3fa59 100644 --- a/test/single_file/binary_no_arg_replacement.cc.noopt.expected +++ b/test/single_file/binary_no_arg_replacement.cc.noopt.expected @@ -42,56 +42,74 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Sub_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 - arg2; + MUTATION_PRELUDE(arg1 - arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Mul(2); + REPLACE_BINARY_Rem(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 - arg2); } static int __dredd_replace_binary_operator_Mul_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 * arg2); } static int __dredd_replace_binary_operator_Div_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 / arg2; + MUTATION_PRELUDE(arg1 / arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 / arg2); } int main() { diff --git a/test/single_file/binary_operands_both_zero.c.expected b/test/single_file/binary_operands_both_zero.c.expected index 77c6b73a..98926e11 100644 --- a/test/single_file/binary_operands_both_zero.c.expected +++ b/test/single_file/binary_operands_both_zero.c.expected @@ -40,80 +40,99 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return 1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ZERO(0); + REPLACE_EXPR_INT_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero_lhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero_lhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero_lhs_minus_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_one_lhs_minus_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 - arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Rem(0); + REPLACE_BINARY_Sub(1); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_minus_one_lhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 - arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Sub(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_minus_one_lhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Rem(1); + REPLACE_BINARY_Sub(2); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_operands_both_zero.c.noopt.expected b/test/single_file/binary_operands_both_zero.c.noopt.expected index 4431ace9..8373db7e 100644 --- a/test/single_file/binary_operands_both_zero.c.noopt.expected +++ b/test/single_file/binary_operands_both_zero.c.noopt.expected @@ -40,49 +40,76 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_operands_both_zero.cc.expected b/test/single_file/binary_operands_both_zero.cc.expected index d6c3d2a6..595a467a 100644 --- a/test/single_file/binary_operands_both_zero.cc.expected +++ b/test/single_file/binary_operands_both_zero.cc.expected @@ -42,80 +42,99 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return 1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ZERO(0); + REPLACE_EXPR_INT_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero_lhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero_lhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero_lhs_minus_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_one_lhs_minus_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 - arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Rem(0); + REPLACE_BINARY_Sub(1); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_minus_one_lhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 - arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Sub(0); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_minus_one_lhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Rem(1); + REPLACE_BINARY_Sub(2); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_operands_both_zero.cc.noopt.expected b/test/single_file/binary_operands_both_zero.cc.noopt.expected index 5971e60c..0a9f99de 100644 --- a/test/single_file/binary_operands_both_zero.cc.noopt.expected +++ b/test/single_file/binary_operands_both_zero.cc.noopt.expected @@ -42,49 +42,76 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_redundant_name_clash.cc.expected b/test/single_file/binary_redundant_name_clash.cc.expected index d37cd99e..7e5e1274 100644 --- a/test/single_file/binary_redundant_name_clash.cc.expected +++ b/test/single_file/binary_redundant_name_clash.cc.expected @@ -42,35 +42,46 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_ARG1(1); + return MUTATION_RETURN(arg1 + arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_lhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Sub(0); + REPLACE_BINARY_ARG2(1); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_redundant_name_clash.cc.noopt.expected b/test/single_file/binary_redundant_name_clash.cc.noopt.expected index 5112204c..df706e12 100644 --- a/test/single_file/binary_redundant_name_clash.cc.noopt.expected +++ b/test/single_file/binary_redundant_name_clash.cc.noopt.expected @@ -42,26 +42,40 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_rhs_zero.cc.expected b/test/single_file/binary_rhs_zero.cc.expected index dfdc5bd0..fc397f89 100644 --- a/test/single_file/binary_rhs_zero.cc.expected +++ b/test/single_file/binary_rhs_zero.cc.expected @@ -42,46 +42,58 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_rhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_ARG1(1); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/binary_rhs_zero.cc.noopt.expected b/test/single_file/binary_rhs_zero.cc.noopt.expected index 1dd5fcc3..15f3c26a 100644 --- a/test/single_file/binary_rhs_zero.cc.noopt.expected +++ b/test/single_file/binary_rhs_zero.cc.noopt.expected @@ -42,33 +42,49 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/bitfield.c.expected b/test/single_file/bitfield.c.expected index dff8db80..1ef22c56 100644 --- a/test/single_file/bitfield.c.expected +++ b/test/single_file/bitfield.c.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } struct S { diff --git a/test/single_file/bitfield.c.noopt.expected b/test/single_file/bitfield.c.noopt.expected index 0a0d422e..887bf4c5 100644 --- a/test/single_file/bitfield.c.noopt.expected +++ b/test/single_file/bitfield.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } struct S { diff --git a/test/single_file/bitfield.cc.expected b/test/single_file/bitfield.cc.expected index d1b84430..aa57f3be 100644 --- a/test/single_file/bitfield.cc.expected +++ b/test/single_file/bitfield.cc.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } struct S { diff --git a/test/single_file/bitfield.cc.noopt.expected b/test/single_file/bitfield.cc.noopt.expected index 8e478536..8e031c80 100644 --- a/test/single_file/bitfield.cc.noopt.expected +++ b/test/single_file/bitfield.cc.noopt.expected @@ -42,26 +42,37 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } struct S { diff --git a/test/single_file/bool_assignment.cc.expected b/test/single_file/bool_assignment.cc.expected index c65e6601..57883838 100644 --- a/test/single_file/bool_assignment.cc.expected +++ b/test/single_file/bool_assignment.cc.expected @@ -42,16 +42,20 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FALSE(0); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool_false(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/bool_assignment.cc.noopt.expected b/test/single_file/bool_assignment.cc.noopt.expected index 763360fc..abbcc4be 100644 --- a/test/single_file/bool_assignment.cc.noopt.expected +++ b/test/single_file/bool_assignment.cc.noopt.expected @@ -42,12 +42,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/boolean_not_insertion_optimisation.c.expected b/test/single_file/boolean_not_insertion_optimisation.c.expected index 69dc6968..bdf6b810 100644 --- a/test/single_file/boolean_not_insertion_optimisation.c.expected +++ b/test/single_file/boolean_not_insertion_optimisation.c.expected @@ -40,19 +40,25 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_LAnd_arg1_int_arg2_int_rhs_zero_lhs_one_rhs(int arg, int local_mutation_id) { diff --git a/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected b/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected index a5e6a206..5fe8ad4a 100644 --- a/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected +++ b/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_LAnd_arg1_int_arg2_int_rhs(int arg, int local_mutation_id) { diff --git a/test/single_file/boolean_not_insertion_optimisation.cc.expected b/test/single_file/boolean_not_insertion_optimisation.cc.expected index ac0fa3ab..0b8b3ef9 100644 --- a/test/single_file/boolean_not_insertion_optimisation.cc.expected +++ b/test/single_file/boolean_not_insertion_optimisation.cc.expected @@ -42,31 +42,45 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool& __dredd_replace_binary_operator_Assign_arg1_bool_arg2_bool(bool& arg1, bool arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FALSE(0); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool_false(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected b/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected index be92bb0c..60b5a553 100644 --- a/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected +++ b/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected @@ -42,27 +42,42 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool& __dredd_replace_binary_operator_Assign_arg1_bool_arg2_bool(bool& arg1, bool arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/comma.c.expected b/test/single_file/comma.c.expected index aacbccab..f03d28f4 100644 --- a/test/single_file/comma.c.expected +++ b/test/single_file/comma.c.expected @@ -40,40 +40,50 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/comma.c.noopt.expected b/test/single_file/comma.c.noopt.expected index b00aa6db..454aa664 100644 --- a/test/single_file/comma.c.noopt.expected +++ b/test/single_file/comma.c.noopt.expected @@ -40,22 +40,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/comment.cc.expected b/test/single_file/comment.cc.expected index 5644bba2..2e7abd78 100644 --- a/test/single_file/comment.cc.expected +++ b/test/single_file/comment.cc.expected @@ -42,10 +42,13 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FALSE(0); + return MUTATION_RETURN(arg); } void g(); diff --git a/test/single_file/comment.cc.noopt.expected b/test/single_file/comment.cc.noopt.expected index 9ede8102..50d92bce 100644 --- a/test/single_file/comment.cc.noopt.expected +++ b/test/single_file/comment.cc.noopt.expected @@ -42,12 +42,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } void g(); diff --git a/test/single_file/comment_at_start_of_file.cc.expected b/test/single_file/comment_at_start_of_file.cc.expected index 119a05d0..7d59ca50 100644 --- a/test/single_file/comment_at_start_of_file.cc.expected +++ b/test/single_file/comment_at_start_of_file.cc.expected @@ -42,14 +42,21 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } // Hello diff --git a/test/single_file/comment_at_start_of_file.cc.noopt.expected b/test/single_file/comment_at_start_of_file.cc.noopt.expected index 055ec6ff..45536b3b 100644 --- a/test/single_file/comment_at_start_of_file.cc.noopt.expected +++ b/test/single_file/comment_at_start_of_file.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } // Hello diff --git a/test/single_file/const_expr.cc.expected b/test/single_file/const_expr.cc.expected index 88367221..216f5cb0 100644 --- a/test/single_file/const_expr.cc.expected +++ b/test/single_file/const_expr.cc.expected @@ -42,13 +42,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } double foo(const double &x) { diff --git a/test/single_file/const_expr.cc.noopt.expected b/test/single_file/const_expr.cc.noopt.expected index 88367221..216f5cb0 100644 --- a/test/single_file/const_expr.cc.noopt.expected +++ b/test/single_file/const_expr.cc.noopt.expected @@ -42,13 +42,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } double foo(const double &x) { diff --git a/test/single_file/const_sized_array_int.c.expected b/test/single_file/const_sized_array_int.c.expected index dd93f512..42e522f6 100644 --- a/test/single_file/const_sized_array_int.c.expected +++ b/test/single_file/const_sized_array_int.c.expected @@ -40,11 +40,15 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/const_sized_array_int.c.noopt.expected b/test/single_file/const_sized_array_int.c.noopt.expected index cd8aae0b..06f47bd0 100644 --- a/test/single_file/const_sized_array_int.c.noopt.expected +++ b/test/single_file/const_sized_array_int.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/const_sized_array_int.cc.expected b/test/single_file/const_sized_array_int.cc.expected index 24965833..f79eaab9 100644 --- a/test/single_file/const_sized_array_int.cc.expected +++ b/test/single_file/const_sized_array_int.cc.expected @@ -42,11 +42,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/const_sized_array_int.cc.noopt.expected b/test/single_file/const_sized_array_int.cc.noopt.expected index 32c47e62..f91c5d43 100644 --- a/test/single_file/const_sized_array_int.cc.noopt.expected +++ b/test/single_file/const_sized_array_int.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/define_at_start_of_file.c.expected b/test/single_file/define_at_start_of_file.c.expected index ccd687c2..bcd2afbe 100644 --- a/test/single_file/define_at_start_of_file.c.expected +++ b/test/single_file/define_at_start_of_file.c.expected @@ -40,12 +40,17 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } #define API diff --git a/test/single_file/define_at_start_of_file.c.noopt.expected b/test/single_file/define_at_start_of_file.c.noopt.expected index 3fd27dba..9be0d734 100644 --- a/test/single_file/define_at_start_of_file.c.noopt.expected +++ b/test/single_file/define_at_start_of_file.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } #define API diff --git a/test/single_file/define_in_first_decl.c.expected b/test/single_file/define_in_first_decl.c.expected index 8757e783..f2027796 100644 --- a/test/single_file/define_in_first_decl.c.expected +++ b/test/single_file/define_in_first_decl.c.expected @@ -40,31 +40,42 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_lhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Rem(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG2(3); + return MUTATION_RETURN(arg1 + arg2); } #define TYPE int diff --git a/test/single_file/define_in_first_decl.c.noopt.expected b/test/single_file/define_in_first_decl.c.noopt.expected index 9907f2b6..07a40364 100644 --- a/test/single_file/define_in_first_decl.c.noopt.expected +++ b/test/single_file/define_in_first_decl.c.noopt.expected @@ -40,26 +40,40 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } #define TYPE int diff --git a/test/single_file/define_in_first_decl.cc.expected b/test/single_file/define_in_first_decl.cc.expected index 43d7a6eb..c5e71bf4 100644 --- a/test/single_file/define_in_first_decl.cc.expected +++ b/test/single_file/define_in_first_decl.cc.expected @@ -42,31 +42,42 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_lhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Rem(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG2(3); + return MUTATION_RETURN(arg1 + arg2); } #define TYPE int diff --git a/test/single_file/define_in_first_decl.cc.noopt.expected b/test/single_file/define_in_first_decl.cc.noopt.expected index 35c42a24..2dde7807 100644 --- a/test/single_file/define_in_first_decl.cc.noopt.expected +++ b/test/single_file/define_in_first_decl.cc.noopt.expected @@ -42,26 +42,40 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } #define TYPE int diff --git a/test/single_file/enum.c.noopt.expected b/test/single_file/enum.c.noopt.expected index b620bec1..ebe1e7ca 100644 --- a/test/single_file/enum.c.noopt.expected +++ b/test/single_file/enum.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } enum A { diff --git a/test/single_file/expr_lvalue.c.expected b/test/single_file/expr_lvalue.c.expected index 33557f17..b0c337d9 100644 --- a/test/single_file/expr_lvalue.c.expected +++ b/test/single_file/expr_lvalue.c.expected @@ -40,47 +40,67 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } int main() { diff --git a/test/single_file/expr_lvalue.c.noopt.expected b/test/single_file/expr_lvalue.c.noopt.expected index 37f9faf5..6e3546a8 100644 --- a/test/single_file/expr_lvalue.c.noopt.expected +++ b/test/single_file/expr_lvalue.c.noopt.expected @@ -40,37 +40,57 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } int main() { diff --git a/test/single_file/expr_lvalue.cc.expected b/test/single_file/expr_lvalue.cc.expected index 508141c4..8afd1b22 100644 --- a/test/single_file/expr_lvalue.cc.expected +++ b/test/single_file/expr_lvalue.cc.expected @@ -42,47 +42,67 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/expr_lvalue.cc.noopt.expected b/test/single_file/expr_lvalue.cc.noopt.expected index 1031ae7f..77a6ed0c 100644 --- a/test/single_file/expr_lvalue.cc.noopt.expected +++ b/test/single_file/expr_lvalue.cc.noopt.expected @@ -42,37 +42,57 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/expr_macro.c.expected b/test/single_file/expr_macro.c.expected index 73200131..db616c30 100644 --- a/test/single_file/expr_macro.c.expected +++ b/test/single_file/expr_macro.c.expected @@ -40,6 +40,8 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #define E (1, 2, 3) void foo(int, int, int); diff --git a/test/single_file/expr_macro.c.noopt.expected b/test/single_file/expr_macro.c.noopt.expected index 73200131..db616c30 100644 --- a/test/single_file/expr_macro.c.noopt.expected +++ b/test/single_file/expr_macro.c.noopt.expected @@ -40,6 +40,8 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #define E (1, 2, 3) void foo(int, int, int); diff --git a/test/single_file/expr_macro.cc.expected b/test/single_file/expr_macro.cc.expected index aa120ead..7fd8b13c 100644 --- a/test/single_file/expr_macro.cc.expected +++ b/test/single_file/expr_macro.cc.expected @@ -42,6 +42,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #define E (1, 2, 3) void foo(int, int, int); diff --git a/test/single_file/expr_macro.cc.noopt.expected b/test/single_file/expr_macro.cc.noopt.expected index aa120ead..7fd8b13c 100644 --- a/test/single_file/expr_macro.cc.noopt.expected +++ b/test/single_file/expr_macro.cc.noopt.expected @@ -42,6 +42,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #define E (1, 2, 3) void foo(int, int, int); diff --git a/test/single_file/float_binary_opts.c.expected b/test/single_file/float_binary_opts.c.expected index 1922cb7a..181607ac 100644 --- a/test/single_file/float_binary_opts.c.expected +++ b/test/single_file/float_binary_opts.c.expected @@ -40,37 +40,48 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double_zero(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ONE(0); + REPLACE_EXPR_FLOAT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double_lhs_zero(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Sub(0); + REPLACE_BINARY_ARG2(1); + return MUTATION_RETURN(arg1 + arg2); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/float_binary_opts.c.noopt.expected b/test/single_file/float_binary_opts.c.noopt.expected index 0e238cdc..d202e4c4 100644 --- a/test/single_file/float_binary_opts.c.noopt.expected +++ b/test/single_file/float_binary_opts.c.noopt.expected @@ -40,23 +40,34 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/float_binary_opts.cc.expected b/test/single_file/float_binary_opts.cc.expected index 42f247ee..e42992aa 100644 --- a/test/single_file/float_binary_opts.cc.expected +++ b/test/single_file/float_binary_opts.cc.expected @@ -42,37 +42,48 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double_zero(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ONE(0); + REPLACE_EXPR_FLOAT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double_lhs_zero(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Sub(0); + REPLACE_BINARY_ARG2(1); + return MUTATION_RETURN(arg1 + arg2); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/float_binary_opts.cc.noopt.expected b/test/single_file/float_binary_opts.cc.noopt.expected index bf50951b..ba9e4957 100644 --- a/test/single_file/float_binary_opts.cc.noopt.expected +++ b/test/single_file/float_binary_opts.cc.noopt.expected @@ -42,23 +42,34 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/float_unary_opt.c.expected b/test/single_file/float_unary_opt.c.expected index feded92d..3b986a31 100644 --- a/test/single_file/float_unary_opt.c.expected +++ b/test/single_file/float_unary_opt.c.expected @@ -40,18 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double_one(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ZERO(0); + REPLACE_EXPR_FLOAT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double_minus_one(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return 1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ZERO(0); + REPLACE_EXPR_FLOAT_ONE(1); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/float_unary_opt.c.noopt.expected b/test/single_file/float_unary_opt.c.noopt.expected index b93bb429..2d1a74c3 100644 --- a/test/single_file/float_unary_opt.c.noopt.expected +++ b/test/single_file/float_unary_opt.c.noopt.expected @@ -40,20 +40,28 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_unary_operator_Minus_double(double 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_LNot(0); + REPLACE_UNARY_ARG(1); + return MUTATION_RETURN(-arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/float_unary_opt.cc.expected b/test/single_file/float_unary_opt.cc.expected index 5b202832..8e082a8c 100644 --- a/test/single_file/float_unary_opt.cc.expected +++ b/test/single_file/float_unary_opt.cc.expected @@ -42,18 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double_one(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ZERO(0); + REPLACE_EXPR_FLOAT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double_minus_one(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return 1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ZERO(0); + REPLACE_EXPR_FLOAT_ONE(1); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/float_unary_opt.cc.noopt.expected b/test/single_file/float_unary_opt.cc.noopt.expected index b397aef5..9d81ffa0 100644 --- a/test/single_file/float_unary_opt.cc.noopt.expected +++ b/test/single_file/float_unary_opt.cc.noopt.expected @@ -42,20 +42,28 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_unary_operator_Minus_double(double 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_LNot(0); + REPLACE_UNARY_ARG(1); + return MUTATION_RETURN(-arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/floats.c.expected b/test/single_file/floats.c.expected index d00939b0..df0bff24 100644 --- a/test/single_file/floats.c.expected +++ b/test/single_file/floats.c.expected @@ -40,85 +40,109 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static float __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(float* arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - return (*arg1) -= arg2; + MUTATION_PRELUDE((*arg1) -= arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + return MUTATION_RETURN((*arg1) -= arg2); } static double __dredd_replace_expr_double_one(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ZERO(0); + REPLACE_EXPR_FLOAT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double_lvalue(double* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Mul_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 * arg2); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } static double __dredd_replace_binary_operator_AddAssign_arg1_double_arg2_double(double* arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) -= arg2; - return (*arg1) += arg2; + MUTATION_PRELUDE((*arg1) += arg2); + REPLACE_BINARY_Assign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN((*arg1) += arg2); } int main() { diff --git a/test/single_file/floats.c.noopt.expected b/test/single_file/floats.c.noopt.expected index a59d9f2c..18d3583b 100644 --- a/test/single_file/floats.c.noopt.expected +++ b/test/single_file/floats.c.noopt.expected @@ -40,78 +40,102 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static float __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(float* arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - return (*arg1) -= arg2; + MUTATION_PRELUDE((*arg1) -= arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + return MUTATION_RETURN((*arg1) -= arg2); } static double __dredd_replace_expr_double_lvalue(double* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Mul_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 * arg2); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } static double __dredd_replace_binary_operator_AddAssign_arg1_double_arg2_double(double* arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) -= arg2; - return (*arg1) += arg2; + MUTATION_PRELUDE((*arg1) += arg2); + REPLACE_BINARY_Assign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN((*arg1) += arg2); } int main() { diff --git a/test/single_file/floats.cc.expected b/test/single_file/floats.cc.expected index 2c819fad..9f71b759 100644 --- a/test/single_file/floats.cc.expected +++ b/test/single_file/floats.cc.expected @@ -42,85 +42,109 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 = arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float& __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(float& arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - return arg1 -= arg2; + MUTATION_PRELUDE(arg1 -= arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + return MUTATION_RETURN(arg1 -= arg2); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double& __dredd_replace_binary_operator_AddAssign_arg1_double_arg2_double(double& arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 -= arg2; - return arg1 += arg2; + MUTATION_PRELUDE(arg1 += arg2); + REPLACE_BINARY_Assign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN(arg1 += arg2); } static double __dredd_replace_expr_double_one(double arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0.0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FLOAT_ZERO(0); + REPLACE_EXPR_FLOAT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double_lvalue(double& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Mul_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 * arg2); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/floats.cc.noopt.expected b/test/single_file/floats.cc.noopt.expected index 45dd2aca..64b2e258 100644 --- a/test/single_file/floats.cc.noopt.expected +++ b/test/single_file/floats.cc.noopt.expected @@ -42,78 +42,102 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 = arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float& __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(float& arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - return arg1 -= arg2; + MUTATION_PRELUDE(arg1 -= arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + return MUTATION_RETURN(arg1 -= arg2); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double& __dredd_replace_binary_operator_AddAssign_arg1_double_arg2_double(double& arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 -= arg2; - return arg1 += arg2; + MUTATION_PRELUDE(arg1 += arg2); + REPLACE_BINARY_Assign(0); + REPLACE_BINARY_DivAssign(1); + REPLACE_BINARY_MulAssign(2); + REPLACE_BINARY_SubAssign(3); + return MUTATION_RETURN(arg1 += arg2); } static double __dredd_replace_expr_double_lvalue(double& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_binary_operator_Mul_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 * arg2; + MUTATION_PRELUDE(arg1 * arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 * arg2); } static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/initializer.c.expected b/test/single_file/initializer.c.expected index a853cdb3..5d344570 100644 --- a/test/single_file/initializer.c.expected +++ b/test/single_file/initializer.c.expected @@ -40,33 +40,49 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo(int a, int b) { diff --git a/test/single_file/initializer.c.noopt.expected b/test/single_file/initializer.c.noopt.expected index a853cdb3..5d344570 100644 --- a/test/single_file/initializer.c.noopt.expected +++ b/test/single_file/initializer.c.noopt.expected @@ -40,33 +40,49 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo(int a, int b) { diff --git a/test/single_file/initializer.cc.expected b/test/single_file/initializer.cc.expected index 15a47d8c..f97a1450 100644 --- a/test/single_file/initializer.cc.expected +++ b/test/single_file/initializer.cc.expected @@ -42,33 +42,49 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo(int a, int b) { diff --git a/test/single_file/initializer.cc.noopt.expected b/test/single_file/initializer.cc.noopt.expected index 15a47d8c..f97a1450 100644 --- a/test/single_file/initializer.cc.noopt.expected +++ b/test/single_file/initializer.cc.noopt.expected @@ -42,33 +42,49 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo(int a, int b) { diff --git a/test/single_file/initializer_list.cc.expected b/test/single_file/initializer_list.cc.expected index 8332313d..8adc3c46 100644 --- a/test/single_file/initializer_list.cc.expected +++ b/test/single_file/initializer_list.cc.expected @@ -42,6 +42,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #include struct A { diff --git a/test/single_file/initializer_list.cc.noopt.expected b/test/single_file/initializer_list.cc.noopt.expected index 347e9339..eacdc64a 100644 --- a/test/single_file/initializer_list.cc.noopt.expected +++ b/test/single_file/initializer_list.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } #include diff --git a/test/single_file/lambda_capture.cc.expected b/test/single_file/lambda_capture.cc.expected index ccddbdc6..c3132b4b 100644 --- a/test/single_file/lambda_capture.cc.expected +++ b/test/single_file/lambda_capture.cc.expected @@ -42,25 +42,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/lambda_capture.cc.noopt.expected b/test/single_file/lambda_capture.cc.noopt.expected index c0ccda83..229afef7 100644 --- a/test/single_file/lambda_capture.cc.noopt.expected +++ b/test/single_file/lambda_capture.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/left_shift_opt.c.expected b/test/single_file/left_shift_opt.c.expected index 5dadb221..6d420db3 100644 --- a/test/single_file/left_shift_opt.c.expected +++ b/test/single_file/left_shift_opt.c.expected @@ -40,19 +40,25 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/left_shift_opt.c.noopt.expected b/test/single_file/left_shift_opt.c.noopt.expected index 492ddacd..44c2e691 100644 --- a/test/single_file/left_shift_opt.c.noopt.expected +++ b/test/single_file/left_shift_opt.c.noopt.expected @@ -40,23 +40,34 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Shr(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >> arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Shl_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 << arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 >> arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2; - return arg1 << arg2; + MUTATION_PRELUDE(arg1 << arg2); + REPLACE_BINARY_Shr(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2(2); + return MUTATION_RETURN(arg1 << arg2); } int main() { diff --git a/test/single_file/left_shift_opt.cc.expected b/test/single_file/left_shift_opt.cc.expected index ecc79d9d..adfef668 100644 --- a/test/single_file/left_shift_opt.cc.expected +++ b/test/single_file/left_shift_opt.cc.expected @@ -42,19 +42,25 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/left_shift_opt.cc.noopt.expected b/test/single_file/left_shift_opt.cc.noopt.expected index 029d9587..10eb2997 100644 --- a/test/single_file/left_shift_opt.cc.noopt.expected +++ b/test/single_file/left_shift_opt.cc.noopt.expected @@ -42,23 +42,34 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Shr(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >> arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Shl_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 << arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 >> arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2; - return arg1 << arg2; + MUTATION_PRELUDE(arg1 << arg2); + REPLACE_BINARY_Shr(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2(2); + return MUTATION_RETURN(arg1 << arg2); } int main() { diff --git a/test/single_file/logical_and.c.expected b/test/single_file/logical_and.c.expected index 9836be0e..3506dfdd 100644 --- a/test/single_file/logical_and.c.expected +++ b/test/single_file/logical_and.c.expected @@ -40,22 +40,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_LAnd_arg1_int_arg2_int_rhs(int arg, int local_mutation_id) { diff --git a/test/single_file/logical_and.c.noopt.expected b/test/single_file/logical_and.c.noopt.expected index 9836be0e..3506dfdd 100644 --- a/test/single_file/logical_and.c.noopt.expected +++ b/test/single_file/logical_and.c.noopt.expected @@ -40,22 +40,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_LAnd_arg1_int_arg2_int_rhs(int arg, int local_mutation_id) { diff --git a/test/single_file/logical_and.cc.expected b/test/single_file/logical_and.cc.expected index 1e8e0933..e45ad4f6 100644 --- a/test/single_file/logical_and.cc.expected +++ b/test/single_file/logical_and.cc.expected @@ -42,45 +42,60 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool_before_logical_operator_argument(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + REPLACE_EXPR_FALSE(1); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_EQ_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1 && arg2()); } int foo(int a, int b) { diff --git a/test/single_file/logical_and.cc.noopt.expected b/test/single_file/logical_and.cc.noopt.expected index cdcd4fca..348fc047 100644 --- a/test/single_file/logical_and.cc.noopt.expected +++ b/test/single_file/logical_and.cc.noopt.expected @@ -42,40 +42,57 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() +#define REPLACE_BINARY_LOr_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 || arg2() +#define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_LOr_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_RHS_EVALUATED(1); + REPLACE_BINARY_NE_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1 && arg2()); } int foo(int a, int b) { diff --git a/test/single_file/logical_and_div.cc.expected b/test/single_file/logical_and_div.cc.expected index 6056bdff..34acc031 100644 --- a/test/single_file/logical_and_div.cc.expected +++ b/test/single_file/logical_and_div.cc.expected @@ -42,68 +42,90 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_LT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 < arg2 +#define REPLACE_BINARY_GT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 > arg2 +#define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Div_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 / arg2; + MUTATION_PRELUDE(arg1 / arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 / arg2); } static bool __dredd_replace_expr_bool_omit_false(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool_before_logical_operator_argument(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + REPLACE_EXPR_FALSE(1); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_NE_arg1_int_arg2_int_rhs_zero(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 < arg2; - return arg1 != arg2; + MUTATION_PRELUDE(arg1 != arg2); + REPLACE_BINARY_GT(0); + REPLACE_BINARY_LT(1); + return MUTATION_RETURN(arg1 != arg2); } static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_EQ_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1 && arg2()); } int foo(int a, int b) { diff --git a/test/single_file/logical_and_div.cc.noopt.expected b/test/single_file/logical_and_div.cc.noopt.expected index ddfb4201..0e836e53 100644 --- a/test/single_file/logical_and_div.cc.noopt.expected +++ b/test/single_file/logical_and_div.cc.noopt.expected @@ -42,63 +42,90 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_LT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 < arg2 +#define REPLACE_BINARY_LOr_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 || arg2() +#define REPLACE_BINARY_LE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <= arg2 +#define REPLACE_BINARY_GT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 > arg2 +#define REPLACE_BINARY_GE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >= arg2 +#define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() +#define REPLACE_BINARY_EQ(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Div_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 / arg2; + MUTATION_PRELUDE(arg1 / arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 / arg2); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_NE_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 != arg2; + MUTATION_PRELUDE(arg1 != arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_GE(1); + REPLACE_BINARY_GT(2); + REPLACE_BINARY_LE(3); + REPLACE_BINARY_LT(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 != arg2); } static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_LOr_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_RHS_EVALUATED(1); + REPLACE_BINARY_NE_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1 && arg2()); } int foo(int a, int b) { diff --git a/test/single_file/logical_or.c.expected b/test/single_file/logical_or.c.expected index bb39398f..8ce8b205 100644 --- a/test/single_file/logical_or.c.expected +++ b/test/single_file/logical_or.c.expected @@ -40,22 +40,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_LOr_arg1_int_arg2_int_rhs(int arg, int local_mutation_id) { diff --git a/test/single_file/logical_or.c.noopt.expected b/test/single_file/logical_or.c.noopt.expected index bb39398f..8ce8b205 100644 --- a/test/single_file/logical_or.c.noopt.expected +++ b/test/single_file/logical_or.c.noopt.expected @@ -40,22 +40,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_LOr_arg1_int_arg2_int_rhs(int arg, int local_mutation_id) { diff --git a/test/single_file/logical_or.cc.expected b/test/single_file/logical_or.cc.expected index 32ad83f1..dfdd1038 100644 --- a/test/single_file/logical_or.cc.expected +++ b/test/single_file/logical_or.cc.expected @@ -42,45 +42,60 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool_before_logical_operator_argument(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + REPLACE_EXPR_FALSE(1); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_LOr_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1 || arg2(); + MUTATION_PRELUDE(arg1 || arg2()); + REPLACE_BINARY_NE_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1 || arg2()); } int foo(int a, int b) { diff --git a/test/single_file/logical_or.cc.noopt.expected b/test/single_file/logical_or.cc.noopt.expected index a7bf76df..b2d6e7a1 100644 --- a/test/single_file/logical_or.cc.noopt.expected +++ b/test/single_file/logical_or.cc.noopt.expected @@ -42,40 +42,57 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() +#define REPLACE_BINARY_LAnd_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 && arg2() +#define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_LOr_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1 || arg2(); + MUTATION_PRELUDE(arg1 || arg2()); + REPLACE_BINARY_LAnd_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_RHS_EVALUATED(1); + REPLACE_BINARY_NE_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1 || arg2()); } int foo(int a, int b) { diff --git a/test/single_file/misc002.cc.expected b/test/single_file/misc002.cc.expected index dbe249be..5762f19c 100644 --- a/test/single_file/misc002.cc.expected +++ b/test/single_file/misc002.cc.expected @@ -42,26 +42,35 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_LE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <= arg2 +#define REPLACE_BINARY_GE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >= arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool_false_omit_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - return arg; + MUTATION_PRELUDE(arg); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_EQ_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 <= arg2; - return arg1 == arg2; + MUTATION_PRELUDE(arg1 == arg2); + REPLACE_BINARY_GE(0); + REPLACE_BINARY_LE(1); + return MUTATION_RETURN(arg1 == arg2); } void f() { diff --git a/test/single_file/misc002.cc.noopt.expected b/test/single_file/misc002.cc.noopt.expected index dd337caa..0ad498f3 100644 --- a/test/single_file/misc002.cc.noopt.expected +++ b/test/single_file/misc002.cc.noopt.expected @@ -42,35 +42,52 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_NE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2 +#define REPLACE_BINARY_LT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 < arg2 +#define REPLACE_BINARY_LE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <= arg2 +#define REPLACE_BINARY_GT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 > arg2 +#define REPLACE_BINARY_GE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >= arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } static bool __dredd_replace_binary_operator_EQ_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 == arg2; + MUTATION_PRELUDE(arg1 == arg2); + REPLACE_BINARY_NE(0); + REPLACE_BINARY_GE(1); + REPLACE_BINARY_GT(2); + REPLACE_BINARY_LE(3); + REPLACE_BINARY_LT(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 == arg2); } void f() { diff --git a/test/single_file/misc003.cc.expected b/test/single_file/misc003.cc.expected index 0ab51208..d59b1ed5 100644 --- a/test/single_file/misc003.cc.expected +++ b/test/single_file/misc003.cc.expected @@ -42,6 +42,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg void f(){ if (!__dredd_enabled_mutation(0)) { try { } catch (...) { diff --git a/test/single_file/misc003.cc.noopt.expected b/test/single_file/misc003.cc.noopt.expected index 0ab51208..d59b1ed5 100644 --- a/test/single_file/misc003.cc.noopt.expected +++ b/test/single_file/misc003.cc.noopt.expected @@ -42,6 +42,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg void f(){ if (!__dredd_enabled_mutation(0)) { try { } catch (...) { diff --git a/test/single_file/negative_switch_case.c.expected b/test/single_file/negative_switch_case.c.expected index 2dbed313..6a83923c 100644 --- a/test/single_file/negative_switch_case.c.expected +++ b/test/single_file/negative_switch_case.c.expected @@ -40,11 +40,15 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/negative_switch_case.c.noopt.expected b/test/single_file/negative_switch_case.c.noopt.expected index 6497468f..662fb412 100644 --- a/test/single_file/negative_switch_case.c.noopt.expected +++ b/test/single_file/negative_switch_case.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/negative_switch_case.cc.expected b/test/single_file/negative_switch_case.cc.expected index 8437eaf0..79d9c72c 100644 --- a/test/single_file/negative_switch_case.cc.expected +++ b/test/single_file/negative_switch_case.cc.expected @@ -42,11 +42,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/negative_switch_case.cc.noopt.expected b/test/single_file/negative_switch_case.cc.noopt.expected index 020bc5b2..bba34ca5 100644 --- a/test/single_file/negative_switch_case.cc.noopt.expected +++ b/test/single_file/negative_switch_case.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/non_const_sized_array.c.expected b/test/single_file/non_const_sized_array.c.expected index 747447ad..a9c75c92 100644 --- a/test/single_file/non_const_sized_array.c.expected +++ b/test/single_file/non_const_sized_array.c.expected @@ -40,43 +40,59 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_volatile_int_lvalue(volatile int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo() { diff --git a/test/single_file/non_const_sized_array.c.noopt.expected b/test/single_file/non_const_sized_array.c.noopt.expected index baf9468d..efcb7158 100644 --- a/test/single_file/non_const_sized_array.c.noopt.expected +++ b/test/single_file/non_const_sized_array.c.noopt.expected @@ -40,33 +40,49 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_volatile_int_lvalue(volatile int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo() { diff --git a/test/single_file/non_const_sized_array.cc.expected b/test/single_file/non_const_sized_array.cc.expected index 37ea65b9..67bd128a 100644 --- a/test/single_file/non_const_sized_array.cc.expected +++ b/test/single_file/non_const_sized_array.cc.expected @@ -42,14 +42,21 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/non_const_sized_array.cc.noopt.expected b/test/single_file/non_const_sized_array.cc.noopt.expected index 1b533828..971b1a29 100644 --- a/test/single_file/non_const_sized_array.cc.noopt.expected +++ b/test/single_file/non_const_sized_array.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/parens.cc.expected b/test/single_file/parens.cc.expected index bea763fc..04c03fbe 100644 --- a/test/single_file/parens.cc.expected +++ b/test/single_file/parens.cc.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int foo(int x) { diff --git a/test/single_file/parens.cc.noopt.expected b/test/single_file/parens.cc.noopt.expected index 9c631225..5b5c5ef0 100644 --- a/test/single_file/parens.cc.noopt.expected +++ b/test/single_file/parens.cc.noopt.expected @@ -42,22 +42,32 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int foo(int x) { diff --git a/test/single_file/positive_int_as_minus_one.c.expected b/test/single_file/positive_int_as_minus_one.c.expected index 998c80b6..3a4e476d 100644 --- a/test/single_file/positive_int_as_minus_one.c.expected +++ b/test/single_file/positive_int_as_minus_one.c.expected @@ -40,50 +40,66 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_ONE(2); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_unsigned_int(unsigned int arg1, unsigned int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 - arg2; + MUTATION_PRELUDE(arg1 - arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Mul(2); + REPLACE_BINARY_Rem(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 - arg2); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/positive_int_as_minus_one.c.noopt.expected b/test/single_file/positive_int_as_minus_one.c.noopt.expected index 5592c185..252e36e4 100644 --- a/test/single_file/positive_int_as_minus_one.c.noopt.expected +++ b/test/single_file/positive_int_as_minus_one.c.noopt.expected @@ -40,53 +40,69 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_unsigned_int(unsigned int arg1, unsigned int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 - arg2; + MUTATION_PRELUDE(arg1 - arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Mul(2); + REPLACE_BINARY_Rem(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 - arg2); } 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/positive_int_as_minus_one.cc.expected b/test/single_file/positive_int_as_minus_one.cc.expected index 87f82209..61ab9a91 100644 --- a/test/single_file/positive_int_as_minus_one.cc.expected +++ b/test/single_file/positive_int_as_minus_one.cc.expected @@ -42,50 +42,66 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_ONE(2); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_unsigned_int(unsigned int arg1, unsigned int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 - arg2; + MUTATION_PRELUDE(arg1 - arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Mul(2); + REPLACE_BINARY_Rem(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 - arg2); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/positive_int_as_minus_one.cc.noopt.expected b/test/single_file/positive_int_as_minus_one.cc.noopt.expected index 2f317c00..34ae31de 100644 --- a/test/single_file/positive_int_as_minus_one.cc.noopt.expected +++ b/test/single_file/positive_int_as_minus_one.cc.noopt.expected @@ -42,53 +42,69 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_unsigned_int(unsigned int arg1, unsigned int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 - arg2; + MUTATION_PRELUDE(arg1 - arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Div(1); + REPLACE_BINARY_Mul(2); + REPLACE_BINARY_Rem(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 - arg2); } 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/post_inc_volatile.c.expected b/test/single_file/post_inc_volatile.c.expected index 81ceb330..0025e086 100644 --- a/test/single_file/post_inc_volatile.c.expected +++ b/test/single_file/post_inc_volatile.c.expected @@ -40,68 +40,99 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PostInc_volatile_int(volatile int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return (*arg)++; + MUTATION_PRELUDE((*arg)++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN((*arg)++); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/post_inc_volatile.c.noopt.expected b/test/single_file/post_inc_volatile.c.noopt.expected index 7c5aa4ec..acf52d48 100644 --- a/test/single_file/post_inc_volatile.c.noopt.expected +++ b/test/single_file/post_inc_volatile.c.noopt.expected @@ -40,58 +40,89 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PostInc_volatile_int(volatile int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return (*arg)++; + MUTATION_PRELUDE((*arg)++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN((*arg)++); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } int main() { diff --git a/test/single_file/post_inc_volatile.cc.expected b/test/single_file/post_inc_volatile.cc.expected index cb3ea5cb..f3bb9be7 100644 --- a/test/single_file/post_inc_volatile.cc.expected +++ b/test/single_file/post_inc_volatile.cc.expected @@ -42,79 +42,113 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg() +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() +#define REPLACE_BINARY_Sub_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() - arg2() +#define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() +#define REPLACE_BINARY_ShrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2() +#define REPLACE_BINARY_ShlAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2() +#define REPLACE_BINARY_Rem_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() % arg2() +#define REPLACE_BINARY_RemAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2() +#define REPLACE_BINARY_OrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2() +#define REPLACE_BINARY_Mul_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() * arg2() +#define REPLACE_BINARY_MulAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2() +#define REPLACE_BINARY_Div_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() / arg2() +#define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() +#define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() +#define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG1_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2(); - return arg1 = arg2(); + MUTATION_PRELUDE(arg1 = arg2()); + REPLACE_BINARY_AddAssign_RHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_RHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_RHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_RHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_RHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_RHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_RHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_RHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_RHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_RHS_EVALUATED(9); + return MUTATION_RETURN(arg1 = arg2()); } static int __dredd_replace_unary_operator_PostInc_volatile_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()++); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(std::function arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() + arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() / arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() * arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() % arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1() - arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2(); - return arg1() + arg2(); + MUTATION_PRELUDE(arg1() + arg2()); + REPLACE_BINARY_Div_LHS_EVALUATED_RHS_EVALUATED(0); + REPLACE_BINARY_Mul_LHS_EVALUATED_RHS_EVALUATED(1); + REPLACE_BINARY_Rem_LHS_EVALUATED_RHS_EVALUATED(2); + REPLACE_BINARY_Sub_LHS_EVALUATED_RHS_EVALUATED(3); + REPLACE_BINARY_ARG1_EVALUATED(4); + REPLACE_BINARY_ARG2_EVALUATED(5); + return MUTATION_RETURN(arg1() + arg2()); } int main() { diff --git a/test/single_file/post_inc_volatile.cc.noopt.expected b/test/single_file/post_inc_volatile.cc.noopt.expected index 78befc8d..63e81845 100644 --- a/test/single_file/post_inc_volatile.cc.noopt.expected +++ b/test/single_file/post_inc_volatile.cc.noopt.expected @@ -42,69 +42,103 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg() +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() +#define REPLACE_BINARY_Sub_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() - arg2() +#define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() +#define REPLACE_BINARY_ShrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2() +#define REPLACE_BINARY_ShlAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2() +#define REPLACE_BINARY_Rem_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() % arg2() +#define REPLACE_BINARY_RemAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2() +#define REPLACE_BINARY_OrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2() +#define REPLACE_BINARY_Mul_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() * arg2() +#define REPLACE_BINARY_MulAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2() +#define REPLACE_BINARY_Div_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() / arg2() +#define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() +#define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() +#define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() +#define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() +#define REPLACE_BINARY_ARG1_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2(); - return arg1 = arg2(); + MUTATION_PRELUDE(arg1 = arg2()); + REPLACE_BINARY_AddAssign_RHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_RHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_RHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_RHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_RHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_RHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_RHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_RHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_RHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_RHS_EVALUATED(9); + return MUTATION_RETURN(arg1 = arg2()); } static int __dredd_replace_unary_operator_PostInc_volatile_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()++); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(std::function arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() + arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() / arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() * arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() % arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1() - arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2(); - return arg1() + arg2(); + MUTATION_PRELUDE(arg1() + arg2()); + REPLACE_BINARY_Div_LHS_EVALUATED_RHS_EVALUATED(0); + REPLACE_BINARY_Mul_LHS_EVALUATED_RHS_EVALUATED(1); + REPLACE_BINARY_Rem_LHS_EVALUATED_RHS_EVALUATED(2); + REPLACE_BINARY_Sub_LHS_EVALUATED_RHS_EVALUATED(3); + REPLACE_BINARY_ARG1_EVALUATED(4); + REPLACE_BINARY_ARG2_EVALUATED(5); + return MUTATION_RETURN(arg1() + arg2()); } int main() { diff --git a/test/single_file/pre_dec_assign.cc.expected b/test/single_file/pre_dec_assign.cc.expected index 39a11fef..1cd74ce6 100644 --- a/test/single_file/pre_dec_assign.cc.expected +++ b/test/single_file/pre_dec_assign.cc.expected @@ -42,76 +42,98 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++arg() +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_unary_operator_PreDec_volatile_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static volatile int& __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(std::function arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1() *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1() |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1() %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1() <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1() >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1() -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1() ^= arg2; - return arg1() = arg2; + MUTATION_PRELUDE(arg1() = arg2); + REPLACE_BINARY_AddAssign_LHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_LHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_LHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_LHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_LHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_LHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_LHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_LHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_LHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_LHS_EVALUATED(9); + return MUTATION_RETURN(arg1() = arg2); } static int& __dredd_replace_unary_operator_PreDec_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(std::function arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1() *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1() |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1() %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1() <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1() >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1() -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1() ^= arg2; - return arg1() = arg2; + MUTATION_PRELUDE(arg1() = arg2); + REPLACE_BINARY_AddAssign_LHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_LHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_LHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_LHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_LHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_LHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_LHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_LHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_LHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_LHS_EVALUATED(9); + return MUTATION_RETURN(arg1() = arg2); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/pre_dec_assign.cc.noopt.expected b/test/single_file/pre_dec_assign.cc.noopt.expected index 07d7dc60..cee3dab7 100644 --- a/test/single_file/pre_dec_assign.cc.noopt.expected +++ b/test/single_file/pre_dec_assign.cc.noopt.expected @@ -42,66 +42,88 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++arg() +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() += arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_unary_operator_PreDec_volatile_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static volatile int& __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(std::function arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1() *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1() |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1() %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1() <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1() >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1() -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1() ^= arg2; - return arg1() = arg2; + MUTATION_PRELUDE(arg1() = arg2); + REPLACE_BINARY_AddAssign_LHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_LHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_LHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_LHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_LHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_LHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_LHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_LHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_LHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_LHS_EVALUATED(9); + return MUTATION_RETURN(arg1() = arg2); } static int& __dredd_replace_unary_operator_PreDec_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(std::function arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1() *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1() |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1() %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1() <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1() >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1() -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1() ^= arg2; - return arg1() = arg2; + MUTATION_PRELUDE(arg1() = arg2); + REPLACE_BINARY_AddAssign_LHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_LHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_LHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_LHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_LHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_LHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_LHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_LHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_LHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_LHS_EVALUATED(9); + return MUTATION_RETURN(arg1() = arg2); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/preprocessor_if.c.expected b/test/single_file/preprocessor_if.c.expected index 0a8dd9e1..17a17937 100644 --- a/test/single_file/preprocessor_if.c.expected +++ b/test/single_file/preprocessor_if.c.expected @@ -40,38 +40,59 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_Xor(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^ arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_And(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 & arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Or_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 | arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 & arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 ^ arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg2; - return arg1 | arg2; + MUTATION_PRELUDE(arg1 | arg2); + REPLACE_BINARY_And(0); + REPLACE_BINARY_Xor(1); + REPLACE_BINARY_ARG1(2); + REPLACE_BINARY_ARG2(3); + return MUTATION_RETURN(arg1 | arg2); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } int main() { diff --git a/test/single_file/preprocessor_if.c.noopt.expected b/test/single_file/preprocessor_if.c.noopt.expected index 4528ef9d..7dc85fa0 100644 --- a/test/single_file/preprocessor_if.c.noopt.expected +++ b/test/single_file/preprocessor_if.c.noopt.expected @@ -40,39 +40,61 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_Xor(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^ arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_And(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 & arg2 +#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Or_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 | arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 & arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 ^ arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg2; - return arg1 | arg2; + MUTATION_PRELUDE(arg1 | arg2); + REPLACE_BINARY_And(0); + REPLACE_BINARY_Xor(1); + REPLACE_BINARY_ARG1(2); + REPLACE_BINARY_ARG2(3); + return MUTATION_RETURN(arg1 | arg2); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) = arg2; + MUTATION_PRELUDE((*arg1) = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) = arg2); } int main() { diff --git a/test/single_file/printing.c.expected b/test/single_file/printing.c.expected index 554ba5c4..680ebc01 100644 --- a/test/single_file/printing.c.expected +++ b/test/single_file/printing.c.expected @@ -40,6 +40,8 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #include int main() { diff --git a/test/single_file/printing.c.noopt.expected b/test/single_file/printing.c.noopt.expected index 67c226ba..34a59e41 100644 --- a/test/single_file/printing.c.noopt.expected +++ b/test/single_file/printing.c.noopt.expected @@ -40,15 +40,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } #include diff --git a/test/single_file/printing.cc.expected b/test/single_file/printing.cc.expected index 55dd46db..cc6be45f 100644 --- a/test/single_file/printing.cc.expected +++ b/test/single_file/printing.cc.expected @@ -42,6 +42,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #include int main() { diff --git a/test/single_file/printing.cc.noopt.expected b/test/single_file/printing.cc.noopt.expected index 55dd46db..cc6be45f 100644 --- a/test/single_file/printing.cc.noopt.expected +++ b/test/single_file/printing.cc.noopt.expected @@ -42,6 +42,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg #include int main() { diff --git a/test/single_file/signed_int_constants.cc.expected b/test/single_file/signed_int_constants.cc.expected index 55833874..b53eb8d0 100644 --- a/test/single_file/signed_int_constants.cc.expected +++ b/test/single_file/signed_int_constants.cc.expected @@ -42,54 +42,64 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return 1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ZERO(0); + REPLACE_EXPR_INT_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo(int a) { diff --git a/test/single_file/signed_int_constants.cc.noopt.expected b/test/single_file/signed_int_constants.cc.noopt.expected index 7fea59d0..3953b5ca 100644 --- a/test/single_file/signed_int_constants.cc.noopt.expected +++ b/test/single_file/signed_int_constants.cc.noopt.expected @@ -42,30 +42,43 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo(int a) { diff --git a/test/single_file/sizeof_template.cc.expected b/test/single_file/sizeof_template.cc.expected index 8bfcde8a..edc21eed 100644 --- a/test/single_file/sizeof_template.cc.expected +++ b/test/single_file/sizeof_template.cc.expected @@ -42,13 +42,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long(unsigned 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } template void b() { if (!__dredd_enabled_mutation(4)) { a(__dredd_replace_expr_unsigned_long(sizeof(a), 0)); } } diff --git a/test/single_file/sizeof_template.cc.noopt.expected b/test/single_file/sizeof_template.cc.noopt.expected index 8bfcde8a..edc21eed 100644 --- a/test/single_file/sizeof_template.cc.noopt.expected +++ b/test/single_file/sizeof_template.cc.noopt.expected @@ -42,13 +42,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long(unsigned 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } template void b() { if (!__dredd_enabled_mutation(4)) { a(__dredd_replace_expr_unsigned_long(sizeof(a), 0)); } } diff --git a/test/single_file/sizeof_template2.cc.expected b/test/single_file/sizeof_template2.cc.expected index 55472d28..c4bcf147 100644 --- a/test/single_file/sizeof_template2.cc.expected +++ b/test/single_file/sizeof_template2.cc.expected @@ -42,23 +42,34 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(std::function 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg()); } bool f(int); diff --git a/test/single_file/sizeof_template2.cc.noopt.expected b/test/single_file/sizeof_template2.cc.noopt.expected index ca636194..7ffb522f 100644 --- a/test/single_file/sizeof_template2.cc.noopt.expected +++ b/test/single_file/sizeof_template2.cc.noopt.expected @@ -42,32 +42,43 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long(unsigned 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(std::function 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg()); } bool f(int); diff --git a/test/single_file/static_initializer.cc.expected b/test/single_file/static_initializer.cc.expected index 3c75e155..f17a96d5 100644 --- a/test/single_file/static_initializer.cc.expected +++ b/test/single_file/static_initializer.cc.expected @@ -42,40 +42,56 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo() { diff --git a/test/single_file/static_initializer.cc.noopt.expected b/test/single_file/static_initializer.cc.noopt.expected index 1c16556c..99477c94 100644 --- a/test/single_file/static_initializer.cc.noopt.expected +++ b/test/single_file/static_initializer.cc.noopt.expected @@ -42,33 +42,49 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } void foo() { diff --git a/test/single_file/structured_binding.cc.expected b/test/single_file/structured_binding.cc.expected index 8e6b5975..70963373 100644 --- a/test/single_file/structured_binding.cc.expected +++ b/test/single_file/structured_binding.cc.expected @@ -42,64 +42,90 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg() +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() +#define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() +#define REPLACE_BINARY_ShrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2() +#define REPLACE_BINARY_ShlAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2() +#define REPLACE_BINARY_RemAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2() +#define REPLACE_BINARY_OrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2() +#define REPLACE_BINARY_MulAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2() +#define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() +#define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() +#define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2(); - return arg1 = arg2(); + MUTATION_PRELUDE(arg1 = arg2()); + REPLACE_BINARY_AddAssign_RHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_RHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_RHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_RHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_RHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_RHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_RHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_RHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_RHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_RHS_EVALUATED(9); + return MUTATION_RETURN(arg1 = arg2()); } static int __dredd_replace_unary_operator_PostInc_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()++); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FALSE(0); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/structured_binding.cc.noopt.expected b/test/single_file/structured_binding.cc.noopt.expected index 03b0b83e..56e6a343 100644 --- a/test/single_file/structured_binding.cc.noopt.expected +++ b/test/single_file/structured_binding.cc.noopt.expected @@ -42,59 +42,87 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg() +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() +#define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() +#define REPLACE_BINARY_ShrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2() +#define REPLACE_BINARY_ShlAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2() +#define REPLACE_BINARY_RemAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2() +#define REPLACE_BINARY_OrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2() +#define REPLACE_BINARY_MulAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2() +#define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() +#define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() +#define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2(); - return arg1 = arg2(); + MUTATION_PRELUDE(arg1 = arg2()); + REPLACE_BINARY_AddAssign_RHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_RHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_RHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_RHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_RHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_RHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_RHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_RHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_RHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_RHS_EVALUATED(9); + return MUTATION_RETURN(arg1 = arg2()); } static int __dredd_replace_unary_operator_PostInc_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()++); } static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/template.cc.expected b/test/single_file/template.cc.expected index 409a9120..15307c41 100644 --- a/test/single_file/template.cc.expected +++ b/test/single_file/template.cc.expected @@ -42,40 +42,60 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() +#define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() +#define REPLACE_BINARY_ShrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2() +#define REPLACE_BINARY_ShlAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2() +#define REPLACE_BINARY_RemAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2() +#define REPLACE_BINARY_OrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2() +#define REPLACE_BINARY_MulAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2() +#define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() +#define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() +#define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2(); - return arg1 = arg2(); + MUTATION_PRELUDE(arg1 = arg2()); + REPLACE_BINARY_AddAssign_RHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_RHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_RHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_RHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_RHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_RHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_RHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_RHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_RHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_RHS_EVALUATED(9); + return MUTATION_RETURN(arg1 = arg2()); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } template diff --git a/test/single_file/template.cc.noopt.expected b/test/single_file/template.cc.noopt.expected index 49f4dcbe..f9d7309e 100644 --- a/test/single_file/template.cc.noopt.expected +++ b/test/single_file/template.cc.noopt.expected @@ -42,41 +42,62 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() +#define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() +#define REPLACE_BINARY_ShrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2() +#define REPLACE_BINARY_ShlAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2() +#define REPLACE_BINARY_RemAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2() +#define REPLACE_BINARY_OrAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2() +#define REPLACE_BINARY_MulAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2() +#define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() +#define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() +#define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2(); - return arg1 = arg2(); + MUTATION_PRELUDE(arg1 = arg2()); + REPLACE_BINARY_AddAssign_RHS_EVALUATED(0); + REPLACE_BINARY_AndAssign_RHS_EVALUATED(1); + REPLACE_BINARY_DivAssign_RHS_EVALUATED(2); + REPLACE_BINARY_MulAssign_RHS_EVALUATED(3); + REPLACE_BINARY_OrAssign_RHS_EVALUATED(4); + REPLACE_BINARY_RemAssign_RHS_EVALUATED(5); + REPLACE_BINARY_ShlAssign_RHS_EVALUATED(6); + REPLACE_BINARY_ShrAssign_RHS_EVALUATED(7); + REPLACE_BINARY_SubAssign_RHS_EVALUATED(8); + REPLACE_BINARY_XorAssign_RHS_EVALUATED(9); + return MUTATION_RETURN(arg1 = arg2()); } static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } template diff --git a/test/single_file/template_instantiation.cc.expected b/test/single_file/template_instantiation.cc.expected index 66f803a4..218bc0b1 100644 --- a/test/single_file/template_instantiation.cc.expected +++ b/test/single_file/template_instantiation.cc.expected @@ -42,11 +42,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } template void foo() { diff --git a/test/single_file/template_instantiation.cc.noopt.expected b/test/single_file/template_instantiation.cc.noopt.expected index 4793c80c..7a73b4ac 100644 --- a/test/single_file/template_instantiation.cc.noopt.expected +++ b/test/single_file/template_instantiation.cc.noopt.expected @@ -42,15 +42,23 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } template void foo() { diff --git a/test/single_file/typedef.c.noopt.expected b/test/single_file/typedef.c.noopt.expected index 3d2c2b52..e8625102 100644 --- a/test/single_file/typedef.c.noopt.expected +++ b/test/single_file/typedef.c.noopt.expected @@ -40,26 +40,40 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } typedef struct S { diff --git a/test/single_file/typedef.cc.noopt.expected b/test/single_file/typedef.cc.noopt.expected index a573ef77..375d8243 100644 --- a/test/single_file/typedef.cc.noopt.expected +++ b/test/single_file/typedef.cc.noopt.expected @@ -42,26 +42,40 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } typedef struct S { diff --git a/test/single_file/unary.c.expected b/test/single_file/unary.c.expected index 487ef4d9..48be7907 100644 --- a/test/single_file/unary.c.expected +++ b/test/single_file/unary.c.expected @@ -40,124 +40,147 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(*arg) +#define REPLACE_UNARY_PreDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(*arg) +#define REPLACE_UNARY_PostInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)++ +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PreInc_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return ++(*arg); + MUTATION_PRELUDE(++(*arg)); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(++(*arg)); } static int __dredd_replace_unary_operator_PreDec_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return --(*arg); + MUTATION_PRELUDE(--(*arg)); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(--(*arg)); } static int __dredd_replace_unary_operator_PostInc_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return (*arg)++; + MUTATION_PRELUDE((*arg)++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN((*arg)++); } static int __dredd_replace_unary_operator_PostDec_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return (*arg)--; + MUTATION_PRELUDE((*arg)--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN((*arg)--); } static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float __dredd_replace_unary_operator_PreInc_float(float* 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 (*arg); - return ++(*arg); + MUTATION_PRELUDE(++(*arg)); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(++(*arg)); } static float __dredd_replace_unary_operator_PreDec_float(float* 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 (*arg); - return --(*arg); + MUTATION_PRELUDE(--(*arg)); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(--(*arg)); } static float __dredd_replace_unary_operator_PostInc_float(float* 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 (*arg); - return (*arg)++; + MUTATION_PRELUDE((*arg)++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN((*arg)++); } static float __dredd_replace_unary_operator_PostDec_float(float* 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 (*arg); - return (*arg)--; + MUTATION_PRELUDE((*arg)--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN((*arg)--); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary.c.noopt.expected b/test/single_file/unary.c.noopt.expected index b9ba2785..02ceab85 100644 --- a/test/single_file/unary.c.noopt.expected +++ b/test/single_file/unary.c.noopt.expected @@ -40,124 +40,148 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(*arg) +#define REPLACE_UNARY_PreDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(*arg) +#define REPLACE_UNARY_PostInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)++ +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PreInc_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return ++(*arg); + MUTATION_PRELUDE(++(*arg)); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(++(*arg)); } static int __dredd_replace_unary_operator_PreDec_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return --(*arg); + MUTATION_PRELUDE(--(*arg)); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(--(*arg)); } static int __dredd_replace_unary_operator_PostInc_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return (*arg)++; + MUTATION_PRELUDE((*arg)++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN((*arg)++); } static int __dredd_replace_unary_operator_PostDec_int(int* 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 !(*arg); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg); - return (*arg)--; + MUTATION_PRELUDE((*arg)--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN((*arg)--); } static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float __dredd_replace_unary_operator_PreInc_float(float* 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 (*arg); - return ++(*arg); + MUTATION_PRELUDE(++(*arg)); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(++(*arg)); } static float __dredd_replace_unary_operator_PreDec_float(float* 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 (*arg); - return --(*arg); + MUTATION_PRELUDE(--(*arg)); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(--(*arg)); } static float __dredd_replace_unary_operator_PostInc_float(float* 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 (*arg); - return (*arg)++; + MUTATION_PRELUDE((*arg)++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN((*arg)++); } static float __dredd_replace_unary_operator_PostDec_float(float* 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 (*arg); - return (*arg)--; + MUTATION_PRELUDE((*arg)--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN((*arg)--); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary.cc.expected b/test/single_file/unary.cc.expected index 37ab5ce2..9e365d6b 100644 --- a/test/single_file/unary.cc.expected +++ b/test/single_file/unary.cc.expected @@ -42,114 +42,137 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++arg() +#define REPLACE_UNARY_PreDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --arg() +#define REPLACE_UNARY_PostInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()++ +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg() +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_unary_operator_PreInc_int(std::function 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(); - return ++arg(); + MUTATION_PRELUDE(++arg()); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(++arg()); } static int& __dredd_replace_unary_operator_PreDec_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static int __dredd_replace_unary_operator_PostInc_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()++); } static int __dredd_replace_unary_operator_PostDec_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()--; + MUTATION_PRELUDE(arg()--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()--); } static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float& __dredd_replace_unary_operator_PreInc_float(std::function 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(); - return ++arg(); + MUTATION_PRELUDE(++arg()); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(++arg()); } static float& __dredd_replace_unary_operator_PreDec_float(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static float __dredd_replace_unary_operator_PostInc_float(std::function 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 arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(arg()++); } static float __dredd_replace_unary_operator_PostDec_float(std::function 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 arg(); - return arg()--; + MUTATION_PRELUDE(arg()--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(arg()--); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary.cc.noopt.expected b/test/single_file/unary.cc.noopt.expected index 0b25de35..d389aeb4 100644 --- a/test/single_file/unary.cc.noopt.expected +++ b/test/single_file/unary.cc.noopt.expected @@ -42,134 +42,161 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++arg() +#define REPLACE_UNARY_PreDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --arg() +#define REPLACE_UNARY_PostInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()++ +#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg()-- +#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg() +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() +#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 +#define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 +#define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_unary_operator_PreInc_int(std::function 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(); - return ++arg(); + MUTATION_PRELUDE(++arg()); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(++arg()); } static int& __dredd_replace_unary_operator_PreDec_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static int __dredd_replace_unary_operator_PostInc_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()++); } static int __dredd_replace_unary_operator_PostDec_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()--; + MUTATION_PRELUDE(arg()--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()--); } static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(std::function 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(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_LNOT_EVALUATED(0); + MUTATION_EXPR_NOT_EVALUATED(1); + MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg()); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static float& __dredd_replace_unary_operator_PreInc_float(std::function 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(); - return ++arg(); + MUTATION_PRELUDE(++arg()); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(++arg()); } static float& __dredd_replace_unary_operator_PreDec_float(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } static float __dredd_replace_unary_operator_PostInc_float(std::function 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 arg(); - return arg()++; + MUTATION_PRELUDE(arg()++); + REPLACE_UNARY_PostDec_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(arg()++); } static float __dredd_replace_unary_operator_PostDec_float(std::function 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 arg(); - return arg()--; + MUTATION_PRELUDE(arg()--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Minus_EVALUATED(1); + REPLACE_UNARY_LNot_EVALUATED(2); + REPLACE_UNARY_ARG_EVALUATED(3); + return MUTATION_RETURN(arg()--); } static float __dredd_replace_expr_float(std::function 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg(); + MUTATION_PRELUDE(arg()); + MUTATION_EXPR_MINUS_EVALUATED(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg()); } static float __dredd_replace_expr_float(float 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_logical_not.c.expected b/test/single_file/unary_logical_not.c.expected index 973de270..3b361a79 100644 --- a/test/single_file/unary_logical_not.c.expected +++ b/test/single_file/unary_logical_not.c.expected @@ -40,36 +40,48 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_LNot_bool(bool 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + return MUTATION_RETURN(!arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FALSE(0); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } #include diff --git a/test/single_file/unary_logical_not.c.noopt.expected b/test/single_file/unary_logical_not.c.noopt.expected index 712dbcaf..d45758ba 100644 --- a/test/single_file/unary_logical_not.c.noopt.expected +++ b/test/single_file/unary_logical_not.c.noopt.expected @@ -40,31 +40,44 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_LNot_bool(bool 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(!arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } #include diff --git a/test/single_file/unary_logical_not.cc.expected b/test/single_file/unary_logical_not.cc.expected index 7e67219c..b81522a3 100644 --- a/test/single_file/unary_logical_not.cc.expected +++ b/test/single_file/unary_logical_not.cc.expected @@ -42,36 +42,48 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_unary_operator_LNot_bool(bool 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + return MUTATION_RETURN(!arg); } static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FALSE(0); + return MUTATION_RETURN(arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_logical_not.cc.noopt.expected b/test/single_file/unary_logical_not.cc.noopt.expected index c8517d12..590bf514 100644 --- a/test/single_file/unary_logical_not.cc.noopt.expected +++ b/test/single_file/unary_logical_not.cc.noopt.expected @@ -42,31 +42,44 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_unary_operator_LNot_bool(bool 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(!arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_minus.c.expected b/test/single_file/unary_minus.c.expected index cc8b7709..11f16b4b 100644 --- a/test/single_file/unary_minus.c.expected +++ b/test/single_file/unary_minus.c.expected @@ -40,37 +40,49 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_minus.c.noopt.expected b/test/single_file/unary_minus.c.noopt.expected index 27b9e5d5..19391688 100644 --- a/test/single_file/unary_minus.c.noopt.expected +++ b/test/single_file/unary_minus.c.noopt.expected @@ -40,30 +40,43 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_lvalue(int* 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)); - return (*arg); + MUTATION_PRELUDE((*arg)); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_minus.cc.expected b/test/single_file/unary_minus.cc.expected index 9938245f..0323d6a7 100644 --- a/test/single_file/unary_minus.cc.expected +++ b/test/single_file/unary_minus.cc.expected @@ -42,37 +42,49 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_minus.cc.noopt.expected b/test/single_file/unary_minus.cc.noopt.expected index ef9569ce..b6eff464 100644 --- a/test/single_file/unary_minus.cc.noopt.expected +++ b/test/single_file/unary_minus.cc.noopt.expected @@ -42,30 +42,43 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_operator_opt.c.expected b/test/single_file/unary_operator_opt.c.expected index eab9557e..e095c80f 100644 --- a/test/single_file/unary_operator_opt.c.expected +++ b/test/single_file/unary_operator_opt.c.expected @@ -40,42 +40,50 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Not_int_minus_one(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return ~arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return !arg; - return ~arg; + MUTATION_PRELUDE(~arg); + REPLACE_UNARY_LNot(0); + return MUTATION_RETURN(~arg); } static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_one(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_MINUS_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 0; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return 1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ZERO(0); + REPLACE_EXPR_INT_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unary_operator_opt.c.noopt.expected b/test/single_file/unary_operator_opt.c.noopt.expected index 18696ab5..768d846c 100644 --- a/test/single_file/unary_operator_opt.c.noopt.expected +++ b/test/single_file/unary_operator_opt.c.noopt.expected @@ -40,31 +40,43 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Not_int(int 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; - return ~arg; + MUTATION_PRELUDE(~arg); + REPLACE_UNARY_Minus(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(~arg); } static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unsigned_int.c.expected b/test/single_file/unsigned_int.c.expected index 617ffc63..89889fb8 100644 --- a/test/single_file/unsigned_int.c.expected +++ b/test/single_file/unsigned_int.c.expected @@ -40,49 +40,59 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_one(unsigned int 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; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_unary_operator_Not_int(int 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; - return ~arg; + MUTATION_PRELUDE(~arg); + REPLACE_UNARY_Minus(0); + REPLACE_UNARY_LNot(1); + return MUTATION_RETURN(~arg); } static int __dredd_replace_unary_operator_LNot_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return !arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return ~arg; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + return MUTATION_RETURN(!arg); } static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return -1; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_INT_ONE(0); + REPLACE_EXPR_INT_MINUS_ONE(1); + return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unsigned_int.c.noopt.expected b/test/single_file/unsigned_int.c.noopt.expected index 9c9f3e65..fb14ca33 100644 --- a/test/single_file/unsigned_int.c.noopt.expected +++ b/test/single_file/unsigned_int.c.noopt.expected @@ -40,40 +40,52 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static int __dredd_replace_unary_operator_Not_int(int 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; - return ~arg; + MUTATION_PRELUDE(~arg); + REPLACE_UNARY_Minus(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(~arg); } static int __dredd_replace_unary_operator_LNot_int(int 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(!arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unsigned_int.cc.expected b/test/single_file/unsigned_int.cc.expected index c3f6bd45..234e54b2 100644 --- a/test/single_file/unsigned_int.cc.expected +++ b/test/single_file/unsigned_int.cc.expected @@ -42,48 +42,59 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_one(unsigned int 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; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_ONE(2); + return MUTATION_RETURN(arg); } static int __dredd_replace_unary_operator_Not_int(int 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; - return ~arg; + MUTATION_PRELUDE(~arg); + REPLACE_UNARY_Minus(0); + REPLACE_UNARY_LNot(1); + return MUTATION_RETURN(~arg); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static bool __dredd_replace_unary_operator_LNot_bool_zero(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return !arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return ~arg; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + return MUTATION_RETURN(!arg); } static bool __dredd_replace_expr_bool_false(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/unsigned_int.cc.noopt.expected b/test/single_file/unsigned_int.cc.noopt.expected index ccb8608f..d56967a7 100644 --- a/test/single_file/unsigned_int.cc.noopt.expected +++ b/test/single_file/unsigned_int.cc.noopt.expected @@ -42,48 +42,62 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg +#define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg +#define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int(unsigned int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + return MUTATION_RETURN(arg); } static int __dredd_replace_unary_operator_Not_int(int 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; - return ~arg; + MUTATION_PRELUDE(~arg); + REPLACE_UNARY_Minus(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(~arg); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static bool __dredd_replace_unary_operator_LNot_bool(bool 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(!arg); } static bool __dredd_replace_expr_bool(bool 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 true; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return false; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_TRUE(1); + REPLACE_EXPR_FALSE(2); + return MUTATION_RETURN(arg); } int main() { diff --git a/test/single_file/using.cc.noopt.expected b/test/single_file/using.cc.noopt.expected index 9de76a94..56b31823 100644 --- a/test/single_file/using.cc.noopt.expected +++ b/test/single_file/using.cc.noopt.expected @@ -42,26 +42,40 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 +#define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 +#define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 +#define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 +#define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 +#define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } using blah = int; diff --git a/test/single_file/volatile.c.expected b/test/single_file/volatile.c.expected index ba6f689f..1d2e3947 100644 --- a/test/single_file/volatile.c.expected +++ b/test/single_file/volatile.c.expected @@ -40,29 +40,46 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) += arg2; + MUTATION_PRELUDE((*arg1) += arg2); + REPLACE_BINARY_AndAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) += arg2); } void foo() { diff --git a/test/single_file/volatile.c.noopt.expected b/test/single_file/volatile.c.noopt.expected index 9ea19efe..46bb61c1 100644 --- a/test/single_file/volatile.c.noopt.expected +++ b/test/single_file/volatile.c.noopt.expected @@ -40,30 +40,48 @@ static int __dredd_enabled_mutation(int local_mutation_id) { return enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64)); } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } static int __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return (*arg1) += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return (*arg1) &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return (*arg1) = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return (*arg1) /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return (*arg1) *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return (*arg1) |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return (*arg1) %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return (*arg1) <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return (*arg1) >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return (*arg1) -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return (*arg1) ^= arg2; - return (*arg1) += arg2; + MUTATION_PRELUDE((*arg1) += arg2); + REPLACE_BINARY_AndAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN((*arg1) += arg2); } void foo() { diff --git a/test/single_file/volatile.cc.expected b/test/single_file/volatile.cc.expected index 4ab4918b..828e3d88 100644 --- a/test/single_file/volatile.cc.expected +++ b/test/single_file/volatile.cc.expected @@ -42,29 +42,46 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 = arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 += arg2; + MUTATION_PRELUDE(arg1 += arg2); + REPLACE_BINARY_AndAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 += arg2); } static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } void foo() { diff --git a/test/single_file/volatile.cc.noopt.expected b/test/single_file/volatile.cc.noopt.expected index 0ccd0ab1..748a858d 100644 --- a/test/single_file/volatile.cc.noopt.expected +++ b/test/single_file/volatile.cc.noopt.expected @@ -42,30 +42,48 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { return (enabled_bitset[local_mutation_id / 64] & (1 << (local_mutation_id % 64))) != 0; } +#define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 +#define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 +#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 +#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 +#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <<= arg2 +#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 %= arg2 +#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 |= arg2 +#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 +#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 +#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 = arg2 +#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 +#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 += arg2; + MUTATION_PRELUDE(arg1 += arg2); + REPLACE_BINARY_AndAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 += arg2); } static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } void foo() { From 9b0e9d353a400c78eb912623fdfd1cc354988279 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 23:36:33 +0000 Subject: [PATCH 10/15] Update unit tests --- .../mutation_replace_binary_operator_test.cc | 452 +++++++++--------- .../src/mutation_replace_expr_test.cc | 72 +-- .../mutation_replace_unary_operator_test.cc | 96 ++-- 3 files changed, 310 insertions(+), 310 deletions(-) diff --git a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc index ff2ab550..45621c19 100644 --- a/src/libdreddtest/src/mutation_replace_binary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_binary_operator_test.cc @@ -81,12 +81,12 @@ TEST(MutationReplaceBinaryOperatorTest, MutateAdd) { "}"; const std::string expected_dredd_declaration_opt = R"(static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int_lhs_one(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Rem(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG2(3); + return MUTATION_RETURN(arg1 + arg2); } )"; @@ -101,14 +101,14 @@ TEST(MutationReplaceBinaryOperatorTest, MutateAdd) { "}"; const std::string expected_dredd_declaration_no_opt = R"(static int __dredd_replace_binary_operator_Add_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 % arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg2; - return arg1 + arg2; + MUTATION_PRELUDE(arg1 + arg2); + REPLACE_BINARY_Div(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Rem(2); + REPLACE_BINARY_Sub(3); + REPLACE_BINARY_ARG1(4); + REPLACE_BINARY_ARG2(5); + return MUTATION_RETURN(arg1 + arg2); } )"; @@ -130,11 +130,11 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAnd) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_EQ_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1 && arg2()); } )"; @@ -150,13 +150,13 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAnd) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_LOr_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_RHS_EVALUATED(1); + REPLACE_BINARY_NE_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1 && arg2()); } )"; @@ -178,11 +178,11 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLOr) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_LOr_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1 || arg2(); + MUTATION_PRELUDE(arg1 || arg2()); + REPLACE_BINARY_NE_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1 || arg2()); } )"; @@ -198,13 +198,13 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLOr) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_LOr_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1 || arg2(); + MUTATION_PRELUDE(arg1 || arg2()); + REPLACE_BINARY_LAnd_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_RHS_EVALUATED(1); + REPLACE_BINARY_NE_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1 || arg2()); } )"; @@ -226,10 +226,10 @@ TEST(MutationReplaceBinaryOperatorTest, MutateGT) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_GT_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 >= arg2; - return arg1 > arg2; + MUTATION_PRELUDE(arg1 > arg2); + REPLACE_BINARY_NE(0); + REPLACE_BINARY_GE(1); + return MUTATION_RETURN(arg1 > arg2); } )"; @@ -245,15 +245,15 @@ TEST(MutationReplaceBinaryOperatorTest, MutateGT) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_GT_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 > arg2; + MUTATION_PRELUDE(arg1 > arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_NE(1); + REPLACE_BINARY_GE(2); + REPLACE_BINARY_LE(3); + REPLACE_BINARY_LT(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 > arg2); } )"; @@ -275,10 +275,10 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLT) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_LT_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 <= arg2; - return arg1 < arg2; + MUTATION_PRELUDE(arg1 < arg2); + REPLACE_BINARY_NE(0); + REPLACE_BINARY_LE(1); + return MUTATION_RETURN(arg1 < arg2); } )"; @@ -294,15 +294,15 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLT) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_LT_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 < arg2; + MUTATION_PRELUDE(arg1 < arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_NE(1); + REPLACE_BINARY_GE(2); + REPLACE_BINARY_GT(3); + REPLACE_BINARY_LE(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 < arg2); } )"; @@ -324,10 +324,10 @@ TEST(MutationReplaceBinaryOperatorTest, MutateEQ) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_EQ_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 <= arg2; - return arg1 == arg2; + MUTATION_PRELUDE(arg1 == arg2); + REPLACE_BINARY_GE(0); + REPLACE_BINARY_LE(1); + return MUTATION_RETURN(arg1 == arg2); } )"; @@ -343,15 +343,15 @@ TEST(MutationReplaceBinaryOperatorTest, MutateEQ) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_EQ_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 == arg2; + MUTATION_PRELUDE(arg1 == arg2); + REPLACE_BINARY_NE(0); + REPLACE_BINARY_GE(1); + REPLACE_BINARY_GT(2); + REPLACE_BINARY_LE(3); + REPLACE_BINARY_LT(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 == arg2); } )"; @@ -373,10 +373,10 @@ TEST(MutationReplaceBinaryOperatorTest, MutateGE) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_GE_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 > arg2; - return arg1 >= arg2; + MUTATION_PRELUDE(arg1 >= arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_GT(1); + return MUTATION_RETURN(arg1 >= arg2); } )"; @@ -392,15 +392,15 @@ TEST(MutationReplaceBinaryOperatorTest, MutateGE) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_GE_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 >= arg2; + MUTATION_PRELUDE(arg1 >= arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_NE(1); + REPLACE_BINARY_GT(2); + REPLACE_BINARY_LE(3); + REPLACE_BINARY_LT(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 >= arg2); } )"; @@ -422,10 +422,10 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLE) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_LE_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 < arg2; - return arg1 <= arg2; + MUTATION_PRELUDE(arg1 <= arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_LT(1); + return MUTATION_RETURN(arg1 <= arg2); } )"; @@ -441,15 +441,15 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLE) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_LE_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 <= arg2; + MUTATION_PRELUDE(arg1 <= arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_NE(1); + REPLACE_BINARY_GE(2); + REPLACE_BINARY_GT(3); + REPLACE_BINARY_LT(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 <= arg2); } )"; @@ -471,10 +471,10 @@ TEST(MutationReplaceBinaryOperatorTest, MutateNE) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_NE_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 < arg2; - return arg1 != arg2; + MUTATION_PRELUDE(arg1 != arg2); + REPLACE_BINARY_GT(0); + REPLACE_BINARY_LT(1); + return MUTATION_RETURN(arg1 != arg2); } )"; @@ -490,15 +490,15 @@ TEST(MutationReplaceBinaryOperatorTest, MutateNE) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_NE_arg1_int_arg2_int(int arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 != arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 >= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 > arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 <= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 < arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg2; - return arg1 != arg2; + MUTATION_PRELUDE(arg1 != arg2); + REPLACE_BINARY_EQ(0); + REPLACE_BINARY_GE(1); + REPLACE_BINARY_GT(2); + REPLACE_BINARY_LE(3); + REPLACE_BINARY_LT(4); + REPLACE_BINARY_ARG1(5); + REPLACE_BINARY_ARG2(6); + return MUTATION_RETURN(arg1 != arg2); } )"; @@ -522,18 +522,18 @@ TEST(MutationReplaceBinaryOperatorTest, MutateAssign) { )"; const std::string expected_dredd_declaration_opt = R"(static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } )"; @@ -550,18 +550,18 @@ TEST(MutationReplaceBinaryOperatorTest, MutateAssign) { )"; const std::string expected_dredd_declaration_no_opt = R"(static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } )"; @@ -589,18 +589,18 @@ void foo() { )"; const std::string expected_dredd_declaration_opt = R"(static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } )"; @@ -619,18 +619,18 @@ void foo() { )"; const std::string expected_dredd_declaration_no_opt = R"(static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 &= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg1 |= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 5)) return arg1 %= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 6)) return arg1 <<= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 7)) return arg1 >>= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 8)) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 9)) return arg1 ^= arg2; - return arg1 = arg2; + MUTATION_PRELUDE(arg1 = arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_AndAssign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_OrAssign(4); + REPLACE_BINARY_RemAssign(5); + REPLACE_BINARY_ShlAssign(6); + REPLACE_BINARY_ShrAssign(7); + REPLACE_BINARY_SubAssign(8); + REPLACE_BINARY_XorAssign(9); + return MUTATION_RETURN(arg1 = arg2); } )"; @@ -656,13 +656,13 @@ TEST(MutationReplaceBinaryOperatorTest, MutateFloatDiv) { )"; const std::string expected_dredd_declaration_opt = R"(static float __dredd_replace_binary_operator_Div_arg1_float_arg2_float(float arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 / arg2; + MUTATION_PRELUDE(arg1 / arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 / arg2); } )"; @@ -680,13 +680,13 @@ TEST(MutationReplaceBinaryOperatorTest, MutateFloatDiv) { )"; const std::string expected_dredd_declaration_no_opt = R"(static float __dredd_replace_binary_operator_Div_arg1_float_arg2_float(float arg1, float arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 / arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 + arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 * arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 - arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2; - return arg1 / arg2; + MUTATION_PRELUDE(arg1 / arg2); + REPLACE_BINARY_Add(0); + REPLACE_BINARY_Mul(1); + REPLACE_BINARY_Sub(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2(4); + return MUTATION_RETURN(arg1 / arg2); } )"; @@ -712,12 +712,12 @@ TEST(MutationReplaceBinaryOperatorTest, MutateFloatSubAssign) { )"; const std::string expected_dredd_declaration_opt = R"(static double& __dredd_replace_binary_operator_SubAssign_arg1_double_arg2_double(double& arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - return arg1 -= arg2; + MUTATION_PRELUDE(arg1 -= arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + return MUTATION_RETURN(arg1 -= arg2); } )"; @@ -735,12 +735,12 @@ TEST(MutationReplaceBinaryOperatorTest, MutateFloatSubAssign) { )"; const std::string expected_dredd_declaration_no_opt = R"(static double& __dredd_replace_binary_operator_SubAssign_arg1_double_arg2_double(double& arg1, double arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 -= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 += arg2; - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 = arg2; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 /= arg2; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1 *= arg2; - return arg1 -= arg2; + MUTATION_PRELUDE(arg1 -= arg2); + REPLACE_BINARY_AddAssign(0); + REPLACE_BINARY_Assign(1); + REPLACE_BINARY_DivAssign(2); + REPLACE_BINARY_MulAssign(3); + return MUTATION_RETURN(arg1 -= arg2); } )"; @@ -762,11 +762,11 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAndWithLhsSideEffect) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(std::function arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1() && arg2(); + MUTATION_PRELUDE(arg1() && arg2()); + REPLACE_BINARY_EQ_LHS_EVALUATED_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1_EVALUATED(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1() && arg2()); } )"; @@ -782,13 +782,13 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAndWithLhsSideEffect) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(std::function arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1() && arg2(); + MUTATION_PRELUDE(arg1() && arg2()); + REPLACE_BINARY_LOr_LHS_EVALUATED_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_LHS_EVALUATED_RHS_EVALUATED(1); + REPLACE_BINARY_NE_LHS_EVALUATED_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1_EVALUATED(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1() && arg2()); } )"; @@ -810,11 +810,11 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAndWithRhsSideEffect) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_EQ_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1 && arg2()); } )"; @@ -830,13 +830,13 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAndWithRhsSideEffect) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(bool arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1 && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1 || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1 == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1 != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1 && arg2(); + MUTATION_PRELUDE(arg1 && arg2()); + REPLACE_BINARY_LOr_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_RHS_EVALUATED(1); + REPLACE_BINARY_NE_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1 && arg2()); } )"; @@ -858,11 +858,11 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAndWithLhsRhsSideEffect) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(std::function arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg2(); - return arg1() && arg2(); + MUTATION_PRELUDE(arg1() && arg2()); + REPLACE_BINARY_EQ_LHS_EVALUATED_RHS_EVALUATED(0); + REPLACE_BINARY_ARG1_EVALUATED(1); + REPLACE_BINARY_ARG2_EVALUATED(2); + return MUTATION_RETURN(arg1() && arg2()); } )"; @@ -878,13 +878,13 @@ TEST(MutationReplaceBinaryOperatorTest, MutateLAndWithLhsRhsSideEffect) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_binary_operator_LAnd_arg1_bool_arg2_bool(std::function arg1, std::function arg2, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg1() && arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 0)) return arg1() || arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 1)) return arg1() == arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 2)) return arg1() != arg2(); - if (__dredd_enabled_mutation(local_mutation_id + 3)) return arg1(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg2(); - return arg1() && arg2(); + MUTATION_PRELUDE(arg1() && arg2()); + REPLACE_BINARY_LOr_LHS_EVALUATED_RHS_EVALUATED(0); + REPLACE_BINARY_EQ_LHS_EVALUATED_RHS_EVALUATED(1); + REPLACE_BINARY_NE_LHS_EVALUATED_RHS_EVALUATED(2); + REPLACE_BINARY_ARG1_EVALUATED(3); + REPLACE_BINARY_ARG2_EVALUATED(4); + return MUTATION_RETURN(arg1() && arg2()); } )"; diff --git a/src/libdreddtest/src/mutation_replace_expr_test.cc b/src/libdreddtest/src/mutation_replace_expr_test.cc index 12727f3b..7cbfc093 100644 --- a/src/libdreddtest/src/mutation_replace_expr_test.cc +++ b/src/libdreddtest/src/mutation_replace_expr_test.cc @@ -81,13 +81,13 @@ TEST(MutationReplaceExprTest, MutateSignedConstants) { "void foo() { __dredd_replace_expr_int_constant(2, 0); }"; const std::string expected_dredd_declaration = R"(static int __dredd_replace_expr_int_constant(int 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 0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return 1; - if (__dredd_enabled_mutation(local_mutation_id + 4)) return -1; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_INT_ZERO(2); + REPLACE_EXPR_INT_ONE(3); + REPLACE_EXPR_INT_MINUS_ONE(4); + return MUTATION_RETURN(arg); } )"; @@ -103,11 +103,11 @@ TEST(MutationReplaceExprTest, MutateUnsignedConstants) { "__dredd_replace_expr_unsigned_int_constant(2, 0); }"; const std::string expected_dredd_declaration = R"(static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_NOT(0); + REPLACE_EXPR_INT_ZERO(1); + REPLACE_EXPR_INT_ONE(2); + return MUTATION_RETURN(arg); } )"; @@ -122,12 +122,12 @@ TEST(MutationReplaceExprTest, MutateFloatConstants) { "void foo() { __dredd_replace_expr_double(2.523, 0); }"; const std::string expected_dredd_declaration = R"(static double __dredd_replace_expr_double(double 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.0; - if (__dredd_enabled_mutation(local_mutation_id + 2)) return 1.0; - if (__dredd_enabled_mutation(local_mutation_id + 3)) return -1.0; - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_FLOAT_ZERO(1); + REPLACE_EXPR_FLOAT_ONE(2); + REPLACE_EXPR_FLOAT_MINUS_ONE(3); + return MUTATION_RETURN(arg); } )"; @@ -151,10 +151,10 @@ TEST(MutationReplaceExprTest, MutateLValues) { )"; const std::string expected_dredd_declaration = R"(static int __dredd_replace_expr_int_lvalue(int& 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); - return arg; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_INC(0); + MUTATION_EXPR_DEC(1); + return MUTATION_RETURN(arg); } )"; @@ -192,14 +192,14 @@ int neg(int x) { )"; const std::string expected_dredd_declaration = R"(static int __dredd_replace_expr_int(int 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; + MUTATION_PRELUDE(arg); + MUTATION_EXPR_LNOT(0); + MUTATION_EXPR_NOT(1); + MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_INT_ZERO(3); + REPLACE_EXPR_INT_ONE(4); + REPLACE_EXPR_INT_MINUS_ONE(5); + return MUTATION_RETURN(arg); } )"; @@ -223,9 +223,9 @@ bool foo(bool a, bool b) { )"; const std::string expected_dredd_declaration = R"(static bool __dredd_replace_expr_bool_omit_true(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return false; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_FALSE(0); + return MUTATION_RETURN(arg); } )"; @@ -249,9 +249,9 @@ bool foo(bool a, bool b) { )"; const std::string expected_dredd_declaration = R"(static bool __dredd_replace_expr_bool_omit_false(bool arg, int local_mutation_id) { - if (!__dredd_some_mutation_enabled) return arg; - if (__dredd_enabled_mutation(local_mutation_id + 0)) return true; - return arg; + MUTATION_PRELUDE(arg); + REPLACE_EXPR_TRUE(0); + return MUTATION_RETURN(arg); } )"; diff --git a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc index 77eb2b26..138cb7d3 100644 --- a/src/libdreddtest/src/mutation_replace_unary_operator_test.cc +++ b/src/libdreddtest/src/mutation_replace_unary_operator_test.cc @@ -78,10 +78,10 @@ TEST(MutationReplaceUnaryOperatorTest, MutateMinus) { "void foo() { __dredd_replace_unary_operator_Minus_int(2, 0); }"; const std::string expected_dredd_declaration_opt = R"(static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + return MUTATION_RETURN(-arg); } )"; @@ -95,11 +95,11 @@ TEST(MutationReplaceUnaryOperatorTest, MutateMinus) { "void foo() { __dredd_replace_unary_operator_Minus_int(2, 0); }"; const std::string expected_dredd_declaration_no_opt = R"(static int __dredd_replace_unary_operator_Minus_int(int 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; - return -arg; + MUTATION_PRELUDE(-arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_LNot(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(-arg); } )"; @@ -124,10 +124,10 @@ TEST(MutationReplaceUnaryOperatorTest, MutateNot) { )"; const std::string expected_dredd_declaration_opt = R"(static bool __dredd_replace_unary_operator_LNot_bool(bool 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + return MUTATION_RETURN(!arg); } )"; @@ -145,11 +145,11 @@ TEST(MutationReplaceUnaryOperatorTest, MutateNot) { )"; const std::string expected_dredd_declaration_no_opt = R"(static bool __dredd_replace_unary_operator_LNot_bool(bool 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; - return !arg; + MUTATION_PRELUDE(!arg); + REPLACE_UNARY_Not(0); + REPLACE_UNARY_Minus(1); + REPLACE_UNARY_ARG(2); + return MUTATION_RETURN(!arg); } )"; @@ -174,10 +174,10 @@ TEST(MutationReplaceUnaryOperatorTest, MutateIncrement) { )"; const std::string expected_dredd_declaration_opt = R"(static double& __dredd_replace_unary_operator_PreInc_double(std::function 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(); - return ++arg(); + MUTATION_PRELUDE(++arg()); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(++arg()); } )"; @@ -195,10 +195,10 @@ TEST(MutationReplaceUnaryOperatorTest, MutateIncrement) { )"; const std::string expected_dredd_declaration_noopt = R"(static double& __dredd_replace_unary_operator_PreInc_double(std::function 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(); - return ++arg(); + MUTATION_PRELUDE(++arg()); + REPLACE_UNARY_PreDec_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(++arg()); } )"; @@ -223,13 +223,13 @@ TEST(MutationReplaceUnaryOperatorTest, MutateDecrement) { )"; const std::string expected_dredd_declaration_opt = R"(static int __dredd_replace_unary_operator_PostDec_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()--; + MUTATION_PRELUDE(arg()--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()--); } )"; @@ -247,13 +247,13 @@ TEST(MutationReplaceUnaryOperatorTest, MutateDecrement) { )"; const std::string expected_dredd_declaration_no_opt = R"(static int __dredd_replace_unary_operator_PostDec_int(std::function 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 !arg(); - if (__dredd_enabled_mutation(local_mutation_id + 4)) return arg(); - return arg()--; + MUTATION_PRELUDE(arg()--); + REPLACE_UNARY_PostInc_EVALUATED(0); + REPLACE_UNARY_Not_EVALUATED(1); + REPLACE_UNARY_Minus_EVALUATED(2); + REPLACE_UNARY_LNot_EVALUATED(3); + REPLACE_UNARY_ARG_EVALUATED(4); + return MUTATION_RETURN(arg()--); } )"; @@ -278,10 +278,10 @@ TEST(MutationReplaceUnaryOperatorTest, MutateDecrementAssign) { )"; const std::string expected_dredd_declaration_opt = R"(static int& __dredd_replace_unary_operator_PreDec_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } )"; @@ -299,10 +299,10 @@ TEST(MutationReplaceUnaryOperatorTest, MutateDecrementAssign) { )"; const std::string expected_dredd_declaration_no_opt = R"(static int& __dredd_replace_unary_operator_PreDec_int(std::function 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(); - return --arg(); + MUTATION_PRELUDE(--arg()); + REPLACE_UNARY_PreInc_EVALUATED(0); + REPLACE_UNARY_ARG_EVALUATED(1); + return MUTATION_RETURN(--arg()); } )"; From c02999c2ac7c1ad305397d0fdda749da47183779 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 23:37:12 +0000 Subject: [PATCH 11/15] Formatting --- src/libdredd/src/mutation_replace_expr.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 7ef5b249..8c001381 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -187,7 +187,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( } if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_INC"; - if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; @@ -200,7 +201,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_DEC"; - if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; @@ -229,7 +231,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_LNOT"; - if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset @@ -249,7 +252,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_NOT"; - if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset @@ -269,7 +273,8 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { std::string macro_name = "MUTATION_EXPR_MINUS"; - if (ast_context.getLangOpts().CPlusPlus && expr_->HasSideEffects(ast_context)) { + if (ast_context.getLangOpts().CPlusPlus && + expr_->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } new_function << " " << macro_name << "(" << mutation_id_offset From bc0665fc2a4ac8e7142d15f8c4eebdb34b299b1c Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Wed, 22 Nov 2023 23:41:22 +0000 Subject: [PATCH 12/15] Add const --- src/libdredd/include/libdredd/util.h | 2 +- src/libdredd/src/util.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libdredd/include/libdredd/util.h b/src/libdredd/include/libdredd/util.h index 8252e295..047bb829 100644 --- a/src/libdredd/include/libdredd/util.h +++ b/src/libdredd/include/libdredd/util.h @@ -130,7 +130,7 @@ bool IsCxx11ConstantExpr(const clang::Expr& expr, std::string GenerateMutationPrelude(); -std::string GenerateMutationMacro(std::string& name, +std::string GenerateMutationMacro(const std::string& name, const std::string& arg_evaluated); std::string GenerateMutationReturn(); diff --git a/src/libdredd/src/util.cc b/src/libdredd/src/util.cc index 3adc5ff0..dcf6546a 100644 --- a/src/libdredd/src/util.cc +++ b/src/libdredd/src/util.cc @@ -134,7 +134,7 @@ std::string GenerateMutationPrelude() { "return arg\n"; } -std::string GenerateMutationMacro(std::string& name, +std::string GenerateMutationMacro(const std::string& name, const std::string& args_evaluated) { return "#define " + name + "(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id " From 4e8275e449d2bf585c87ffbcc7126d659c335df0 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Thu, 23 Nov 2023 13:27:25 +0000 Subject: [PATCH 13/15] Macro name bug fixes --- .../mutation_replace_binary_operator.h | 2 + .../include/libdredd/mutation_replace_expr.h | 2 + .../mutation_replace_unary_operator.h | 2 + .../src/mutation_replace_binary_operator.cc | 33 +++-- src/libdredd/src/mutation_replace_expr.cc | 41 +++---- .../src/mutation_replace_unary_operator.cc | 22 ++-- .../src/mutation_replace_expr_test.cc | 18 +-- test/single_file/add.c.expected | 26 ++-- test/single_file/add.c.noopt.expected | 20 +-- test/single_file/add.cc.expected | 26 ++-- test/single_file/add.cc.noopt.expected | 20 +-- test/single_file/add_float.c.expected | 28 ++--- test/single_file/add_float.c.noopt.expected | 40 +++--- test/single_file/add_float.cc.expected | 12 +- test/single_file/add_float.cc.noopt.expected | 24 ++-- test/single_file/add_mul.c.expected | 26 ++-- test/single_file/add_mul.c.noopt.expected | 20 +-- test/single_file/add_mul.cc.expected | 26 ++-- test/single_file/add_mul.cc.noopt.expected | 20 +-- .../add_type_aliases.c.noopt.expected | 46 +++---- .../add_type_aliases.cc.noopt.expected | 46 +++---- test/single_file/assign.c.expected | 68 +++++------ test/single_file/assign.c.noopt.expected | 72 +++++------ test/single_file/assign.cc.expected | 8 +- test/single_file/assign.cc.noopt.expected | 12 +- test/single_file/auto.cc.expected | 24 ++-- test/single_file/auto.cc.noopt.expected | 20 +-- test/single_file/basic.c.noopt.expected | 12 +- test/single_file/basic.cc.noopt.expected | 12 +- test/single_file/binary_lhs_zero.cc.expected | 24 ++-- .../binary_lhs_zero.cc.noopt.expected | 20 +-- ..._long_and_long_name_clash.c.noopt.expected | 24 ++-- .../binary_no_arg_replacement.cc.expected | 10 +- ...inary_no_arg_replacement.cc.noopt.expected | 12 +- .../binary_operands_both_zero.c.expected | 44 +++---- ...binary_operands_both_zero.c.noopt.expected | 52 ++++---- .../binary_operands_both_zero.cc.expected | 4 +- ...inary_operands_both_zero.cc.noopt.expected | 12 +- .../binary_redundant_name_clash.cc.expected | 8 +- ...ary_redundant_name_clash.cc.noopt.expected | 12 +- test/single_file/binary_rhs_zero.cc.expected | 24 ++-- .../binary_rhs_zero.cc.noopt.expected | 20 +-- test/single_file/bitfield.c.expected | 12 +- test/single_file/bitfield.c.noopt.expected | 12 +- test/single_file/bitfield.cc.expected | 12 +- test/single_file/bitfield.cc.noopt.expected | 24 ++-- .../bool_assignment.cc.noopt.expected | 4 +- ...lean_not_insertion_optimisation.c.expected | 4 +- ...ot_insertion_optimisation.c.noopt.expected | 12 +- ...t_insertion_optimisation.cc.noopt.expected | 4 +- test/single_file/comma.c.expected | 26 ++-- test/single_file/comma.c.noopt.expected | 20 +-- test/single_file/comment.cc.noopt.expected | 4 +- .../comment_at_start_of_file.cc.expected | 8 +- ...comment_at_start_of_file.cc.noopt.expected | 12 +- test/single_file/const_expr.cc.expected | 4 +- test/single_file/const_expr.cc.noopt.expected | 4 +- .../const_sized_array_int.c.noopt.expected | 12 +- .../const_sized_array_int.cc.noopt.expected | 12 +- .../define_at_start_of_file.c.expected | 4 +- .../define_at_start_of_file.c.noopt.expected | 12 +- .../define_in_first_decl.c.expected | 10 +- .../define_in_first_decl.c.noopt.expected | 12 +- .../define_in_first_decl.cc.expected | 10 +- .../define_in_first_decl.cc.noopt.expected | 12 +- test/single_file/enum.c.noopt.expected | 12 +- test/single_file/expr_lvalue.c.expected | 64 +++++----- test/single_file/expr_lvalue.c.noopt.expected | 60 ++++----- test/single_file/expr_lvalue.cc.expected | 24 ++-- .../single_file/expr_lvalue.cc.noopt.expected | 20 +-- test/single_file/float_binary_opts.c.expected | 4 +- .../float_binary_opts.c.noopt.expected | 4 +- .../single_file/float_binary_opts.cc.expected | 4 +- .../float_binary_opts.cc.noopt.expected | 4 +- .../float_unary_opt.c.noopt.expected | 4 +- .../float_unary_opt.cc.noopt.expected | 4 +- test/single_file/floats.c.expected | 50 ++++---- test/single_file/floats.c.noopt.expected | 50 ++++---- test/single_file/floats.cc.expected | 24 ++-- test/single_file/floats.cc.noopt.expected | 24 ++-- test/single_file/initializer.c.expected | 20 +-- test/single_file/initializer.c.noopt.expected | 20 +-- test/single_file/initializer.cc.expected | 20 +-- .../single_file/initializer.cc.noopt.expected | 20 +-- .../initializer_list.cc.noopt.expected | 12 +- test/single_file/lambda_capture.cc.expected | 16 +-- .../lambda_capture.cc.noopt.expected | 12 +- test/single_file/left_shift_opt.c.expected | 4 +- .../left_shift_opt.c.noopt.expected | 12 +- test/single_file/left_shift_opt.cc.expected | 4 +- .../left_shift_opt.cc.noopt.expected | 12 +- test/single_file/logical_and.c.expected | 20 +-- test/single_file/logical_and.c.noopt.expected | 20 +-- test/single_file/logical_and.cc.expected | 22 ++-- .../single_file/logical_and.cc.noopt.expected | 22 ++-- test/single_file/logical_and_div.cc.expected | 20 +-- .../logical_and_div.cc.noopt.expected | 22 ++-- test/single_file/logical_or.c.expected | 20 +-- test/single_file/logical_or.c.noopt.expected | 20 +-- test/single_file/logical_or.cc.expected | 22 ++-- test/single_file/logical_or.cc.noopt.expected | 22 ++-- test/single_file/misc002.cc.expected | 8 +- test/single_file/misc002.cc.noopt.expected | 14 +-- .../negative_switch_case.c.noopt.expected | 12 +- .../negative_switch_case.cc.noopt.expected | 12 +- .../non_const_sized_array.c.expected | 24 ++-- .../non_const_sized_array.c.noopt.expected | 20 +-- .../non_const_sized_array.cc.expected | 8 +- .../non_const_sized_array.cc.noopt.expected | 12 +- test/single_file/parens.cc.expected | 12 +- test/single_file/parens.cc.noopt.expected | 20 +-- .../positive_int_as_minus_one.c.expected | 26 ++-- ...positive_int_as_minus_one.c.noopt.expected | 30 ++--- .../positive_int_as_minus_one.cc.expected | 26 ++-- ...ositive_int_as_minus_one.cc.noopt.expected | 30 ++--- test/single_file/post_inc_volatile.c.expected | 84 ++++++------- .../post_inc_volatile.c.noopt.expected | 80 ++++++------ .../single_file/post_inc_volatile.cc.expected | 36 +++--- .../post_inc_volatile.cc.noopt.expected | 32 ++--- test/single_file/pre_dec_assign.cc.expected | 24 ++-- .../pre_dec_assign.cc.noopt.expected | 20 +-- test/single_file/preprocessor_if.c.expected | 48 ++++---- .../preprocessor_if.c.noopt.expected | 52 ++++---- test/single_file/printing.c.noopt.expected | 12 +- .../signed_int_constants.cc.expected | 26 ++-- .../signed_int_constants.cc.noopt.expected | 20 +-- test/single_file/sizeof_template.cc.expected | 8 +- .../sizeof_template.cc.noopt.expected | 8 +- test/single_file/sizeof_template2.cc.expected | 16 +-- .../sizeof_template2.cc.noopt.expected | 20 +-- .../static_initializer.cc.expected | 20 +-- .../static_initializer.cc.noopt.expected | 20 +-- .../structured_binding.cc.expected | 22 ++-- .../structured_binding.cc.noopt.expected | 26 ++-- test/single_file/template.cc.expected | 20 +-- test/single_file/template.cc.noopt.expected | 24 ++-- .../template_instantiation.cc.noopt.expected | 12 +- test/single_file/typedef.c.noopt.expected | 12 +- test/single_file/typedef.cc.noopt.expected | 12 +- test/single_file/unary.c.expected | 114 +++++++++--------- test/single_file/unary.c.noopt.expected | 112 ++++++++--------- test/single_file/unary.cc.expected | 26 ++-- test/single_file/unary.cc.noopt.expected | 38 +++--- test/single_file/unary_logical_not.c.expected | 14 +-- .../unary_logical_not.c.noopt.expected | 14 +-- .../single_file/unary_logical_not.cc.expected | 14 +-- .../unary_logical_not.cc.noopt.expected | 14 +-- test/single_file/unary_minus.c.expected | 22 ++-- test/single_file/unary_minus.c.noopt.expected | 20 +-- test/single_file/unary_minus.cc.expected | 22 ++-- .../single_file/unary_minus.cc.noopt.expected | 20 +-- .../single_file/unary_operator_opt.c.expected | 10 +- .../unary_operator_opt.c.noopt.expected | 12 +- test/single_file/unsigned_int.c.expected | 12 +- .../single_file/unsigned_int.c.noopt.expected | 16 +-- test/single_file/unsigned_int.cc.expected | 12 +- .../unsigned_int.cc.noopt.expected | 18 +-- test/single_file/using.cc.noopt.expected | 12 +- test/single_file/volatile.c.expected | 48 ++++---- test/single_file/volatile.c.noopt.expected | 52 ++++---- test/single_file/volatile.cc.expected | 8 +- test/single_file/volatile.cc.noopt.expected | 12 +- 162 files changed, 1759 insertions(+), 1745 deletions(-) diff --git a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h index ad1ba778..27169647 100644 --- a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h @@ -67,6 +67,8 @@ class MutationReplaceBinaryOperator : public Mutation { static std::string OpKindToString(clang::BinaryOperatorKind kind); + [[nodiscard]] std::string GetBinaryMacroName(const std::string& operator_name, const clang::ASTContext &ast_context) const; + [[nodiscard]] bool IsRedundantReplacementOperator( clang::BinaryOperatorKind operator_kind, const clang::ASTContext& ast_context) const; diff --git a/src/libdredd/include/libdredd/mutation_replace_expr.h b/src/libdredd/include/libdredd/mutation_replace_expr.h index d14a9574..c16cc9cf 100644 --- a/src/libdredd/include/libdredd/mutation_replace_expr.h +++ b/src/libdredd/include/libdredd/mutation_replace_expr.h @@ -44,6 +44,8 @@ class MutationReplaceExpr : public Mutation { std::unordered_set& dredd_declarations, std::unordered_set& dredd_macros) const override; + [[nodiscard]] std::string GetExprMacroName(const std::string& operator_name, const clang::ASTContext &ast_context) const; + static void ApplyCppTypeModifiers(const clang::Expr& expr, std::string& type); static void ApplyCTypeModifiers(const clang::Expr& expr, std::string& type); diff --git a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h index 1ac0a0eb..9c7233cf 100644 --- a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h @@ -69,6 +69,8 @@ class MutationReplaceUnaryOperator : public Mutation { static std::string OpKindToString(clang::UnaryOperatorKind kind); + [[nodiscard]] std::string GetUnaryMacroName(const std::string& operator_name, const clang::ASTContext &ast_context) const; + // Replaces unary operators with other valid unary operators. void GenerateUnaryOperatorReplacement( const std::string& arg_evaluated, const clang::ASTContext& ast_context, diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index bce42990..c5cadd53 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -231,6 +231,24 @@ std::string MutationReplaceBinaryOperator::GetFunctionName( return result; } +std::string MutationReplaceBinaryOperator::GetBinaryMacroName(const std::string& operator_name, const clang::ASTContext& ast_context) const { + std::string result = "REPLACE_BINARY_" + operator_name; + if (ast_context.getLangOpts().CPlusPlus && + binary_operator_->getLHS()->HasSideEffects(ast_context)) { + result += "_LHS_EVALUATED"; + } + if (ast_context.getLangOpts().CPlusPlus && + (binary_operator_->isLogicalOp() || + binary_operator_->getRHS()->HasSideEffects(ast_context))) { + result += "_RHS_EVALUATED"; + } + if (!ast_context.getLangOpts().CPlusPlus && + binary_operator_->isAssignmentOp()) { + result += "_LHS_POINTER"; + } + return result; +} + void MutationReplaceBinaryOperator::GenerateArgumentReplacement( const std::string& arg1_evaluated, const std::string& arg2_evaluated, const clang::ASTContext& ast_context, @@ -284,6 +302,9 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( if (ast_context.getLangOpts().CPlusPlus && binary_operator_->getLHS()->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; + } else if (!ast_context.getLangOpts().CPlusPlus && + binary_operator_->isAssignmentOp()) { + macro_name+= "_POINTER"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, arg1_evaluated)); @@ -337,17 +358,7 @@ void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { - std::string macro_name = - "REPLACE_BINARY_" + OpKindToString(operator_kind); - if (ast_context.getLangOpts().CPlusPlus && - binary_operator_->getLHS()->HasSideEffects(ast_context)) { - macro_name += "_LHS_EVALUATED"; - } - if (ast_context.getLangOpts().CPlusPlus && - (binary_operator_->isLogicalOp() || - binary_operator_->getRHS()->HasSideEffects(ast_context))) { - macro_name += "_RHS_EVALUATED"; - } + const std::string macro_name = GetBinaryMacroName(OpKindToString(operator_kind), ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro( macro_name, diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 8c001381..5df6e1df 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -115,6 +115,17 @@ void MutationReplaceExpr::AddOptimisationSpecifier( } } +std::string MutationReplaceExpr::GetExprMacroName(const std::string& operator_name, const clang::ASTContext& ast_context) const { + std::string result = "REPLACE_EXPR_" + operator_name; + if (ast_context.getLangOpts().CPlusPlus && + expr_->HasSideEffects(ast_context)) { + result += "_EVALUATED"; + } else if (!ast_context.getLangOpts().CPlusPlus && expr_->isLValue()) { + result += "_POINTER"; + } + return result; +} + bool MutationReplaceExpr::ExprIsEquivalentToInt( const clang::Expr& expr, int constant, const clang::ASTContext& ast_context) { @@ -186,11 +197,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( return; } if (!only_track_mutant_coverage) { - std::string macro_name = "MUTATION_EXPR_INC"; - if (ast_context.getLangOpts().CPlusPlus && - expr_->HasSideEffects(ast_context)) { - macro_name += "_EVALUATED"; - } + const std::string macro_name = GetExprMacroName("INC", ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( GenerateMutationMacro(macro_name, "++(" + arg_evaluated + ")")); @@ -200,11 +207,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeLValue( mutation_id_offset, protobuf_message); if (!only_track_mutant_coverage) { - std::string macro_name = "MUTATION_EXPR_DEC"; - if (ast_context.getLangOpts().CPlusPlus && - expr_->HasSideEffects(ast_context)) { - macro_name += "_EVALUATED"; - } + const std::string macro_name = GetExprMacroName("DEC", ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( GenerateMutationMacro(macro_name, "--(" + arg_evaluated + ")")); @@ -230,11 +233,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_LNot)) { if (!only_track_mutant_coverage) { - std::string macro_name = "MUTATION_EXPR_LNOT"; - if (ast_context.getLangOpts().CPlusPlus && - expr_->HasSideEffects(ast_context)) { - macro_name += "_EVALUATED"; - } + const std::string macro_name = GetExprMacroName("LNOT", ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( @@ -251,11 +250,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Not)) { if (!only_track_mutant_coverage) { - std::string macro_name = "MUTATION_EXPR_NOT"; - if (ast_context.getLangOpts().CPlusPlus && - expr_->HasSideEffects(ast_context)) { - macro_name += "_EVALUATED"; - } + const std::string macro_name = GetExprMacroName("NOT", ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( @@ -272,11 +267,7 @@ void MutationReplaceExpr::GenerateUnaryOperatorInsertionBeforeNonLValue( if (!optimise_mutations || !IsRedundantOperatorInsertion(ast_context, clang::UO_Minus)) { if (!only_track_mutant_coverage) { - std::string macro_name = "MUTATION_EXPR_MINUS"; - if (ast_context.getLangOpts().CPlusPlus && - expr_->HasSideEffects(ast_context)) { - macro_name += "_EVALUATED"; - } + const std::string macro_name = GetExprMacroName("MINUS", ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert( diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index d8f5f37c..d9271d30 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -282,6 +282,18 @@ bool MutationReplaceUnaryOperator::IsRedundantReplacementOperator( return false; } +std::string MutationReplaceUnaryOperator::GetUnaryMacroName(const std::string& operator_name, const clang::ASTContext& ast_context) const { + std::string result = "REPLACE_UNARY_" + operator_name; + if (ast_context.getLangOpts().CPlusPlus && unary_operator_->HasSideEffects(ast_context)) { + result += "_EVALUATED"; + } + if (!ast_context.getLangOpts().CPlusPlus && + unary_operator_->isIncrementDecrementOp()) { + result += "_POINTER"; + } + return result; +} + void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( const std::string& arg_evaluated, const clang::ASTContext& ast_context, std::unordered_set& dredd_macros, bool optimise_mutations, @@ -305,10 +317,7 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( continue; } if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_UNARY_" + OpKindToString(operator_kind); - if (unary_operator_->HasSideEffects(ast_context)) { - macro_name += "_EVALUATED"; - } + const std::string macro_name = GetUnaryMacroName(OpKindToString(operator_kind), ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; if (IsPrefix(operator_kind)) { dredd_macros.insert(GenerateMutationMacro( @@ -331,10 +340,7 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( // another mutation. if (!optimise_mutations || !IsOperatorSelfInverse()) { if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_UNARY_ARG"; - if (unary_operator_->HasSideEffects(ast_context)) { - macro_name += "_EVALUATED"; - } + const std::string macro_name = GetUnaryMacroName("ARG", ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, arg_evaluated)); } diff --git a/src/libdreddtest/src/mutation_replace_expr_test.cc b/src/libdreddtest/src/mutation_replace_expr_test.cc index 7cbfc093..5d6905e4 100644 --- a/src/libdreddtest/src/mutation_replace_expr_test.cc +++ b/src/libdreddtest/src/mutation_replace_expr_test.cc @@ -82,8 +82,8 @@ TEST(MutationReplaceExprTest, MutateSignedConstants) { const std::string expected_dredd_declaration = R"(static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -104,7 +104,7 @@ TEST(MutationReplaceExprTest, MutateUnsignedConstants) { const std::string expected_dredd_declaration = R"(static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_ONE(2); return MUTATION_RETURN(arg); @@ -123,7 +123,7 @@ TEST(MutationReplaceExprTest, MutateFloatConstants) { const std::string expected_dredd_declaration = R"(static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -152,8 +152,8 @@ TEST(MutationReplaceExprTest, MutateLValues) { const std::string expected_dredd_declaration = R"(static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } @@ -193,9 +193,9 @@ int neg(int x) { const std::string expected_dredd_declaration = R"(static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add.c.expected b/test/single_file/add.c.expected index 288a4819..da3b9fee 100644 --- a/test/single_file/add.c.expected +++ b/test/single_file/add.c.expected @@ -41,24 +41,24 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -66,15 +66,15 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -83,9 +83,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add.c.noopt.expected b/test/single_file/add.c.noopt.expected index 27ee0a40..f9bc3b4a 100644 --- a/test/single_file/add.c.noopt.expected +++ b/test/single_file/add.c.noopt.expected @@ -41,33 +41,33 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add.cc.expected b/test/single_file/add.cc.expected index 159053d7..507f78a5 100644 --- a/test/single_file/add.cc.expected +++ b/test/single_file/add.cc.expected @@ -43,24 +43,24 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -68,15 +68,15 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -85,9 +85,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add.cc.noopt.expected b/test/single_file/add.cc.noopt.expected index cfa2aa18..87cca3bf 100644 --- a/test/single_file/add.cc.noopt.expected +++ b/test/single_file/add.cc.noopt.expected @@ -43,33 +43,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add_float.c.expected b/test/single_file/add_float.c.expected index d6aa6667..d88bf3c9 100644 --- a/test/single_file/add_float.c.expected +++ b/test/single_file/add_float.c.expected @@ -41,23 +41,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -68,14 +68,14 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static float __dredd_replace_expr_float_lvalue(float* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -84,10 +84,10 @@ static float __dredd_replace_expr_float(float arg, int local_mutation_id) { static float __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float* arg1, float arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_DivAssign(1); - REPLACE_BINARY_MulAssign(2); - REPLACE_BINARY_SubAssign(3); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_DivAssign_LHS_POINTER(1); + REPLACE_BINARY_MulAssign_LHS_POINTER(2); + REPLACE_BINARY_SubAssign_LHS_POINTER(3); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/add_float.c.noopt.expected b/test/single_file/add_float.c.noopt.expected index 615f1801..e53a80f5 100644 --- a/test/single_file/add_float.c.noopt.expected +++ b/test/single_file/add_float.c.noopt.expected @@ -41,32 +41,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -75,14 +75,14 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static float __dredd_replace_expr_float_lvalue(float* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -91,10 +91,10 @@ static float __dredd_replace_expr_float(float arg, int local_mutation_id) { static float __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float* arg1, float arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_DivAssign(1); - REPLACE_BINARY_MulAssign(2); - REPLACE_BINARY_SubAssign(3); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_DivAssign_LHS_POINTER(1); + REPLACE_BINARY_MulAssign_LHS_POINTER(2); + REPLACE_BINARY_SubAssign_LHS_POINTER(3); return MUTATION_RETURN((*arg1) = arg2); } @@ -110,7 +110,7 @@ static float __dredd_replace_binary_operator_Add_arg1_float_arg2_float(float arg static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/add_float.cc.expected b/test/single_file/add_float.cc.expected index b816d465..3d531023 100644 --- a/test/single_file/add_float.cc.expected +++ b/test/single_file/add_float.cc.expected @@ -43,11 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 @@ -57,9 +60,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -79,14 +79,14 @@ static float& __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float static float __dredd_replace_expr_float_lvalue(float& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/add_float.cc.noopt.expected b/test/single_file/add_float.cc.noopt.expected index 831c87ab..df946bbe 100644 --- a/test/single_file/add_float.cc.noopt.expected +++ b/test/single_file/add_float.cc.noopt.expected @@ -43,12 +43,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 @@ -58,17 +63,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -86,14 +86,14 @@ static float& __dredd_replace_binary_operator_Assign_arg1_float_arg2_float(float static float __dredd_replace_expr_float_lvalue(float& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -112,7 +112,7 @@ static float __dredd_replace_binary_operator_Add_arg1_float_arg2_float(float arg static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/add_mul.c.expected b/test/single_file/add_mul.c.expected index bae545d0..725f65e7 100644 --- a/test/single_file/add_mul.c.expected +++ b/test/single_file/add_mul.c.expected @@ -41,9 +41,14 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 @@ -51,15 +56,10 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -67,15 +67,15 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -84,9 +84,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add_mul.c.noopt.expected b/test/single_file/add_mul.c.noopt.expected index d452e83f..e5ef73a0 100644 --- a/test/single_file/add_mul.c.noopt.expected +++ b/test/single_file/add_mul.c.noopt.expected @@ -41,9 +41,14 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 @@ -51,24 +56,19 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add_mul.cc.expected b/test/single_file/add_mul.cc.expected index c59d3c8c..41efcd13 100644 --- a/test/single_file/add_mul.cc.expected +++ b/test/single_file/add_mul.cc.expected @@ -43,9 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 @@ -53,15 +58,10 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -69,15 +69,15 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -86,9 +86,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add_mul.cc.noopt.expected b/test/single_file/add_mul.cc.noopt.expected index afeff625..38f052f0 100644 --- a/test/single_file/add_mul.cc.noopt.expected +++ b/test/single_file/add_mul.cc.noopt.expected @@ -43,9 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 @@ -53,24 +58,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add_type_aliases.c.noopt.expected b/test/single_file/add_type_aliases.c.noopt.expected index ca44509d..93ba3176 100644 --- a/test/single_file/add_type_aliases.c.noopt.expected +++ b/test/single_file/add_type_aliases.c.noopt.expected @@ -41,32 +41,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long_lvalue(unsigned long* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static unsigned long __dredd_replace_expr_unsigned_long(unsigned long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -85,15 +85,15 @@ static unsigned long __dredd_replace_binary_operator_Add_arg1_unsigned_long_arg2 static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -112,16 +112,16 @@ static unsigned int __dredd_replace_binary_operator_Add_arg1_unsigned_int_arg2_u static long __dredd_replace_expr_long_lvalue(long* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static long __dredd_replace_expr_long(long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -141,16 +141,16 @@ static long __dredd_replace_binary_operator_Add_arg1_long_arg2_long(long arg1, l static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/add_type_aliases.cc.noopt.expected b/test/single_file/add_type_aliases.cc.noopt.expected index 6f47544c..72ca90e4 100644 --- a/test/single_file/add_type_aliases.cc.noopt.expected +++ b/test/single_file/add_type_aliases.cc.noopt.expected @@ -43,32 +43,32 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long_lvalue(unsigned long& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static unsigned long __dredd_replace_expr_unsigned_long(unsigned long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -87,15 +87,15 @@ static unsigned long __dredd_replace_binary_operator_Add_arg1_unsigned_long_arg2 static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -114,16 +114,16 @@ static unsigned int __dredd_replace_binary_operator_Add_arg1_unsigned_int_arg2_u static long __dredd_replace_expr_long_lvalue(long& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static long __dredd_replace_expr_long(long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -143,16 +143,16 @@ static long __dredd_replace_binary_operator_Add_arg1_long_arg2_long(long arg1, l static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/assign.c.expected b/test/single_file/assign.c.expected index 3cf00b9e..89b84ed2 100644 --- a/test/single_file/assign.c.expected +++ b/test/single_file/assign.c.expected @@ -41,26 +41,26 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -69,31 +69,31 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/assign.c.noopt.expected b/test/single_file/assign.c.noopt.expected index 5a3a5e59..34d76156 100644 --- a/test/single_file/assign.c.noopt.expected +++ b/test/single_file/assign.c.noopt.expected @@ -41,28 +41,28 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -71,31 +71,31 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/assign.cc.expected b/test/single_file/assign.cc.expected index 8bcff7f2..b348490d 100644 --- a/test/single_file/assign.cc.expected +++ b/test/single_file/assign.cc.expected @@ -43,6 +43,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -56,8 +58,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2); @@ -91,8 +91,8 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/assign.cc.noopt.expected b/test/single_file/assign.cc.noopt.expected index 66653ea2..bc4a7c32 100644 --- a/test/single_file/assign.cc.noopt.expected +++ b/test/single_file/assign.cc.noopt.expected @@ -43,6 +43,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -56,9 +59,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_Assign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2); @@ -92,9 +92,9 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/auto.cc.expected b/test/single_file/auto.cc.expected index d3850dda..010a2e3a 100644 --- a/test/single_file/auto.cc.expected +++ b/test/single_file/auto.cc.expected @@ -43,26 +43,26 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -71,9 +71,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/auto.cc.noopt.expected b/test/single_file/auto.cc.noopt.expected index d7805bbb..71d6aa3c 100644 --- a/test/single_file/auto.cc.noopt.expected +++ b/test/single_file/auto.cc.noopt.expected @@ -43,27 +43,27 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/basic.c.noopt.expected b/test/single_file/basic.c.noopt.expected index c9997672..a899b69e 100644 --- a/test/single_file/basic.c.noopt.expected +++ b/test/single_file/basic.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/basic.cc.noopt.expected b/test/single_file/basic.cc.noopt.expected index 53492aab..49832e03 100644 --- a/test/single_file/basic.cc.noopt.expected +++ b/test/single_file/basic.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_lhs_zero.cc.expected b/test/single_file/binary_lhs_zero.cc.expected index 7174fbb1..8414d49a 100644 --- a/test/single_file/binary_lhs_zero.cc.expected +++ b/test/single_file/binary_lhs_zero.cc.expected @@ -43,16 +43,16 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -63,15 +63,15 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -80,9 +80,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_lhs_zero.cc.noopt.expected b/test/single_file/binary_lhs_zero.cc.noopt.expected index 820fe5f8..8e72326f 100644 --- a/test/single_file/binary_lhs_zero.cc.noopt.expected +++ b/test/single_file/binary_lhs_zero.cc.noopt.expected @@ -43,33 +43,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected b/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected index 32c68f73..f9627b16 100644 --- a/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected +++ b/test/single_file/binary_long_long_and_long_name_clash.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static long long __dredd_replace_expr_long_long(long long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -73,9 +73,9 @@ static long long __dredd_replace_binary_operator_LAnd_arg1_long_arg2_long_long_r } static long __dredd_replace_expr_long(long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -96,9 +96,9 @@ static long __dredd_replace_binary_operator_LAnd_arg1_long_arg2_long_long_lhs(lo } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_no_arg_replacement.cc.expected b/test/single_file/binary_no_arg_replacement.cc.expected index 92fbaa28..546201af 100644 --- a/test/single_file/binary_no_arg_replacement.cc.expected +++ b/test/single_file/binary_no_arg_replacement.cc.expected @@ -43,6 +43,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -52,8 +54,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -64,7 +64,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -79,8 +79,8 @@ static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/binary_no_arg_replacement.cc.noopt.expected b/test/single_file/binary_no_arg_replacement.cc.noopt.expected index f8c3fa59..4e96c2d4 100644 --- a/test/single_file/binary_no_arg_replacement.cc.noopt.expected +++ b/test/single_file/binary_no_arg_replacement.cc.noopt.expected @@ -46,6 +46,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -56,9 +59,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -70,9 +70,9 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_operands_both_zero.c.expected b/test/single_file/binary_operands_both_zero.c.expected index 98926e11..27b9869b 100644 --- a/test/single_file/binary_operands_both_zero.c.expected +++ b/test/single_file/binary_operands_both_zero.c.expected @@ -41,23 +41,23 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -68,7 +68,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -83,16 +83,16 @@ static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/binary_operands_both_zero.c.noopt.expected b/test/single_file/binary_operands_both_zero.c.noopt.expected index 8373db7e..04c2d874 100644 --- a/test/single_file/binary_operands_both_zero.c.noopt.expected +++ b/test/single_file/binary_operands_both_zero.c.noopt.expected @@ -44,28 +44,28 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -77,9 +77,9 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -88,16 +88,16 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/binary_operands_both_zero.cc.expected b/test/single_file/binary_operands_both_zero.cc.expected index 595a467a..52abc986 100644 --- a/test/single_file/binary_operands_both_zero.cc.expected +++ b/test/single_file/binary_operands_both_zero.cc.expected @@ -43,6 +43,7 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -59,7 +60,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2); @@ -85,7 +85,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/binary_operands_both_zero.cc.noopt.expected b/test/single_file/binary_operands_both_zero.cc.noopt.expected index 0a9f99de..80892a85 100644 --- a/test/single_file/binary_operands_both_zero.cc.noopt.expected +++ b/test/single_file/binary_operands_both_zero.cc.noopt.expected @@ -46,6 +46,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -65,9 +68,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2); @@ -94,9 +94,9 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_redundant_name_clash.cc.expected b/test/single_file/binary_redundant_name_clash.cc.expected index 7e5e1274..e1fd10e8 100644 --- a/test/single_file/binary_redundant_name_clash.cc.expected +++ b/test/single_file/binary_redundant_name_clash.cc.expected @@ -43,6 +43,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -50,8 +52,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -62,8 +62,8 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/binary_redundant_name_clash.cc.noopt.expected b/test/single_file/binary_redundant_name_clash.cc.noopt.expected index df706e12..8d03c552 100644 --- a/test/single_file/binary_redundant_name_clash.cc.noopt.expected +++ b/test/single_file/binary_redundant_name_clash.cc.noopt.expected @@ -43,6 +43,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -52,15 +55,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_rhs_zero.cc.expected b/test/single_file/binary_rhs_zero.cc.expected index fc397f89..297b2187 100644 --- a/test/single_file/binary_rhs_zero.cc.expected +++ b/test/single_file/binary_rhs_zero.cc.expected @@ -43,16 +43,16 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -63,15 +63,15 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -80,9 +80,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/binary_rhs_zero.cc.noopt.expected b/test/single_file/binary_rhs_zero.cc.noopt.expected index 15f3c26a..28708c9f 100644 --- a/test/single_file/binary_rhs_zero.cc.noopt.expected +++ b/test/single_file/binary_rhs_zero.cc.noopt.expected @@ -43,33 +43,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/bitfield.c.expected b/test/single_file/bitfield.c.expected index 1ef22c56..edf7a3c6 100644 --- a/test/single_file/bitfield.c.expected +++ b/test/single_file/bitfield.c.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/bitfield.c.noopt.expected b/test/single_file/bitfield.c.noopt.expected index 887bf4c5..78eedf4f 100644 --- a/test/single_file/bitfield.c.noopt.expected +++ b/test/single_file/bitfield.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/bitfield.cc.expected b/test/single_file/bitfield.cc.expected index aa57f3be..a381bafa 100644 --- a/test/single_file/bitfield.cc.expected +++ b/test/single_file/bitfield.cc.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/bitfield.cc.noopt.expected b/test/single_file/bitfield.cc.noopt.expected index 8e031c80..5ebc2938 100644 --- a/test/single_file/bitfield.cc.noopt.expected +++ b/test/single_file/bitfield.cc.noopt.expected @@ -43,21 +43,21 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -66,9 +66,9 @@ static int __dredd_replace_expr_int(std::function arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/bool_assignment.cc.noopt.expected b/test/single_file/bool_assignment.cc.noopt.expected index abbcc4be..90f5fab2 100644 --- a/test/single_file/bool_assignment.cc.noopt.expected +++ b/test/single_file/bool_assignment.cc.noopt.expected @@ -44,12 +44,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/boolean_not_insertion_optimisation.c.expected b/test/single_file/boolean_not_insertion_optimisation.c.expected index bdf6b810..c7966b0c 100644 --- a/test/single_file/boolean_not_insertion_optimisation.c.expected +++ b/test/single_file/boolean_not_insertion_optimisation.c.expected @@ -41,10 +41,10 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -55,7 +55,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected b/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected index 5fe8ad4a..365a26a1 100644 --- a/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected +++ b/test/single_file/boolean_not_insertion_optimisation.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected b/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected index 60b5a553..b6aca6df 100644 --- a/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected +++ b/test/single_file/boolean_not_insertion_optimisation.cc.noopt.expected @@ -44,6 +44,7 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false #define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 #define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 @@ -55,7 +56,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool& __dredd_replace_binary_operator_Assign_arg1_bool_arg2_bool(bool& arg1, bool arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2); @@ -74,7 +74,7 @@ static bool& __dredd_replace_binary_operator_Assign_arg1_bool_arg2_bool(bool& ar static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/comma.c.expected b/test/single_file/comma.c.expected index f03d28f4..c51ce785 100644 --- a/test/single_file/comma.c.expected +++ b/test/single_file/comma.c.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -60,15 +60,15 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -77,9 +77,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/comma.c.noopt.expected b/test/single_file/comma.c.noopt.expected index 454aa664..bef58434 100644 --- a/test/single_file/comma.c.noopt.expected +++ b/test/single_file/comma.c.noopt.expected @@ -41,27 +41,27 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/comment.cc.noopt.expected b/test/single_file/comment.cc.noopt.expected index 50d92bce..57a1e584 100644 --- a/test/single_file/comment.cc.noopt.expected +++ b/test/single_file/comment.cc.noopt.expected @@ -44,12 +44,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/comment_at_start_of_file.cc.expected b/test/single_file/comment_at_start_of_file.cc.expected index 7d59ca50..096f2d7a 100644 --- a/test/single_file/comment_at_start_of_file.cc.expected +++ b/test/single_file/comment_at_start_of_file.cc.expected @@ -43,16 +43,16 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/comment_at_start_of_file.cc.noopt.expected b/test/single_file/comment_at_start_of_file.cc.noopt.expected index 45536b3b..f650d53d 100644 --- a/test/single_file/comment_at_start_of_file.cc.noopt.expected +++ b/test/single_file/comment_at_start_of_file.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/const_expr.cc.expected b/test/single_file/const_expr.cc.expected index 216f5cb0..368e2f1d 100644 --- a/test/single_file/const_expr.cc.expected +++ b/test/single_file/const_expr.cc.expected @@ -43,14 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/const_expr.cc.noopt.expected b/test/single_file/const_expr.cc.noopt.expected index 216f5cb0..368e2f1d 100644 --- a/test/single_file/const_expr.cc.noopt.expected +++ b/test/single_file/const_expr.cc.noopt.expected @@ -43,14 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/const_sized_array_int.c.noopt.expected b/test/single_file/const_sized_array_int.c.noopt.expected index 06f47bd0..2ade58b7 100644 --- a/test/single_file/const_sized_array_int.c.noopt.expected +++ b/test/single_file/const_sized_array_int.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/const_sized_array_int.cc.noopt.expected b/test/single_file/const_sized_array_int.cc.noopt.expected index f91c5d43..e9dce351 100644 --- a/test/single_file/const_sized_array_int.cc.noopt.expected +++ b/test/single_file/const_sized_array_int.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/define_at_start_of_file.c.expected b/test/single_file/define_at_start_of_file.c.expected index bcd2afbe..c4a7cc3d 100644 --- a/test/single_file/define_at_start_of_file.c.expected +++ b/test/single_file/define_at_start_of_file.c.expected @@ -41,13 +41,13 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/define_at_start_of_file.c.noopt.expected b/test/single_file/define_at_start_of_file.c.noopt.expected index 9be0d734..9fc0c405 100644 --- a/test/single_file/define_at_start_of_file.c.noopt.expected +++ b/test/single_file/define_at_start_of_file.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/define_in_first_decl.c.expected b/test/single_file/define_in_first_decl.c.expected index f2027796..7e6349e7 100644 --- a/test/single_file/define_in_first_decl.c.expected +++ b/test/single_file/define_in_first_decl.c.expected @@ -41,6 +41,8 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -48,12 +50,10 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -61,8 +61,8 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/define_in_first_decl.c.noopt.expected b/test/single_file/define_in_first_decl.c.noopt.expected index 07a40364..5ea2b826 100644 --- a/test/single_file/define_in_first_decl.c.noopt.expected +++ b/test/single_file/define_in_first_decl.c.noopt.expected @@ -41,6 +41,9 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -50,15 +53,12 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/define_in_first_decl.cc.expected b/test/single_file/define_in_first_decl.cc.expected index c5e71bf4..ab6dd5ae 100644 --- a/test/single_file/define_in_first_decl.cc.expected +++ b/test/single_file/define_in_first_decl.cc.expected @@ -43,6 +43,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -50,12 +52,10 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -63,8 +63,8 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/define_in_first_decl.cc.noopt.expected b/test/single_file/define_in_first_decl.cc.noopt.expected index 2dde7807..8bb37ed4 100644 --- a/test/single_file/define_in_first_decl.cc.noopt.expected +++ b/test/single_file/define_in_first_decl.cc.noopt.expected @@ -43,6 +43,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -52,15 +55,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/enum.c.noopt.expected b/test/single_file/enum.c.noopt.expected index ebe1e7ca..41382fe8 100644 --- a/test/single_file/enum.c.noopt.expected +++ b/test/single_file/enum.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/expr_lvalue.c.expected b/test/single_file/expr_lvalue.c.expected index b0c337d9..e78be5d0 100644 --- a/test/single_file/expr_lvalue.c.expected +++ b/test/single_file/expr_lvalue.c.expected @@ -41,36 +41,36 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -79,9 +79,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -90,16 +90,16 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/expr_lvalue.c.noopt.expected b/test/single_file/expr_lvalue.c.noopt.expected index 6e3546a8..ff42401f 100644 --- a/test/single_file/expr_lvalue.c.noopt.expected +++ b/test/single_file/expr_lvalue.c.noopt.expected @@ -41,37 +41,37 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -80,16 +80,16 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/expr_lvalue.cc.expected b/test/single_file/expr_lvalue.cc.expected index 8afd1b22..e516a8f4 100644 --- a/test/single_file/expr_lvalue.cc.expected +++ b/test/single_file/expr_lvalue.cc.expected @@ -43,9 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 #define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 #define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 @@ -56,11 +61,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2); @@ -79,15 +79,15 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -96,9 +96,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/expr_lvalue.cc.noopt.expected b/test/single_file/expr_lvalue.cc.noopt.expected index 77a6ed0c..518e7591 100644 --- a/test/single_file/expr_lvalue.cc.noopt.expected +++ b/test/single_file/expr_lvalue.cc.noopt.expected @@ -43,9 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2 #define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 #define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >>= arg2 @@ -56,11 +61,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 #define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2); @@ -79,16 +79,16 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/float_binary_opts.c.expected b/test/single_file/float_binary_opts.c.expected index 181607ac..999ff5c8 100644 --- a/test/single_file/float_binary_opts.c.expected +++ b/test/single_file/float_binary_opts.c.expected @@ -41,6 +41,7 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 @@ -49,7 +50,6 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double_zero(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -60,7 +60,7 @@ static double __dredd_replace_expr_double_zero(double arg, int local_mutation_id static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/float_binary_opts.c.noopt.expected b/test/single_file/float_binary_opts.c.noopt.expected index d202e4c4..9842fd78 100644 --- a/test/single_file/float_binary_opts.c.noopt.expected +++ b/test/single_file/float_binary_opts.c.noopt.expected @@ -41,6 +41,7 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 @@ -49,11 +50,10 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/float_binary_opts.cc.expected b/test/single_file/float_binary_opts.cc.expected index e42992aa..817ce9a4 100644 --- a/test/single_file/float_binary_opts.cc.expected +++ b/test/single_file/float_binary_opts.cc.expected @@ -43,6 +43,7 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 @@ -51,7 +52,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double_zero(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -62,7 +62,7 @@ static double __dredd_replace_expr_double_zero(double arg, int local_mutation_id static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/float_binary_opts.cc.noopt.expected b/test/single_file/float_binary_opts.cc.noopt.expected index ba9e4957..8672bcaf 100644 --- a/test/single_file/float_binary_opts.cc.noopt.expected +++ b/test/single_file/float_binary_opts.cc.noopt.expected @@ -43,6 +43,7 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 @@ -51,11 +52,10 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/float_unary_opt.c.noopt.expected b/test/single_file/float_unary_opt.c.noopt.expected index 2d1a74c3..e8721914 100644 --- a/test/single_file/float_unary_opt.c.noopt.expected +++ b/test/single_file/float_unary_opt.c.noopt.expected @@ -43,10 +43,10 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_unary_operator_Minus_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -57,7 +57,7 @@ static double __dredd_replace_unary_operator_Minus_double(double arg, int local_ static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/float_unary_opt.cc.noopt.expected b/test/single_file/float_unary_opt.cc.noopt.expected index 9d81ffa0..9275f30c 100644 --- a/test/single_file/float_unary_opt.cc.noopt.expected +++ b/test/single_file/float_unary_opt.cc.noopt.expected @@ -45,10 +45,10 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static double __dredd_replace_unary_operator_Minus_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -59,7 +59,7 @@ static double __dredd_replace_unary_operator_Minus_double(double arg, int local_ static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/floats.c.expected b/test/single_file/floats.c.expected index df0bff24..11025508 100644 --- a/test/single_file/floats.c.expected +++ b/test/single_file/floats.c.expected @@ -41,34 +41,34 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_Assign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -77,7 +77,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -86,10 +86,10 @@ static float __dredd_replace_expr_float(float arg, int local_mutation_id) { static float __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(float* arg1, double arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) -= arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_Assign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_Assign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); return MUTATION_RETURN((*arg1) -= arg2); } @@ -102,14 +102,14 @@ static double __dredd_replace_expr_double_one(double arg, int local_mutation_id) static double __dredd_replace_expr_double_lvalue(double* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -138,10 +138,10 @@ static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double static double __dredd_replace_binary_operator_AddAssign_arg1_double_arg2_double(double* arg1, double arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) += arg2); - REPLACE_BINARY_Assign(0); - REPLACE_BINARY_DivAssign(1); - REPLACE_BINARY_MulAssign(2); - REPLACE_BINARY_SubAssign(3); + REPLACE_BINARY_Assign_LHS_POINTER(0); + REPLACE_BINARY_DivAssign_LHS_POINTER(1); + REPLACE_BINARY_MulAssign_LHS_POINTER(2); + REPLACE_BINARY_SubAssign_LHS_POINTER(3); return MUTATION_RETURN((*arg1) += arg2); } diff --git a/test/single_file/floats.c.noopt.expected b/test/single_file/floats.c.noopt.expected index 18d3583b..7b054d37 100644 --- a/test/single_file/floats.c.noopt.expected +++ b/test/single_file/floats.c.noopt.expected @@ -41,34 +41,34 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_Assign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -77,7 +77,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -86,23 +86,23 @@ static float __dredd_replace_expr_float(float arg, int local_mutation_id) { static float __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(float* arg1, double arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) -= arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_Assign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_Assign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); return MUTATION_RETURN((*arg1) -= arg2); } static double __dredd_replace_expr_double_lvalue(double* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -131,10 +131,10 @@ static double __dredd_replace_binary_operator_Add_arg1_double_arg2_double(double static double __dredd_replace_binary_operator_AddAssign_arg1_double_arg2_double(double* arg1, double arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) += arg2); - REPLACE_BINARY_Assign(0); - REPLACE_BINARY_DivAssign(1); - REPLACE_BINARY_MulAssign(2); - REPLACE_BINARY_SubAssign(3); + REPLACE_BINARY_Assign_LHS_POINTER(0); + REPLACE_BINARY_DivAssign_LHS_POINTER(1); + REPLACE_BINARY_MulAssign_LHS_POINTER(2); + REPLACE_BINARY_SubAssign_LHS_POINTER(3); return MUTATION_RETURN((*arg1) += arg2); } diff --git a/test/single_file/floats.cc.expected b/test/single_file/floats.cc.expected index 9f71b759..23fbada4 100644 --- a/test/single_file/floats.cc.expected +++ b/test/single_file/floats.cc.expected @@ -43,12 +43,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 @@ -60,17 +65,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -88,7 +88,7 @@ static float& __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(f static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -113,14 +113,14 @@ static double __dredd_replace_expr_double_one(double arg, int local_mutation_id) static double __dredd_replace_expr_double_lvalue(double& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/floats.cc.noopt.expected b/test/single_file/floats.cc.noopt.expected index 64b2e258..bdbd8ffb 100644 --- a/test/single_file/floats.cc.noopt.expected +++ b/test/single_file/floats.cc.noopt.expected @@ -43,12 +43,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 *= arg2 @@ -60,17 +65,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -88,7 +88,7 @@ static float& __dredd_replace_binary_operator_SubAssign_arg1_float_arg2_double(f static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -106,14 +106,14 @@ static double& __dredd_replace_binary_operator_AddAssign_arg1_double_arg2_double static double __dredd_replace_expr_double_lvalue(double& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/initializer.c.expected b/test/single_file/initializer.c.expected index 5d344570..340993aa 100644 --- a/test/single_file/initializer.c.expected +++ b/test/single_file/initializer.c.expected @@ -41,33 +41,33 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/initializer.c.noopt.expected b/test/single_file/initializer.c.noopt.expected index 5d344570..340993aa 100644 --- a/test/single_file/initializer.c.noopt.expected +++ b/test/single_file/initializer.c.noopt.expected @@ -41,33 +41,33 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/initializer.cc.expected b/test/single_file/initializer.cc.expected index f97a1450..6b47adb1 100644 --- a/test/single_file/initializer.cc.expected +++ b/test/single_file/initializer.cc.expected @@ -43,33 +43,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/initializer.cc.noopt.expected b/test/single_file/initializer.cc.noopt.expected index f97a1450..6b47adb1 100644 --- a/test/single_file/initializer.cc.noopt.expected +++ b/test/single_file/initializer.cc.noopt.expected @@ -43,33 +43,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/initializer_list.cc.noopt.expected b/test/single_file/initializer_list.cc.noopt.expected index eacdc64a..ee68897b 100644 --- a/test/single_file/initializer_list.cc.noopt.expected +++ b/test/single_file/initializer_list.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/lambda_capture.cc.expected b/test/single_file/lambda_capture.cc.expected index c3132b4b..c531a98e 100644 --- a/test/single_file/lambda_capture.cc.expected +++ b/test/single_file/lambda_capture.cc.expected @@ -43,17 +43,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -62,9 +62,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/lambda_capture.cc.noopt.expected b/test/single_file/lambda_capture.cc.noopt.expected index 229afef7..005fafc2 100644 --- a/test/single_file/lambda_capture.cc.noopt.expected +++ b/test/single_file/lambda_capture.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/left_shift_opt.c.expected b/test/single_file/left_shift_opt.c.expected index 6d420db3..dd8fa6a0 100644 --- a/test/single_file/left_shift_opt.c.expected +++ b/test/single_file/left_shift_opt.c.expected @@ -41,10 +41,10 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -55,7 +55,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/left_shift_opt.c.noopt.expected b/test/single_file/left_shift_opt.c.noopt.expected index 44c2e691..3bcf0b8d 100644 --- a/test/single_file/left_shift_opt.c.noopt.expected +++ b/test/single_file/left_shift_opt.c.noopt.expected @@ -41,21 +41,21 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_BINARY_Shr(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >> arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/left_shift_opt.cc.expected b/test/single_file/left_shift_opt.cc.expected index adfef668..f37d7130 100644 --- a/test/single_file/left_shift_opt.cc.expected +++ b/test/single_file/left_shift_opt.cc.expected @@ -43,10 +43,10 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -57,7 +57,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/left_shift_opt.cc.noopt.expected b/test/single_file/left_shift_opt.cc.noopt.expected index 10eb2997..993b3913 100644 --- a/test/single_file/left_shift_opt.cc.noopt.expected +++ b/test/single_file/left_shift_opt.cc.noopt.expected @@ -43,21 +43,21 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_BINARY_Shr(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >> arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/logical_and.c.expected b/test/single_file/logical_and.c.expected index 3506dfdd..4a01108a 100644 --- a/test/single_file/logical_and.c.expected +++ b/test/single_file/logical_and.c.expected @@ -41,27 +41,27 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/logical_and.c.noopt.expected b/test/single_file/logical_and.c.noopt.expected index 3506dfdd..4a01108a 100644 --- a/test/single_file/logical_and.c.noopt.expected +++ b/test/single_file/logical_and.c.noopt.expected @@ -41,27 +41,27 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/logical_and.cc.expected b/test/single_file/logical_and.cc.expected index e45ad4f6..ee820ea3 100644 --- a/test/single_file/logical_and.cc.expected +++ b/test/single_file/logical_and.cc.expected @@ -44,31 +44,31 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -84,7 +84,7 @@ static bool __dredd_replace_expr_bool_before_logical_operator_argument(bool arg, static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/logical_and.cc.noopt.expected b/test/single_file/logical_and.cc.noopt.expected index 348fc047..0b8cd2ad 100644 --- a/test/single_file/logical_and.cc.noopt.expected +++ b/test/single_file/logical_and.cc.noopt.expected @@ -44,33 +44,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() #define REPLACE_BINARY_LOr_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 || arg2() #define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -79,7 +79,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/logical_and_div.cc.expected b/test/single_file/logical_and_div.cc.expected index 34acc031..037f3526 100644 --- a/test/single_file/logical_and_div.cc.expected +++ b/test/single_file/logical_and_div.cc.expected @@ -44,10 +44,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 @@ -58,11 +63,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -73,16 +73,16 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/logical_and_div.cc.noopt.expected b/test/single_file/logical_and_div.cc.noopt.expected index 0e836e53..a515d7e1 100644 --- a/test/single_file/logical_and_div.cc.noopt.expected +++ b/test/single_file/logical_and_div.cc.noopt.expected @@ -44,10 +44,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() @@ -63,24 +68,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -100,7 +100,7 @@ static int __dredd_replace_binary_operator_Div_arg1_int_arg2_int(int arg1, int a static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/logical_or.c.expected b/test/single_file/logical_or.c.expected index 8ce8b205..86c30a8d 100644 --- a/test/single_file/logical_or.c.expected +++ b/test/single_file/logical_or.c.expected @@ -41,27 +41,27 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/logical_or.c.noopt.expected b/test/single_file/logical_or.c.noopt.expected index 8ce8b205..86c30a8d 100644 --- a/test/single_file/logical_or.c.noopt.expected +++ b/test/single_file/logical_or.c.noopt.expected @@ -41,27 +41,27 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/logical_or.cc.expected b/test/single_file/logical_or.cc.expected index dfdd1038..2790f5b2 100644 --- a/test/single_file/logical_or.cc.expected +++ b/test/single_file/logical_or.cc.expected @@ -44,31 +44,31 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -84,7 +84,7 @@ static bool __dredd_replace_expr_bool_before_logical_operator_argument(bool arg, static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/logical_or.cc.noopt.expected b/test/single_file/logical_or.cc.noopt.expected index b2d6e7a1..12211e58 100644 --- a/test/single_file/logical_or.cc.noopt.expected +++ b/test/single_file/logical_or.cc.noopt.expected @@ -44,33 +44,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_NE_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 != arg2() #define REPLACE_BINARY_LAnd_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 && arg2() #define REPLACE_BINARY_EQ_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 == arg2() #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -79,7 +79,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/misc002.cc.expected b/test/single_file/misc002.cc.expected index 5762f19c..f6909095 100644 --- a/test/single_file/misc002.cc.expected +++ b/test/single_file/misc002.cc.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_BINARY_LE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 <= arg2 #define REPLACE_BINARY_GE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >= arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/misc002.cc.noopt.expected b/test/single_file/misc002.cc.noopt.expected index 0ad498f3..fa486984 100644 --- a/test/single_file/misc002.cc.noopt.expected +++ b/test/single_file/misc002.cc.noopt.expected @@ -44,6 +44,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -55,15 +58,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_GE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 >= arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -72,7 +72,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/negative_switch_case.c.noopt.expected b/test/single_file/negative_switch_case.c.noopt.expected index 662fb412..1169e40b 100644 --- a/test/single_file/negative_switch_case.c.noopt.expected +++ b/test/single_file/negative_switch_case.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/negative_switch_case.cc.noopt.expected b/test/single_file/negative_switch_case.cc.noopt.expected index bba34ca5..9065505e 100644 --- a/test/single_file/negative_switch_case.cc.noopt.expected +++ b/test/single_file/negative_switch_case.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/non_const_sized_array.c.expected b/test/single_file/non_const_sized_array.c.expected index a9c75c92..645affce 100644 --- a/test/single_file/non_const_sized_array.c.expected +++ b/test/single_file/non_const_sized_array.c.expected @@ -41,32 +41,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_volatile_int_lvalue(volatile int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -75,9 +75,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/non_const_sized_array.c.noopt.expected b/test/single_file/non_const_sized_array.c.noopt.expected index efcb7158..81ca97ca 100644 --- a/test/single_file/non_const_sized_array.c.noopt.expected +++ b/test/single_file/non_const_sized_array.c.noopt.expected @@ -41,33 +41,33 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_volatile_int_lvalue(volatile int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/non_const_sized_array.cc.expected b/test/single_file/non_const_sized_array.cc.expected index 67bd128a..3cf08ea6 100644 --- a/test/single_file/non_const_sized_array.cc.expected +++ b/test/single_file/non_const_sized_array.cc.expected @@ -43,16 +43,16 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/non_const_sized_array.cc.noopt.expected b/test/single_file/non_const_sized_array.cc.noopt.expected index 971b1a29..4113cb11 100644 --- a/test/single_file/non_const_sized_array.cc.noopt.expected +++ b/test/single_file/non_const_sized_array.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/parens.cc.expected b/test/single_file/parens.cc.expected index 04c03fbe..6d06839c 100644 --- a/test/single_file/parens.cc.expected +++ b/test/single_file/parens.cc.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/parens.cc.noopt.expected b/test/single_file/parens.cc.noopt.expected index 5b5c5ef0..95ae9712 100644 --- a/test/single_file/parens.cc.noopt.expected +++ b/test/single_file/parens.cc.noopt.expected @@ -43,27 +43,27 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/positive_int_as_minus_one.c.expected b/test/single_file/positive_int_as_minus_one.c.expected index 3a4e476d..b4c56999 100644 --- a/test/single_file/positive_int_as_minus_one.c.expected +++ b/test/single_file/positive_int_as_minus_one.c.expected @@ -41,31 +41,31 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_ONE(2); return MUTATION_RETURN(arg); @@ -73,8 +73,8 @@ static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg, static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -93,9 +93,9 @@ static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_u static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/positive_int_as_minus_one.c.noopt.expected b/test/single_file/positive_int_as_minus_one.c.noopt.expected index 252e36e4..522c60f4 100644 --- a/test/single_file/positive_int_as_minus_one.c.noopt.expected +++ b/test/single_file/positive_int_as_minus_one.c.noopt.expected @@ -41,32 +41,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -85,9 +85,9 @@ static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_u static long __dredd_replace_expr_long(long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -96,9 +96,9 @@ static long __dredd_replace_expr_long(long arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/positive_int_as_minus_one.cc.expected b/test/single_file/positive_int_as_minus_one.cc.expected index 61ab9a91..a1eb3038 100644 --- a/test/single_file/positive_int_as_minus_one.cc.expected +++ b/test/single_file/positive_int_as_minus_one.cc.expected @@ -43,31 +43,31 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_ONE(2); return MUTATION_RETURN(arg); @@ -75,8 +75,8 @@ static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg, static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -95,9 +95,9 @@ static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_u static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/positive_int_as_minus_one.cc.noopt.expected b/test/single_file/positive_int_as_minus_one.cc.noopt.expected index 34ae31de..9aefee6c 100644 --- a/test/single_file/positive_int_as_minus_one.cc.noopt.expected +++ b/test/single_file/positive_int_as_minus_one.cc.noopt.expected @@ -43,32 +43,32 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_Add(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 + arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_lvalue(unsigned int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -87,9 +87,9 @@ static unsigned int __dredd_replace_binary_operator_Sub_arg1_unsigned_int_arg2_u static long __dredd_replace_expr_long(long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -98,9 +98,9 @@ static long __dredd_replace_expr_long(long arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/post_inc_volatile.c.expected b/test/single_file/post_inc_volatile.c.expected index 0025e086..d0947af0 100644 --- a/test/single_file/post_inc_volatile.c.expected +++ b/test/single_file/post_inc_volatile.c.expected @@ -41,57 +41,57 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg -#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- -#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) -#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) -#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) -#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_UNARY_PostDec_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_Minus_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_ARG_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PostInc_volatile_int(volatile int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)++); - REPLACE_UNARY_PostDec_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PostDec_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN((*arg)++); } static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -100,9 +100,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -111,16 +111,16 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/post_inc_volatile.c.noopt.expected b/test/single_file/post_inc_volatile.c.noopt.expected index acf52d48..885af8a7 100644 --- a/test/single_file/post_inc_volatile.c.noopt.expected +++ b/test/single_file/post_inc_volatile.c.noopt.expected @@ -41,58 +41,58 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg -#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- -#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) -#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) -#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) -#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_UNARY_PostDec_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_Minus_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_ARG_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PostInc_volatile_int(volatile int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)++); - REPLACE_UNARY_PostDec_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PostDec_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN((*arg)++); } static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -101,16 +101,16 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/post_inc_volatile.cc.expected b/test/single_file/post_inc_volatile.cc.expected index f3bb9be7..f5549faf 100644 --- a/test/single_file/post_inc_volatile.cc.expected +++ b/test/single_file/post_inc_volatile.cc.expected @@ -48,9 +48,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() #define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() #define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() #define REPLACE_BINARY_Sub_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() - arg2() #define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() @@ -67,14 +75,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG1_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() -#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2()); @@ -103,15 +103,15 @@ static int __dredd_replace_unary_operator_PostInc_volatile_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -131,9 +131,9 @@ static int __dredd_replace_expr_int(std::function arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/post_inc_volatile.cc.noopt.expected b/test/single_file/post_inc_volatile.cc.noopt.expected index 63e81845..9eefa26f 100644 --- a/test/single_file/post_inc_volatile.cc.noopt.expected +++ b/test/single_file/post_inc_volatile.cc.noopt.expected @@ -48,9 +48,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() #define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() #define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_XorAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^= arg2() #define REPLACE_BINARY_Sub_LHS_EVALUATED_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() - arg2() #define REPLACE_BINARY_SubAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -= arg2() @@ -67,14 +75,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() #define REPLACE_BINARY_ARG2_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2() #define REPLACE_BINARY_ARG1_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() -#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2()); @@ -103,16 +103,16 @@ static int __dredd_replace_unary_operator_PostInc_volatile_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -121,9 +121,9 @@ static int __dredd_replace_expr_int(std::function arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/pre_dec_assign.cc.expected b/test/single_file/pre_dec_assign.cc.expected index 1cd74ce6..dc972ba2 100644 --- a/test/single_file/pre_dec_assign.cc.expected +++ b/test/single_file/pre_dec_assign.cc.expected @@ -45,9 +45,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++arg() #define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_XorAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() ^= arg2 #define REPLACE_BINARY_SubAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() -= arg2 #define REPLACE_BINARY_ShrAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() >>= arg2 @@ -58,11 +63,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() /= arg2 #define REPLACE_BINARY_AndAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() &= arg2 #define REPLACE_BINARY_AddAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_unary_operator_PreDec_volatile_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(--arg()); @@ -110,15 +110,15 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(std::functi static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -127,9 +127,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/pre_dec_assign.cc.noopt.expected b/test/single_file/pre_dec_assign.cc.noopt.expected index cee3dab7..9739d9cc 100644 --- a/test/single_file/pre_dec_assign.cc.noopt.expected +++ b/test/single_file/pre_dec_assign.cc.noopt.expected @@ -45,9 +45,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++arg() #define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_XorAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() ^= arg2 #define REPLACE_BINARY_SubAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() -= arg2 #define REPLACE_BINARY_ShrAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() >>= arg2 @@ -58,11 +63,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() /= arg2 #define REPLACE_BINARY_AndAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() &= arg2 #define REPLACE_BINARY_AddAssign_LHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1() += arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_unary_operator_PreDec_volatile_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(--arg()); @@ -110,16 +110,16 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(std::functi static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/preprocessor_if.c.expected b/test/single_file/preprocessor_if.c.expected index 17a17937..074eac30 100644 --- a/test/single_file/preprocessor_if.c.expected +++ b/test/single_file/preprocessor_if.c.expected @@ -41,30 +41,30 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 #define REPLACE_BINARY_Xor(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^ arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 #define REPLACE_BINARY_And(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 & arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -82,16 +82,16 @@ static int __dredd_replace_binary_operator_Or_arg1_int_arg2_int(int arg1, int ar static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/preprocessor_if.c.noopt.expected b/test/single_file/preprocessor_if.c.noopt.expected index 7dc85fa0..30d98c1e 100644 --- a/test/single_file/preprocessor_if.c.noopt.expected +++ b/test/single_file/preprocessor_if.c.noopt.expected @@ -41,32 +41,32 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 #define REPLACE_BINARY_Xor(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 ^ arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 #define REPLACE_BINARY_And(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 & arg2 -#define REPLACE_BINARY_AddAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 +#define REPLACE_BINARY_AddAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) += arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -84,16 +84,16 @@ static int __dredd_replace_binary_operator_Or_arg1_int_arg2_int(int arg1, int ar static int __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) = arg2); - REPLACE_BINARY_AddAssign(0); - REPLACE_BINARY_AndAssign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AddAssign_LHS_POINTER(0); + REPLACE_BINARY_AndAssign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) = arg2); } diff --git a/test/single_file/printing.c.noopt.expected b/test/single_file/printing.c.noopt.expected index 34a59e41..9af0434a 100644 --- a/test/single_file/printing.c.noopt.expected +++ b/test/single_file/printing.c.noopt.expected @@ -41,18 +41,18 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/signed_int_constants.cc.expected b/test/single_file/signed_int_constants.cc.expected index b53eb8d0..88d7f0ff 100644 --- a/test/single_file/signed_int_constants.cc.expected +++ b/test/single_file/signed_int_constants.cc.expected @@ -43,14 +43,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -61,7 +61,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -76,15 +76,15 @@ static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -93,9 +93,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/signed_int_constants.cc.noopt.expected b/test/single_file/signed_int_constants.cc.noopt.expected index 3953b5ca..490ecd87 100644 --- a/test/single_file/signed_int_constants.cc.noopt.expected +++ b/test/single_file/signed_int_constants.cc.noopt.expected @@ -46,14 +46,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -65,16 +65,16 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/sizeof_template.cc.expected b/test/single_file/sizeof_template.cc.expected index edc21eed..277624f0 100644 --- a/test/single_file/sizeof_template.cc.expected +++ b/test/single_file/sizeof_template.cc.expected @@ -43,15 +43,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long(unsigned long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); diff --git a/test/single_file/sizeof_template.cc.noopt.expected b/test/single_file/sizeof_template.cc.noopt.expected index edc21eed..277624f0 100644 --- a/test/single_file/sizeof_template.cc.noopt.expected +++ b/test/single_file/sizeof_template.cc.noopt.expected @@ -43,15 +43,15 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long(unsigned long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); diff --git a/test/single_file/sizeof_template2.cc.expected b/test/single_file/sizeof_template2.cc.expected index c4bcf147..5bd61e22 100644 --- a/test/single_file/sizeof_template2.cc.expected +++ b/test/single_file/sizeof_template2.cc.expected @@ -44,20 +44,20 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -66,7 +66,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_LNOT_EVALUATED(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg()); diff --git a/test/single_file/sizeof_template2.cc.noopt.expected b/test/single_file/sizeof_template2.cc.noopt.expected index 7ffb522f..89022bfb 100644 --- a/test/single_file/sizeof_template2.cc.noopt.expected +++ b/test/single_file/sizeof_template2.cc.noopt.expected @@ -44,19 +44,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned long __dredd_replace_expr_unsigned_long(unsigned long arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -64,9 +64,9 @@ static unsigned long __dredd_replace_expr_unsigned_long(unsigned long arg, int l static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -75,7 +75,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_LNOT_EVALUATED(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg()); diff --git a/test/single_file/static_initializer.cc.expected b/test/single_file/static_initializer.cc.expected index f17a96d5..a7d4e823 100644 --- a/test/single_file/static_initializer.cc.expected +++ b/test/single_file/static_initializer.cc.expected @@ -43,20 +43,20 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); @@ -67,16 +67,16 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/static_initializer.cc.noopt.expected b/test/single_file/static_initializer.cc.noopt.expected index 99477c94..40b17f80 100644 --- a/test/single_file/static_initializer.cc.noopt.expected +++ b/test/single_file/static_initializer.cc.noopt.expected @@ -43,33 +43,33 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define REPLACE_BINARY_Sub(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 - arg2 #define REPLACE_BINARY_Rem(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 % arg2 #define REPLACE_BINARY_Mul(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 * arg2 #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/structured_binding.cc.expected b/test/single_file/structured_binding.cc.expected index 70963373..40c032ae 100644 --- a/test/single_file/structured_binding.cc.expected +++ b/test/single_file/structured_binding.cc.expected @@ -48,6 +48,11 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg() #define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() #define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -62,11 +67,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() #define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() #define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() -#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2()); @@ -95,7 +95,7 @@ static int __dredd_replace_unary_operator_PostInc_int(std::function arg, static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -103,8 +103,8 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -113,9 +113,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/structured_binding.cc.noopt.expected b/test/single_file/structured_binding.cc.noopt.expected index 56e6a343..405cceb0 100644 --- a/test/single_file/structured_binding.cc.noopt.expected +++ b/test/single_file/structured_binding.cc.noopt.expected @@ -49,6 +49,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() #define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -63,12 +69,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() #define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() #define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() -#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2()); @@ -97,9 +97,9 @@ static int __dredd_replace_unary_operator_PostInc_int(std::function arg, static int __dredd_replace_expr_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -108,9 +108,9 @@ static int __dredd_replace_expr_int(std::function arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -119,7 +119,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/template.cc.expected b/test/single_file/template.cc.expected index 15307c41..b0f258cf 100644 --- a/test/single_file/template.cc.expected +++ b/test/single_file/template.cc.expected @@ -43,6 +43,11 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -56,11 +61,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() #define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() #define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() -#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2()); @@ -79,8 +79,8 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -89,9 +89,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/template.cc.noopt.expected b/test/single_file/template.cc.noopt.expected index f9d7309e..19561ac9 100644 --- a/test/single_file/template.cc.noopt.expected +++ b/test/single_file/template.cc.noopt.expected @@ -43,6 +43,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -56,12 +62,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2() #define REPLACE_BINARY_AndAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2() #define REPLACE_BINARY_AddAssign_RHS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 += arg2() -#define MUTATION_EXPR_NOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg()) -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg()) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg()) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, std::function arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 = arg2()); @@ -80,9 +80,9 @@ static int& __dredd_replace_binary_operator_Assign_arg1_int_arg2_int(int& arg1, static int __dredd_replace_expr_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -91,9 +91,9 @@ static int __dredd_replace_expr_int(std::function arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/template_instantiation.cc.noopt.expected b/test/single_file/template_instantiation.cc.noopt.expected index 7a73b4ac..4a19d9d8 100644 --- a/test/single_file/template_instantiation.cc.noopt.expected +++ b/test/single_file/template_instantiation.cc.noopt.expected @@ -43,18 +43,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/typedef.c.noopt.expected b/test/single_file/typedef.c.noopt.expected index e8625102..7b266716 100644 --- a/test/single_file/typedef.c.noopt.expected +++ b/test/single_file/typedef.c.noopt.expected @@ -41,6 +41,9 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -50,15 +53,12 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/typedef.cc.noopt.expected b/test/single_file/typedef.cc.noopt.expected index 375d8243..f9346f8b 100644 --- a/test/single_file/typedef.cc.noopt.expected +++ b/test/single_file/typedef.cc.noopt.expected @@ -43,6 +43,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -52,15 +55,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/unary.c.expected b/test/single_file/unary.c.expected index 48be7907..0bb82724 100644 --- a/test/single_file/unary.c.expected +++ b/test/single_file/unary.c.expected @@ -41,65 +41,65 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg -#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(*arg) -#define REPLACE_UNARY_PreDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(*arg) -#define REPLACE_UNARY_PostInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)++ -#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- -#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_PreInc_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(*arg) +#define REPLACE_UNARY_PreDec_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(*arg) +#define REPLACE_UNARY_PostInc_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)++ +#define REPLACE_UNARY_PostDec_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg -#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) -#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_Minus_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg -#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_UNARY_ARG_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PreInc_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE(++(*arg)); - REPLACE_UNARY_PreDec_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PreDec_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN(++(*arg)); } static int __dredd_replace_unary_operator_PreDec_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE(--(*arg)); - REPLACE_UNARY_PreInc_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PreInc_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN(--(*arg)); } static int __dredd_replace_unary_operator_PostInc_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)++); - REPLACE_UNARY_PostDec_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PostDec_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN((*arg)++); } static int __dredd_replace_unary_operator_PostDec_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)--); - REPLACE_UNARY_PostInc_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PostInc_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN((*arg)--); } @@ -112,15 +112,15 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -129,9 +129,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -140,43 +140,43 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static float __dredd_replace_unary_operator_PreInc_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE(++(*arg)); - REPLACE_UNARY_PreDec_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PreDec_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN(++(*arg)); } static float __dredd_replace_unary_operator_PreDec_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE(--(*arg)); - REPLACE_UNARY_PreInc_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PreInc_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN(--(*arg)); } static float __dredd_replace_unary_operator_PostInc_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)++); - REPLACE_UNARY_PostDec_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PostDec_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN((*arg)++); } static float __dredd_replace_unary_operator_PostDec_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)--); - REPLACE_UNARY_PostInc_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PostInc_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN((*arg)--); } static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/unary.c.noopt.expected b/test/single_file/unary.c.noopt.expected index 02ceab85..5a0d30fe 100644 --- a/test/single_file/unary.c.noopt.expected +++ b/test/single_file/unary.c.noopt.expected @@ -41,66 +41,66 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg -#define REPLACE_UNARY_PreInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(*arg) -#define REPLACE_UNARY_PreDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(*arg) -#define REPLACE_UNARY_PostInc_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)++ -#define REPLACE_UNARY_PostDec_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- -#define REPLACE_UNARY_Not_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) +#define REPLACE_UNARY_PreInc_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(*arg) +#define REPLACE_UNARY_PreDec_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(*arg) +#define REPLACE_UNARY_PostInc_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)++ +#define REPLACE_UNARY_PostDec_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg)-- +#define REPLACE_UNARY_Not_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(*arg) #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg -#define REPLACE_UNARY_Minus_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) -#define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) +#define REPLACE_UNARY_Minus_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(*arg) +#define REPLACE_UNARY_LNot_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(*arg) #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg -#define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) +#define REPLACE_UNARY_ARG_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg) #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_PreInc_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE(++(*arg)); - REPLACE_UNARY_PreDec_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PreDec_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN(++(*arg)); } static int __dredd_replace_unary_operator_PreDec_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE(--(*arg)); - REPLACE_UNARY_PreInc_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PreInc_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN(--(*arg)); } static int __dredd_replace_unary_operator_PostInc_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)++); - REPLACE_UNARY_PostDec_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PostDec_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN((*arg)++); } static int __dredd_replace_unary_operator_PostDec_int(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)--); - REPLACE_UNARY_PostInc_EVALUATED(0); - REPLACE_UNARY_Not_EVALUATED(1); - REPLACE_UNARY_Minus_EVALUATED(2); - REPLACE_UNARY_LNot_EVALUATED(3); - REPLACE_UNARY_ARG_EVALUATED(4); + REPLACE_UNARY_PostInc_POINTER(0); + REPLACE_UNARY_Not_POINTER(1); + REPLACE_UNARY_Minus_POINTER(2); + REPLACE_UNARY_LNot_POINTER(3); + REPLACE_UNARY_ARG_POINTER(4); return MUTATION_RETURN((*arg)--); } @@ -114,16 +114,16 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -132,43 +132,43 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static float __dredd_replace_unary_operator_PreInc_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE(++(*arg)); - REPLACE_UNARY_PreDec_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PreDec_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN(++(*arg)); } static float __dredd_replace_unary_operator_PreDec_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE(--(*arg)); - REPLACE_UNARY_PreInc_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PreInc_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN(--(*arg)); } static float __dredd_replace_unary_operator_PostInc_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)++); - REPLACE_UNARY_PostDec_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PostDec_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN((*arg)++); } static float __dredd_replace_unary_operator_PostDec_float(float* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)--); - REPLACE_UNARY_PostInc_EVALUATED(0); - REPLACE_UNARY_Minus_EVALUATED(1); - REPLACE_UNARY_LNot_EVALUATED(2); - REPLACE_UNARY_ARG_EVALUATED(3); + REPLACE_UNARY_PostInc_POINTER(0); + REPLACE_UNARY_Minus_POINTER(1); + REPLACE_UNARY_LNot_POINTER(2); + REPLACE_UNARY_ARG_POINTER(3); return MUTATION_RETURN((*arg)--); } static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -177,7 +177,7 @@ static float __dredd_replace_expr_float(float arg, int local_mutation_id) { static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/unary.cc.expected b/test/single_file/unary.cc.expected index 9e365d6b..4a3f91b8 100644 --- a/test/single_file/unary.cc.expected +++ b/test/single_file/unary.cc.expected @@ -53,17 +53,17 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_LNot_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg() #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG_EVALUATED(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg() +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) #define REPLACE_EXPR_FLOAT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0.0 #define REPLACE_EXPR_FLOAT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1.0 #define REPLACE_EXPR_FLOAT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1.0 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int& __dredd_replace_unary_operator_PreInc_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(++arg()); @@ -108,15 +108,15 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -125,9 +125,9 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -168,7 +168,7 @@ static float __dredd_replace_unary_operator_PostDec_float(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(++arg()); @@ -113,16 +113,16 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_LNOT_EVALUATED(0); - MUTATION_EXPR_NOT_EVALUATED(1); - MUTATION_EXPR_MINUS_EVALUATED(2); + REPLACE_EXPR_LNOT_EVALUATED(0); + REPLACE_EXPR_NOT_EVALUATED(1); + REPLACE_EXPR_MINUS_EVALUATED(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -131,9 +131,9 @@ static int __dredd_replace_expr_int(std::function arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -174,7 +174,7 @@ static float __dredd_replace_unary_operator_PostDec_float(std::function arg, int local_mutation_id) { MUTATION_PRELUDE(arg()); - MUTATION_EXPR_MINUS_EVALUATED(0); + REPLACE_EXPR_MINUS_EVALUATED(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -183,7 +183,7 @@ static float __dredd_replace_expr_float(std::function arg, int local_mu static float __dredd_replace_expr_float(float arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); @@ -192,7 +192,7 @@ static float __dredd_replace_expr_float(float arg, int local_mutation_id) { static double __dredd_replace_expr_double(double arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_MINUS(0); + REPLACE_EXPR_MINUS(0); REPLACE_EXPR_FLOAT_ZERO(1); REPLACE_EXPR_FLOAT_ONE(2); REPLACE_EXPR_FLOAT_MINUS_ONE(3); diff --git a/test/single_file/unary_logical_not.c.expected b/test/single_file/unary_logical_not.c.expected index 3b361a79..2971ab82 100644 --- a/test/single_file/unary_logical_not.c.expected +++ b/test/single_file/unary_logical_not.c.expected @@ -44,13 +44,13 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_LNot_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(!arg); @@ -61,9 +61,9 @@ static int __dredd_replace_unary_operator_LNot_bool(bool arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -78,7 +78,7 @@ static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/unary_logical_not.c.noopt.expected b/test/single_file/unary_logical_not.c.noopt.expected index d45758ba..9e5e4cc1 100644 --- a/test/single_file/unary_logical_not.c.noopt.expected +++ b/test/single_file/unary_logical_not.c.noopt.expected @@ -45,13 +45,13 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_LNot_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(!arg); @@ -63,9 +63,9 @@ static int __dredd_replace_unary_operator_LNot_bool(bool arg, int local_mutation static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -74,7 +74,7 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/unary_logical_not.cc.expected b/test/single_file/unary_logical_not.cc.expected index b81522a3..f8d2be1c 100644 --- a/test/single_file/unary_logical_not.cc.expected +++ b/test/single_file/unary_logical_not.cc.expected @@ -46,19 +46,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -80,7 +80,7 @@ static bool __dredd_replace_expr_bool_true(bool arg, int local_mutation_id) { static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/unary_logical_not.cc.noopt.expected b/test/single_file/unary_logical_not.cc.noopt.expected index 590bf514..62d826ca 100644 --- a/test/single_file/unary_logical_not.cc.noopt.expected +++ b/test/single_file/unary_logical_not.cc.noopt.expected @@ -47,19 +47,19 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -76,7 +76,7 @@ static bool __dredd_replace_unary_operator_LNot_bool(bool arg, int local_mutatio static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/unary_minus.c.expected b/test/single_file/unary_minus.c.expected index 11f16b4b..96931b1c 100644 --- a/test/single_file/unary_minus.c.expected +++ b/test/single_file/unary_minus.c.expected @@ -43,14 +43,14 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -61,7 +61,7 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -69,16 +69,16 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/unary_minus.c.noopt.expected b/test/single_file/unary_minus.c.noopt.expected index 19391688..f2259afd 100644 --- a/test/single_file/unary_minus.c.noopt.expected +++ b/test/single_file/unary_minus.c.noopt.expected @@ -44,14 +44,14 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) +#define REPLACE_EXPR_INC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++((*arg)) +#define REPLACE_EXPR_DEC_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --((*arg)) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -63,16 +63,16 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_lvalue(int* arg, int local_mutation_id) { MUTATION_PRELUDE((*arg)); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC_POINTER(0); + REPLACE_EXPR_DEC_POINTER(1); return MUTATION_RETURN((*arg)); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/unary_minus.cc.expected b/test/single_file/unary_minus.cc.expected index 0323d6a7..a7470fb9 100644 --- a/test/single_file/unary_minus.cc.expected +++ b/test/single_file/unary_minus.cc.expected @@ -45,14 +45,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -63,7 +63,7 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -71,16 +71,16 @@ static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/unary_minus.cc.noopt.expected b/test/single_file/unary_minus.cc.noopt.expected index b6eff464..b89541e4 100644 --- a/test/single_file/unary_minus.cc.noopt.expected +++ b/test/single_file/unary_minus.cc.noopt.expected @@ -46,14 +46,14 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) -#define MUTATION_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) -#define MUTATION_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) +#define REPLACE_EXPR_INC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ++(arg) +#define REPLACE_EXPR_DEC(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return --(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(-arg); @@ -65,16 +65,16 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int_lvalue(int& arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_INC(0); - MUTATION_EXPR_DEC(1); + REPLACE_EXPR_INC(0); + REPLACE_EXPR_DEC(1); return MUTATION_RETURN(arg); } static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/unary_operator_opt.c.expected b/test/single_file/unary_operator_opt.c.expected index e095c80f..e919ecf2 100644 --- a/test/single_file/unary_operator_opt.c.expected +++ b/test/single_file/unary_operator_opt.c.expected @@ -42,11 +42,11 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define MUTATION_RETURN(arg) arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Not_int_minus_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(~arg); @@ -63,7 +63,7 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_one(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_MINUS_ONE(2); return MUTATION_RETURN(arg); @@ -78,8 +78,8 @@ static int __dredd_replace_expr_int_minus_one(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/unary_operator_opt.c.noopt.expected b/test/single_file/unary_operator_opt.c.noopt.expected index 768d846c..0e98d461 100644 --- a/test/single_file/unary_operator_opt.c.noopt.expected +++ b/test/single_file/unary_operator_opt.c.noopt.expected @@ -45,12 +45,12 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_unary_operator_Not_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(~arg); @@ -70,9 +70,9 @@ static int __dredd_replace_unary_operator_Minus_int(int arg, int local_mutation_ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/unsigned_int.c.expected b/test/single_file/unsigned_int.c.expected index 89889fb8..316e40a5 100644 --- a/test/single_file/unsigned_int.c.expected +++ b/test/single_file/unsigned_int.c.expected @@ -44,22 +44,22 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Not(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~arg #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_one(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_ONE(2); return MUTATION_RETURN(arg); @@ -87,8 +87,8 @@ static int __dredd_replace_expr_int_zero(int arg, int local_mutation_id) { static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/unsigned_int.c.noopt.expected b/test/single_file/unsigned_int.c.noopt.expected index fb14ca33..c19b4d3c 100644 --- a/test/single_file/unsigned_int.c.noopt.expected +++ b/test/single_file/unsigned_int.c.noopt.expected @@ -45,17 +45,17 @@ static int __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -79,9 +79,9 @@ static int __dredd_replace_unary_operator_LNot_int(int arg, int local_mutation_i static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/unsigned_int.cc.expected b/test/single_file/unsigned_int.cc.expected index 234e54b2..455d95f3 100644 --- a/test/single_file/unsigned_int.cc.expected +++ b/test/single_file/unsigned_int.cc.expected @@ -47,22 +47,22 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_Minus(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -arg #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int_one(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); return MUTATION_RETURN(arg); } static unsigned int __dredd_replace_expr_unsigned_int_constant(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); + REPLACE_EXPR_NOT(0); REPLACE_EXPR_INT_ZERO(1); REPLACE_EXPR_INT_ONE(2); return MUTATION_RETURN(arg); @@ -77,8 +77,8 @@ static int __dredd_replace_unary_operator_Not_int(int arg, int local_mutation_id static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/unsigned_int.cc.noopt.expected b/test/single_file/unsigned_int.cc.noopt.expected index d56967a7..b8b305f2 100644 --- a/test/single_file/unsigned_int.cc.noopt.expected +++ b/test/single_file/unsigned_int.cc.noopt.expected @@ -48,18 +48,18 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_UNARY_LNot(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !arg #define REPLACE_UNARY_ARG(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg #define REPLACE_EXPR_TRUE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return true +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 #define REPLACE_EXPR_FALSE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return false -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static unsigned int __dredd_replace_expr_unsigned_int(unsigned int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); return MUTATION_RETURN(arg); @@ -75,9 +75,9 @@ static int __dredd_replace_unary_operator_Not_int(int arg, int local_mutation_id static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -94,7 +94,7 @@ static bool __dredd_replace_unary_operator_LNot_bool(bool arg, int local_mutatio static bool __dredd_replace_expr_bool(bool arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); + REPLACE_EXPR_LNOT(0); REPLACE_EXPR_TRUE(1); REPLACE_EXPR_FALSE(2); return MUTATION_RETURN(arg); diff --git a/test/single_file/using.cc.noopt.expected b/test/single_file/using.cc.noopt.expected index 56b31823..db222738 100644 --- a/test/single_file/using.cc.noopt.expected +++ b/test/single_file/using.cc.noopt.expected @@ -43,6 +43,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -52,15 +55,12 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_Div(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 / arg2 #define REPLACE_BINARY_ARG2(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg2 #define REPLACE_BINARY_ARG1(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); diff --git a/test/single_file/volatile.c.expected b/test/single_file/volatile.c.expected index 1d2e3947..a6c0f9e5 100644 --- a/test/single_file/volatile.c.expected +++ b/test/single_file/volatile.c.expected @@ -41,26 +41,26 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Assign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); @@ -69,16 +69,16 @@ static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) += arg2); - REPLACE_BINARY_AndAssign(0); - REPLACE_BINARY_Assign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AndAssign_LHS_POINTER(0); + REPLACE_BINARY_Assign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) += arg2); } diff --git a/test/single_file/volatile.c.noopt.expected b/test/single_file/volatile.c.noopt.expected index 46bb61c1..55f2ce63 100644 --- a/test/single_file/volatile.c.noopt.expected +++ b/test/single_file/volatile.c.noopt.expected @@ -41,28 +41,28 @@ static int __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 -#define REPLACE_BINARY_XorAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 -#define REPLACE_BINARY_SubAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 -#define REPLACE_BINARY_ShrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 -#define REPLACE_BINARY_ShlAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 -#define REPLACE_BINARY_RemAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 -#define REPLACE_BINARY_OrAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 -#define REPLACE_BINARY_MulAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 -#define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 -#define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 -#define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) +#define REPLACE_BINARY_XorAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) ^= arg2 +#define REPLACE_BINARY_SubAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) -= arg2 +#define REPLACE_BINARY_ShrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) >>= arg2 +#define REPLACE_BINARY_ShlAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) <<= arg2 +#define REPLACE_BINARY_RemAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) %= arg2 +#define REPLACE_BINARY_OrAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) |= arg2 +#define REPLACE_BINARY_MulAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) *= arg2 +#define REPLACE_BINARY_DivAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) /= arg2 +#define REPLACE_BINARY_Assign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) = arg2 +#define REPLACE_BINARY_AndAssign_LHS_POINTER(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return (*arg1) &= arg2 #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); @@ -71,16 +71,16 @@ static int __dredd_replace_expr_int(int arg, int local_mutation_id) { static int __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int* arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE((*arg1) += arg2); - REPLACE_BINARY_AndAssign(0); - REPLACE_BINARY_Assign(1); - REPLACE_BINARY_DivAssign(2); - REPLACE_BINARY_MulAssign(3); - REPLACE_BINARY_OrAssign(4); - REPLACE_BINARY_RemAssign(5); - REPLACE_BINARY_ShlAssign(6); - REPLACE_BINARY_ShrAssign(7); - REPLACE_BINARY_SubAssign(8); - REPLACE_BINARY_XorAssign(9); + REPLACE_BINARY_AndAssign_LHS_POINTER(0); + REPLACE_BINARY_Assign_LHS_POINTER(1); + REPLACE_BINARY_DivAssign_LHS_POINTER(2); + REPLACE_BINARY_MulAssign_LHS_POINTER(3); + REPLACE_BINARY_OrAssign_LHS_POINTER(4); + REPLACE_BINARY_RemAssign_LHS_POINTER(5); + REPLACE_BINARY_ShlAssign_LHS_POINTER(6); + REPLACE_BINARY_ShrAssign_LHS_POINTER(7); + REPLACE_BINARY_SubAssign_LHS_POINTER(8); + REPLACE_BINARY_XorAssign_LHS_POINTER(9); return MUTATION_RETURN((*arg1) += arg2); } diff --git a/test/single_file/volatile.cc.expected b/test/single_file/volatile.cc.expected index 828e3d88..25c6cffb 100644 --- a/test/single_file/volatile.cc.expected +++ b/test/single_file/volatile.cc.expected @@ -43,6 +43,8 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -56,8 +58,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 #define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 = arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 += arg2); @@ -76,8 +76,8 @@ static volatile int& __dredd_replace_binary_operator_AddAssign_arg1_volatile_int static int __dredd_replace_expr_int_constant(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_NOT(0); - MUTATION_EXPR_MINUS(1); + REPLACE_EXPR_NOT(0); + REPLACE_EXPR_MINUS(1); REPLACE_EXPR_INT_ZERO(2); REPLACE_EXPR_INT_ONE(3); REPLACE_EXPR_INT_MINUS_ONE(4); diff --git a/test/single_file/volatile.cc.noopt.expected b/test/single_file/volatile.cc.noopt.expected index 748a858d..7672da7d 100644 --- a/test/single_file/volatile.cc.noopt.expected +++ b/test/single_file/volatile.cc.noopt.expected @@ -43,6 +43,9 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { } #define MUTATION_RETURN(arg) arg +#define REPLACE_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) +#define REPLACE_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) +#define REPLACE_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define REPLACE_EXPR_INT_ZERO(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 0 #define REPLACE_EXPR_INT_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return 1 #define REPLACE_EXPR_INT_MINUS_ONE(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -1 @@ -56,9 +59,6 @@ static bool __dredd_enabled_mutation(int local_mutation_id) { #define REPLACE_BINARY_DivAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 /= arg2 #define REPLACE_BINARY_Assign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 = arg2 #define REPLACE_BINARY_AndAssign(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return arg1 &= arg2 -#define MUTATION_EXPR_NOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return ~(arg) -#define MUTATION_EXPR_MINUS(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return -(arg) -#define MUTATION_EXPR_LNOT(mutation_id_offset) if (__dredd_enabled_mutation(local_mutation_id + mutation_id_offset)) return !(arg) #define MUTATION_PRELUDE(arg) if (!__dredd_some_mutation_enabled) return arg static volatile int& __dredd_replace_binary_operator_AddAssign_arg1_volatile_int_arg2_int(volatile int& arg1, int arg2, int local_mutation_id) { MUTATION_PRELUDE(arg1 += arg2); @@ -77,9 +77,9 @@ static volatile int& __dredd_replace_binary_operator_AddAssign_arg1_volatile_int static int __dredd_replace_expr_int(int arg, int local_mutation_id) { MUTATION_PRELUDE(arg); - MUTATION_EXPR_LNOT(0); - MUTATION_EXPR_NOT(1); - MUTATION_EXPR_MINUS(2); + REPLACE_EXPR_LNOT(0); + REPLACE_EXPR_NOT(1); + REPLACE_EXPR_MINUS(2); REPLACE_EXPR_INT_ZERO(3); REPLACE_EXPR_INT_ONE(4); REPLACE_EXPR_INT_MINUS_ONE(5); From 2f852e428a90134124c2fc1cdf2ba7f096718df9 Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Thu, 23 Nov 2023 13:31:20 +0000 Subject: [PATCH 14/15] Formatting --- .../libdredd/mutation_replace_binary_operator.h | 4 +++- .../include/libdredd/mutation_replace_expr.h | 4 +++- .../libdredd/mutation_replace_unary_operator.h | 4 +++- .../src/mutation_replace_binary_operator.cc | 11 +++++++---- src/libdredd/src/mutation_replace_expr.cc | 6 ++++-- .../src/mutation_replace_unary_operator.cc | 14 +++++++++----- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h index 27169647..c5f25c9a 100644 --- a/src/libdredd/include/libdredd/mutation_replace_binary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_binary_operator.h @@ -67,7 +67,9 @@ class MutationReplaceBinaryOperator : public Mutation { static std::string OpKindToString(clang::BinaryOperatorKind kind); - [[nodiscard]] std::string GetBinaryMacroName(const std::string& operator_name, const clang::ASTContext &ast_context) const; + [[nodiscard]] std::string GetBinaryMacroName( + const std::string& operator_name, + const clang::ASTContext& ast_context) const; [[nodiscard]] bool IsRedundantReplacementOperator( clang::BinaryOperatorKind operator_kind, diff --git a/src/libdredd/include/libdredd/mutation_replace_expr.h b/src/libdredd/include/libdredd/mutation_replace_expr.h index c16cc9cf..50d69d44 100644 --- a/src/libdredd/include/libdredd/mutation_replace_expr.h +++ b/src/libdredd/include/libdredd/mutation_replace_expr.h @@ -44,7 +44,9 @@ class MutationReplaceExpr : public Mutation { std::unordered_set& dredd_declarations, std::unordered_set& dredd_macros) const override; - [[nodiscard]] std::string GetExprMacroName(const std::string& operator_name, const clang::ASTContext &ast_context) const; + [[nodiscard]] std::string GetExprMacroName( + const std::string& operator_name, + const clang::ASTContext& ast_context) const; static void ApplyCppTypeModifiers(const clang::Expr& expr, std::string& type); diff --git a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h index 9c7233cf..c2d11dbb 100644 --- a/src/libdredd/include/libdredd/mutation_replace_unary_operator.h +++ b/src/libdredd/include/libdredd/mutation_replace_unary_operator.h @@ -69,7 +69,9 @@ class MutationReplaceUnaryOperator : public Mutation { static std::string OpKindToString(clang::UnaryOperatorKind kind); - [[nodiscard]] std::string GetUnaryMacroName(const std::string& operator_name, const clang::ASTContext &ast_context) const; + [[nodiscard]] std::string GetUnaryMacroName( + const std::string& operator_name, + const clang::ASTContext& ast_context) const; // Replaces unary operators with other valid unary operators. void GenerateUnaryOperatorReplacement( diff --git a/src/libdredd/src/mutation_replace_binary_operator.cc b/src/libdredd/src/mutation_replace_binary_operator.cc index c5cadd53..20b687dd 100644 --- a/src/libdredd/src/mutation_replace_binary_operator.cc +++ b/src/libdredd/src/mutation_replace_binary_operator.cc @@ -231,7 +231,9 @@ std::string MutationReplaceBinaryOperator::GetFunctionName( return result; } -std::string MutationReplaceBinaryOperator::GetBinaryMacroName(const std::string& operator_name, const clang::ASTContext& ast_context) const { +std::string MutationReplaceBinaryOperator::GetBinaryMacroName( + const std::string& operator_name, + const clang::ASTContext& ast_context) const { std::string result = "REPLACE_BINARY_" + operator_name; if (ast_context.getLangOpts().CPlusPlus && binary_operator_->getLHS()->HasSideEffects(ast_context)) { @@ -303,8 +305,8 @@ void MutationReplaceBinaryOperator::GenerateArgumentReplacement( binary_operator_->getLHS()->HasSideEffects(ast_context)) { macro_name += "_EVALUATED"; } else if (!ast_context.getLangOpts().CPlusPlus && - binary_operator_->isAssignmentOp()) { - macro_name+= "_POINTER"; + binary_operator_->isAssignmentOp()) { + macro_name += "_POINTER"; } new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, arg1_evaluated)); @@ -358,7 +360,8 @@ void MutationReplaceBinaryOperator::GenerateBinaryOperatorReplacement( for (auto operator_kind : GetReplacementOperators(optimise_mutations, ast_context)) { if (!only_track_mutant_coverage) { - const std::string macro_name = GetBinaryMacroName(OpKindToString(operator_kind), ast_context); + const std::string macro_name = + GetBinaryMacroName(OpKindToString(operator_kind), ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro( macro_name, diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index 5df6e1df..abc54ff7 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -115,10 +115,12 @@ void MutationReplaceExpr::AddOptimisationSpecifier( } } -std::string MutationReplaceExpr::GetExprMacroName(const std::string& operator_name, const clang::ASTContext& ast_context) const { +std::string MutationReplaceExpr::GetExprMacroName( + const std::string& operator_name, + const clang::ASTContext& ast_context) const { std::string result = "REPLACE_EXPR_" + operator_name; if (ast_context.getLangOpts().CPlusPlus && - expr_->HasSideEffects(ast_context)) { + expr_->HasSideEffects(ast_context)) { result += "_EVALUATED"; } else if (!ast_context.getLangOpts().CPlusPlus && expr_->isLValue()) { result += "_POINTER"; diff --git a/src/libdredd/src/mutation_replace_unary_operator.cc b/src/libdredd/src/mutation_replace_unary_operator.cc index d9271d30..1be538d7 100644 --- a/src/libdredd/src/mutation_replace_unary_operator.cc +++ b/src/libdredd/src/mutation_replace_unary_operator.cc @@ -282,11 +282,14 @@ bool MutationReplaceUnaryOperator::IsRedundantReplacementOperator( return false; } -std::string MutationReplaceUnaryOperator::GetUnaryMacroName(const std::string& operator_name, const clang::ASTContext& ast_context) const { +std::string MutationReplaceUnaryOperator::GetUnaryMacroName( + const std::string& operator_name, + const clang::ASTContext& ast_context) const { std::string result = "REPLACE_UNARY_" + operator_name; - if (ast_context.getLangOpts().CPlusPlus && unary_operator_->HasSideEffects(ast_context)) { - result += "_EVALUATED"; - } + if (ast_context.getLangOpts().CPlusPlus && + unary_operator_->HasSideEffects(ast_context)) { + result += "_EVALUATED"; + } if (!ast_context.getLangOpts().CPlusPlus && unary_operator_->isIncrementDecrementOp()) { result += "_POINTER"; @@ -317,7 +320,8 @@ void MutationReplaceUnaryOperator::GenerateUnaryOperatorReplacement( continue; } if (!only_track_mutant_coverage) { - const std::string macro_name = GetUnaryMacroName(OpKindToString(operator_kind), ast_context); + const std::string macro_name = + GetUnaryMacroName(OpKindToString(operator_kind), ast_context); new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; if (IsPrefix(operator_kind)) { dredd_macros.insert(GenerateMutationMacro( From e1d07a0b1601e10dbf910126faf4864e0ee9f10a Mon Sep 17 00:00:00 2001 From: James Lee-Jones Date: Thu, 23 Nov 2023 14:30:44 +0000 Subject: [PATCH 15/15] Clang-tidy fixes --- src/libdredd/include/libdredd/util.h | 2 +- src/libdredd/src/mutation_replace_expr.cc | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libdredd/include/libdredd/util.h b/src/libdredd/include/libdredd/util.h index 047bb829..965b3f55 100644 --- a/src/libdredd/include/libdredd/util.h +++ b/src/libdredd/include/libdredd/util.h @@ -131,7 +131,7 @@ bool IsCxx11ConstantExpr(const clang::Expr& expr, std::string GenerateMutationPrelude(); std::string GenerateMutationMacro(const std::string& name, - const std::string& arg_evaluated); + const std::string& args_evaluated); std::string GenerateMutationReturn(); } // namespace dredd diff --git a/src/libdredd/src/mutation_replace_expr.cc b/src/libdredd/src/mutation_replace_expr.cc index abc54ff7..9f235241 100644 --- a/src/libdredd/src/mutation_replace_expr.cc +++ b/src/libdredd/src/mutation_replace_expr.cc @@ -332,7 +332,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 0.0, ast_context)) { // Replace floating point expression with 0.0 if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; + const std::string macro_name = "REPLACE_EXPR_FLOAT_ZERO"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "0.0")); @@ -347,7 +347,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, 1.0, ast_context)) { // Replace floating point expression with 1.0 if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; + const std::string macro_name = "REPLACE_EXPR_FLOAT_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "1.0")); @@ -362,7 +362,7 @@ void MutationReplaceExpr::GenerateFloatConstantReplacement( !ExprIsEquivalentToFloat(*expr_, -1.0, ast_context)) { // Replace floating point expression with -1.0 if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; + const std::string macro_name = "REPLACE_EXPR_FLOAT_MINUS_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "-1.0")); @@ -386,7 +386,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 0, ast_context)) { // Replace expression with 0 if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_INT_ZERO"; + const std::string macro_name = "REPLACE_EXPR_INT_ZERO"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "0")); @@ -400,7 +400,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( if (!optimise_mutations || !ExprIsEquivalentToInt(*expr_, 1, ast_context)) { // Replace expression with 1 if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_INT_ONE"; + const std::string macro_name = "REPLACE_EXPR_INT_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "1")); @@ -417,7 +417,7 @@ void MutationReplaceExpr::GenerateIntegerConstantReplacement( !ExprIsEquivalentToInt(*expr_, -1, ast_context)) { // Replace signed integer expression with -1 if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; + const std::string macro_name = "REPLACE_EXPR_INT_MINUS_ONE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(macro_name, "-1")); @@ -443,7 +443,7 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(true, ast_context))) { // Replace expression with true if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_TRUE"; + const std::string macro_name = "REPLACE_EXPR_TRUE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro( @@ -459,7 +459,7 @@ void MutationReplaceExpr::GenerateBooleanConstantReplacement( !IsBooleanReplacementRedundantForBinaryOperator(false, ast_context))) { // Replace expression with false if (!only_track_mutant_coverage) { - std::string macro_name = "REPLACE_EXPR_FALSE"; + const std::string macro_name = "REPLACE_EXPR_FALSE"; new_function << " " << macro_name << "(" << mutation_id_offset << ");\n"; dredd_macros.insert(GenerateMutationMacro(