| 249 | } |
| 250 | |
| 251 | void CheckInternalImpl::checkUnknownPattern() |
| 252 | { |
| 253 | const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase(); |
| 254 | for (const Scope* scope : symbolDatabase->functionScopes) { |
| 255 | for (const Token* tok = scope->bodyStart->next(); tok != scope->bodyEnd; tok = tok->next()) { |
| 256 | if (!Token::simpleMatch(tok, "Token :: Match (") && !Token::simpleMatch(tok, "Token :: findmatch (")) |
| 257 | continue; |
| 258 | |
| 259 | // Get pattern string |
| 260 | const Token *patternTok = tok->tokAt(4)->nextArgument(); |
| 261 | if (!patternTok || patternTok->tokType() != Token::eString) |
| 262 | continue; |
| 263 | |
| 264 | const std::string pattern = patternTok->strValue(); |
| 265 | bool inBrackets = false; |
| 266 | |
| 267 | for (std::string::size_type j = 0; j < pattern.length() - 1; j++) { |
| 268 | if (pattern[j] == '[' && (j == 0 || pattern[j - 1] == ' ')) |
| 269 | inBrackets = true; |
| 270 | else if (pattern[j] == ']') |
| 271 | inBrackets = false; |
| 272 | else if (pattern[j] == '%' && pattern[j + 1] != ' ' && pattern[j + 1] != '|' && !inBrackets) { |
| 273 | const std::string::size_type end = pattern.find('%', j + 1); |
| 274 | if (end != std::string::npos) { |
| 275 | const std::string s = pattern.substr(j, end - j + 1); |
| 276 | if (knownPatterns.find(s) == knownPatterns.end()) |
| 277 | unknownPatternError(tok, s); |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | } |
| 284 | |
| 285 | void CheckInternalImpl::checkRedundantNextPrevious() |
| 286 | { |
no test coverage detected