| 8471 | } |
| 8472 | |
| 8473 | void Tokenizer::validate() const |
| 8474 | { |
| 8475 | std::stack<const Token *> linkTokens; |
| 8476 | const Token *lastTok = nullptr; |
| 8477 | for (const Token *tok = tokens(); tok; tok = tok->next()) { |
| 8478 | lastTok = tok; |
| 8479 | if (Token::Match(tok, "[{([]") || (tok->str() == "<" && tok->link())) { |
| 8480 | if (tok->link() == nullptr) |
| 8481 | cppcheckError(tok); |
| 8482 | |
| 8483 | linkTokens.push(tok); |
| 8484 | } |
| 8485 | |
| 8486 | else if (Token::Match(tok, "[})]]") || (Token::Match(tok, ">|>>") && tok->link())) { |
| 8487 | if (tok->link() == nullptr) |
| 8488 | cppcheckError(tok); |
| 8489 | |
| 8490 | if (linkTokens.empty()) |
| 8491 | cppcheckError(tok); |
| 8492 | |
| 8493 | if (tok->link() != linkTokens.top()) |
| 8494 | cppcheckError(tok); |
| 8495 | |
| 8496 | if (tok != tok->link()->link()) |
| 8497 | cppcheckError(tok); |
| 8498 | |
| 8499 | linkTokens.pop(); |
| 8500 | } |
| 8501 | |
| 8502 | else if (tok->link() != nullptr) |
| 8503 | cppcheckError(tok); |
| 8504 | } |
| 8505 | |
| 8506 | if (!linkTokens.empty()) |
| 8507 | cppcheckError(linkTokens.top()); |
| 8508 | |
| 8509 | // Validate that the Tokenizer::list.back() is updated correctly during simplifications |
| 8510 | if (lastTok != list.back()) |
| 8511 | cppcheckError(lastTok); |
| 8512 | } |
| 8513 | |
| 8514 | static const Token *findUnmatchedTernaryOp(const Token * const begin, const Token * const end, int depth = 0) |
| 8515 | { |
no test coverage detected