| 244 | } |
| 245 | |
| 246 | void 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 | |
| 283 | bool UTModify::generateHeader(const std::string &BasePath) { |
| 284 | const std::string CheckerMacro = "AUTOFUZZ"; |
nothing calls this directly
no test coverage detected