Skip to content

Commit

Permalink
Fix: address reviewer comment
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanFoo0523 committed Sep 25, 2024
1 parent a92a40b commit 7c6e274
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ case "$(uname)" in
rm -r test/execute/constant_function_argument

# The C code generated by Dredd may require recent C/C++ support.
# Dredd's prelude includes experimental `stdatomic.h`` header.
# Dredd's prelude includes the experimental `stdatomic.h` header.
export DREDD_EXTRA_C_ARGS="/std:c17 /experimental:c11atomics"
export DREDD_EXTRA_CXX_ARGS="/std:c++20"
;;
Expand Down
47 changes: 21 additions & 26 deletions src/libdredd/src/mutate_ast_consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ const char* const kDreddPreludeStartComment =
"//\n"
"// void __dredd_prelude_start();\n"
"//\n";

const char* const kDreddPreludeHeadersCpp =
"#include <atomic>\n"
"#include <cinttypes>\n"
"#include <cstddef>\n"
"#include <fstream>\n"
"#include <functional>\n"
"#include <sstream>\n"
"#include <string>\n\n";

const char* const kDreddPreludeHeadersC =
"#include <inttypes.h>\n"
"#include <stdatomic.h>\n"
"#include <stdbool.h>\n"
"#include <stdio.h>\n"
"#include <stdlib.h>\n"
"#include <string.h>\n";
} // namespace

void MutateAstConsumer::HandleTranslationUnit(clang::ASTContext& ast_context) {
Expand Down Expand Up @@ -241,13 +258,7 @@ std::string MutateAstConsumer::GetRegularDreddPreludeCpp(
(num_mutations + kWordSize - 1) / kWordSize;

std::stringstream result;
result << "#include <atomic>\n";
result << "#include <cinttypes>\n";
result << "#include <cstddef>\n";
result << "#include <fstream>\n";
result << "#include <functional>\n";
result << "#include <sstream>\n";
result << "#include <string>\n\n";
result << kDreddPreludeHeadersCpp;
result << "\n";
result << "#ifdef _MSC_VER\n";
result << "#define thread_local __declspec(thread)\n";
Expand Down Expand Up @@ -334,13 +345,7 @@ std::string MutateAstConsumer::GetMutantTrackingDreddPreludeCpp(
const int num_mutations = *mutation_id_ - initial_mutation_id;

std::stringstream result;
result << "#include <atomic>\n";
result << "#include <cinttypes>\n";
result << "#include <cstddef>\n";
result << "#include <fstream>\n";
result << "#include <functional>\n";
result << "#include <sstream>\n";
result << "#include <string>\n\n";
result << kDreddPreludeHeadersCpp;
result << "\n";
result << "static void __dredd_record_covered_mutants(int local_mutation_id, "
"int num_mutations) {\n";
Expand Down Expand Up @@ -380,12 +385,7 @@ std::string MutateAstConsumer::GetRegularDreddPreludeC(
(num_mutations + kWordSize - 1) / kWordSize;

std::stringstream result;
result << "#include <inttypes.h>\n";
result << "#include <stdatomic.h>\n";
result << "#include <stdbool.h>\n";
result << "#include <stdio.h>\n";
result << "#include <stdlib.h>\n";
result << "#include <string.h>\n";
result << kDreddPreludeHeadersC;
result << "\n";
result << "#ifdef _MSC_VER\n";
result << "#define thread_local __declspec(thread)\n";
Expand Down Expand Up @@ -440,12 +440,7 @@ std::string MutateAstConsumer::GetMutantTrackingDreddPreludeC(
// port to C.
const int num_mutations = *mutation_id_ - initial_mutation_id;
std::stringstream result;
result << "#include <inttypes.h>\n";
result << "#include <stdatomic.h>\n";
result << "#include <stdbool.h>\n";
result << "#include <stdio.h>\n";
result << "#include <stdlib.h>\n";
result << "#include <string.h>\n";
result << kDreddPreludeHeadersC;
result << "\n";
result << "static void __dredd_record_covered_mutants(int local_mutation_id, "
"int num_mutations) {\n";
Expand Down

0 comments on commit 7c6e274

Please sign in to comment.