| 125 | } |
| 126 | |
| 127 | void UTModify::generateBottom( |
| 128 | const std::map<std::string, std::vector<std::string>> &FuzzVarFlagDecls, |
| 129 | const std::map<std::string, std::vector<GlobalVarSetter>> &Setters, |
| 130 | const Unittest &UT, const SourceAnalysisReport &SourceReport) { |
| 131 | auto UTPath = UT.getFilePath(); |
| 132 | auto UTType = UT.getType(); |
| 133 | |
| 134 | std::set<std::string> Paths = {UTPath}; |
| 135 | for (const auto &Iter : Setters) |
| 136 | Paths.emplace(Iter.first); |
| 137 | |
| 138 | for (const auto &Path : Paths) { |
| 139 | auto EndOffset = SourceReport.getEndOffset(Path); |
| 140 | assert(EndOffset > 0 && "Unexpected Program State"); |
| 141 | |
| 142 | std::string Content; |
| 143 | auto Iter = Setters.find(Path); |
| 144 | if (Iter != Setters.end()) { |
| 145 | for (const auto &Iter2 : Iter->second) { |
| 146 | Content += ("void " + Iter2.FuncName + "() {\n" + util::getIndent(1) + |
| 147 | Iter2.FuncBody + "\n" + "}\n"); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | if (Path == UTPath) { |
| 152 | Content += "void " + UTEntryFuncName + "() {\n"; |
| 153 | for (const auto &Iter2 : Setters) |
| 154 | for (const auto &Iter3 : Iter2.second) |
| 155 | Content += util::getIndent(1) + Iter3.FuncName + "();\n"; |
| 156 | |
| 157 | for (const auto &Iter2 : FuzzVarFlagDecls) |
| 158 | for (const auto &Iter3 : Iter2.second) |
| 159 | Content += util::getIndent(1) + Iter3 + " = 1;\n"; |
| 160 | |
| 161 | auto TCFactory = createTCAnalyzerFactory(UTType); |
| 162 | assert(TCFactory && "Unexpected Program State"); |
| 163 | auto CallWriter = TCFactory->createTCCallWriter(); |
| 164 | assert(CallWriter && "Unexpected Program State"); |
| 165 | |
| 166 | Content += CallWriter->getTCCall(UT, util::getIndent(1)); |
| 167 | Content += "}\n"; |
| 168 | } |
| 169 | if (!Content.empty()) |
| 170 | Content = "\n" + CPPMacroStart + Content + CPPMacroEnd; |
| 171 | addReplace(Replacement(Path, EndOffset, 0, Content)); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | std::string UTModify::generateDeclTypeName(const Type &T) const { |
| 176 | std::string TypeName = ""; |
nothing calls this directly
no test coverage detected