| 1198 | |
| 1199 | |
| 1200 | void Preprocessor::addRemarkComments(const simplecpp::TokenList &tokens, std::vector<RemarkComment> &remarkComments) const |
| 1201 | { |
| 1202 | for (const simplecpp::Token *tok = tokens.cfront(); tok; tok = tok->next) { |
| 1203 | if (!tok->comment) |
| 1204 | continue; |
| 1205 | |
| 1206 | const std::string& comment = tok->str(); |
| 1207 | |
| 1208 | // is it a remark comment? |
| 1209 | const std::string::size_type pos1 = comment.find_first_not_of("/* \t"); |
| 1210 | if (pos1 == std::string::npos) |
| 1211 | continue; |
| 1212 | const std::string::size_type pos2 = comment.find_first_of(": \t", pos1); |
| 1213 | if (pos2 != pos1 + 6 || comment.compare(pos1, 6, "REMARK") != 0) |
| 1214 | continue; |
| 1215 | const std::string::size_type pos3 = comment.find_first_not_of(": \t", pos2); |
| 1216 | if (pos3 == std::string::npos) |
| 1217 | continue; |
| 1218 | if (comment.compare(0,2,"/*") == 0 && pos3 + 2 >= tok->str().size()) |
| 1219 | continue; |
| 1220 | |
| 1221 | const std::string::size_type pos4 = (comment.compare(0,2,"/*") == 0) ? comment.size()-2 : comment.size(); |
| 1222 | const std::string remarkText = comment.substr(pos3, pos4-pos3); |
| 1223 | |
| 1224 | // Get remarked token |
| 1225 | const simplecpp::Token* remarkedToken = nullptr; |
| 1226 | for (const simplecpp::Token* after = tok->next; after; after = after->next) { |
| 1227 | if (after->comment) |
| 1228 | continue; |
| 1229 | remarkedToken = after; |
| 1230 | break; |
| 1231 | } |
| 1232 | for (const simplecpp::Token* prev = tok->previous; prev; prev = prev->previous) { |
| 1233 | if (prev->comment) |
| 1234 | continue; |
| 1235 | if (sameline(prev, tok)) |
| 1236 | remarkedToken = prev; |
| 1237 | break; |
| 1238 | } |
| 1239 | if (!remarkedToken) |
| 1240 | continue; |
| 1241 | |
| 1242 | // Relative filename |
| 1243 | const std::string relativeFilename = getRelativeFilename(tokens, remarkedToken, mSettings); |
| 1244 | |
| 1245 | // Add the suppressions. |
| 1246 | remarkComments.emplace_back(relativeFilename, remarkedToken->location.line, remarkText); |
| 1247 | } |
| 1248 | } |
nothing calls this directly
no test coverage detected