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

Method generateFuzzVarReplacements

lib/generation/UTModify.cpp:246–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246void UTModify::generateFuzzVarReplacements(const FuzzInput &Input) {
247 const auto &Def = Input.getDef();
248 const auto &T = Def.DataType;
249 assert(T && "Unexpected Program State");
250
251 if (Def.Declaration != Definition::DeclType_None) {
252 auto TypeString = util::trim(Def.TypeString);
253 auto Stripped = util::stripConstExpr(TypeString);
254 if (Stripped != TypeString) {
255 addReplace(Replacement(Def.Path, Def.TypeOffset,
256 static_cast<unsigned int>(Def.TypeString.size()),
257 Stripped + " "));
258 }
259 }
260
261 if (Def.Declaration == Definition::DeclType_Global)
262 return;
263
264 const auto *CopyFrom = Input.getCopyFrom();
265 const auto *AssignBase = CopyFrom ? CopyFrom : &Input;
266 auto AssignStmt = generateAssignStatement(*AssignBase);
267 if (Def.Declaration == Definition::DeclType_StaticLocal) {
268 auto FlagVarName = util::getStaticLocalFlagVarName(Input.getFuzzVarName());
269 AssignStmt = " if (" + FlagVarName + ") { " + FlagVarName + " = 0; " +
270 AssignStmt + " }";
271 addReplace(Replacement(Def.Path, Def.EndOffset, 0, AssignStmt));
272 return;
273 }
274
275 if (T->isFixedLengthArrayPtr()) {
276 addReplace(Replacement(Def.Path, Def.EndOffset, 0, " " + AssignStmt));
277 return;
278 }
279
280 addReplace(Replacement(Def.Path, Def.Offset, Def.Length, AssignStmt));
281}
282
283bool UTModify::generateHeader(const std::string &BasePath) {
284 const std::string CheckerMacro = "AUTOFUZZ";

Callers

nothing calls this directly

Calls 8

trimFunction · 0.85
stripConstExprFunction · 0.85
getDefMethod · 0.80
sizeMethod · 0.80
getCopyFromMethod · 0.80
getFuzzVarNameMethod · 0.80
isFixedLengthArrayPtrMethod · 0.80

Tested by

no test coverage detected