| 196 | } |
| 197 | |
| 198 | static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Settings &settings, SuppressionList &suppressions, std::list<BadInlineSuppression> &bad) |
| 199 | { |
| 200 | std::list<SuppressionList::Suppression> inlineSuppressionsBlockBegin; |
| 201 | |
| 202 | bool onlyComments = true; |
| 203 | |
| 204 | polyspace::Parser polyspaceParser(settings); |
| 205 | |
| 206 | for (const simplecpp::Token *tok = tokens.cfront(); tok; tok = tok->next) { |
| 207 | if (!tok->comment) { |
| 208 | onlyComments = false; |
| 209 | continue; |
| 210 | } |
| 211 | |
| 212 | std::list<SuppressionList::Suppression> inlineSuppressions; |
| 213 | if (polyspace::isPolyspaceComment(tok->str())) { |
| 214 | inlineSuppressions = polyspaceParser.parse(tok->str(), tok->location.line, getRelativeFilename(tokens, tok, settings)); |
| 215 | } else { |
| 216 | if (!parseInlineSuppressionCommentToken(tok, inlineSuppressions, bad)) |
| 217 | continue; |
| 218 | |
| 219 | if (!sameline(tok->previous, tok)) { |
| 220 | // find code after comment.. |
| 221 | if (tok->next) { |
| 222 | tok = tok->next; |
| 223 | |
| 224 | while (tok->comment) { |
| 225 | parseInlineSuppressionCommentToken(tok, inlineSuppressions, bad); |
| 226 | if (tok->next) { |
| 227 | tok = tok->next; |
| 228 | } else { |
| 229 | break; |
| 230 | } |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | if (inlineSuppressions.empty()) |
| 237 | continue; |
| 238 | |
| 239 | // It should never happen |
| 240 | if (!tok) |
| 241 | continue; |
| 242 | |
| 243 | // Relative filename |
| 244 | const std::string relativeFilename = getRelativeFilename(tokens, tok, settings); |
| 245 | |
| 246 | // Macro name |
| 247 | std::string macroName; |
| 248 | if (tok->str() == "#" && tok->next && tok->next->str() == "define") { |
| 249 | const simplecpp::Token *macroNameTok = tok->next->next; |
| 250 | if (sameline(tok, macroNameTok) && macroNameTok->name) { |
| 251 | macroName = macroNameTok->str(); |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | // Add the suppressions. |
no test coverage detected