| 265 | } |
| 266 | |
| 267 | void FuzzInputGenerator::applyArrayPolicies( |
| 268 | std::map<unsigned, std::shared_ptr<FuzzInput>> &FuzzInputMap, |
| 269 | std::map<unsigned, std::shared_ptr<FuzzNoInput>> &FuzzNoInputMap, |
| 270 | std::vector<std::set<unsigned>> &ArrayGroups) const { |
| 271 | |
| 272 | for (int S = 0; S < (int)ArrayGroups.size(); ++S) { |
| 273 | auto &Group = ArrayGroups[S]; |
| 274 | std::set<unsigned> ArrayDefIDs; |
| 275 | std::set<unsigned> ArrayLenDefIDs; |
| 276 | |
| 277 | for (auto Member : Group) { |
| 278 | auto Iter = FuzzInputMap.find(Member); |
| 279 | assert(Iter != FuzzInputMap.end() && "Unexpected Program State"); |
| 280 | assert(Iter->second && "Unexpected Program State"); |
| 281 | |
| 282 | auto &Def = Iter->second->getDef(); |
| 283 | if (Def.Array) |
| 284 | ArrayDefIDs.emplace(Def.ID); |
| 285 | else if (Def.ArrayLen) |
| 286 | ArrayLenDefIDs.emplace(Def.ID); |
| 287 | } |
| 288 | |
| 289 | if (ArrayDefIDs.size() != 1) { |
| 290 | for (auto Member : Group) { |
| 291 | auto Iter = FuzzInputMap.find(Member); |
| 292 | assert(Iter != FuzzInputMap.end() && "Unexpected Program State"); |
| 293 | assert(Iter->second && "Unexpected Program State"); |
| 294 | |
| 295 | auto Def = Iter->second->getDefPtr(); |
| 296 | auto NoInput = FuzzNoInputFactory().generateMeshArrayRelation(Def); |
| 297 | assert(NoInput && "Unexpected Program State"); |
| 298 | |
| 299 | FuzzNoInputMap.emplace(NoInput->getDefID(), NoInput); |
| 300 | FuzzInputMap.erase(Iter); |
| 301 | } |
| 302 | ArrayGroups.erase(ArrayGroups.begin() + S); |
| 303 | S--; |
| 304 | continue; |
| 305 | } |
| 306 | |
| 307 | if (ArrayLenDefIDs.size() > 1) { |
| 308 | std::vector<unsigned> ArrayLenDefIDVec(ArrayLenDefIDs.begin(), |
| 309 | ArrayLenDefIDs.end()); |
| 310 | auto Iter = FuzzInputMap.find(ArrayLenDefIDVec[0]); |
| 311 | assert(Iter != FuzzInputMap.end() && "Unexpected Program State"); |
| 312 | assert(Iter->second && "Unexpected Program State"); |
| 313 | |
| 314 | auto &BaseInput = Iter->second; |
| 315 | for (unsigned S1 = 1, E1 = ArrayLenDefIDVec.size(); S1 < E1; ++S1) { |
| 316 | auto Iter = FuzzInputMap.find(ArrayLenDefIDVec[S1]); |
| 317 | assert(Iter != FuzzInputMap.end() && "Unexpected Program State"); |
| 318 | assert(Iter->second && "Unexpected Program State"); |
| 319 | |
| 320 | Iter->second->setCopyFrom(BaseInput); |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | } |
nothing calls this directly
no test coverage detected