MCPcopy Create free account
hub / github.com/Samsung/UTopia / genEntry

Method genEntry

lib/generation/ProtobufMutator.cpp:36–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36void ProtobufMutator::genEntry(const std::string &OutDir,
37 const std::string &FileName,
38 const std::string &Signature) {
39 std::string Code(Signature);
40 // Headers
41 for (const auto &Header : getHeaders())
42 Code += SrcGenerator::genIncludeStmt(Header);
43
44 Code += R"(extern "C" {)";
45 // Fuzz var declaration
46 for (auto FuzzVarDecl : FuzzVarDecls)
47 Code += FuzzVarDecl;
48 Code += "}";
49
50 // Fuzzer main
51 Code += "DEFINE_PROTO_FUZZER(const " + DescriptorNameSpace +
52 "::" + DescriptorName + " &" + DescriptorObjName + ") {";
53
54 // Assign mutation result
55 for (auto FuzzVarAssign : FuzzVarAssigns)
56 Code += FuzzVarAssign;
57
58 Code += UTModify::UTEntryFuncName + "(); }";
59
60 Code = SrcGenerator::reformat(Code);
61
62 util::saveFile((fs::path(OutDir) / FileName).c_str(), Code.c_str());
63 Descriptor.genProtoFile(OutDir);
64}
65
66std::string ProtobufMutator::genFuzzVarDecl(FuzzInput &Input) {
67 auto FuzzVarName = Input.getFuzzVarName();

Callers 2

generateMethod · 0.80
verifyGenerateResultMethod · 0.80

Calls 2

saveFileFunction · 0.85
genProtoFileMethod · 0.80

Tested by 1

verifyGenerateResultMethod · 0.64