| 9652 | } |
| 9653 | |
| 9654 | void Tokenizer::simplifyCppcheckAttribute() |
| 9655 | { |
| 9656 | for (Token *tok = list.front(); tok; tok = tok->next()) { |
| 9657 | if (tok->str() != "(") |
| 9658 | continue; |
| 9659 | if (!tok->previous()) |
| 9660 | continue; |
| 9661 | const std::string &attr = tok->strAt(-1); |
| 9662 | if (!startsWith(attr, "__cppcheck_")) |
| 9663 | continue; |
| 9664 | if (attr.compare(attr.size()-2, 2, "__") != 0) // TODO: ends_with("__") |
| 9665 | continue; |
| 9666 | |
| 9667 | Token *vartok = tok->link(); |
| 9668 | while (Token::Match(vartok->next(), "%name%|*|&|::")) { |
| 9669 | vartok = vartok->next(); |
| 9670 | if (Token::Match(vartok, "%name% (") && startsWith(vartok->str(),"__cppcheck_")) |
| 9671 | vartok = vartok->linkAt(1); |
| 9672 | } |
| 9673 | |
| 9674 | if (vartok->isName()) { |
| 9675 | if (Token::Match(tok->previous(), "__cppcheck_low__ ( %num% )")) |
| 9676 | vartok->setCppcheckAttribute(Token::CppcheckAttributesType::LOW, |
| 9677 | MathLib::toBigNumber(tok->tokAt(1))); |
| 9678 | else if (Token::Match(tok->previous(), "__cppcheck_high__ ( %num% )")) |
| 9679 | vartok->setCppcheckAttribute(Token::CppcheckAttributesType::HIGH, |
| 9680 | MathLib::toBigNumber(tok->tokAt(1))); |
| 9681 | } |
| 9682 | |
| 9683 | // Delete cppcheck attribute.. |
| 9684 | if (tok->tokAt(-2)) { |
| 9685 | tok = tok->tokAt(-2); |
| 9686 | Token::eraseTokens(tok, tok->linkAt(2)->next()); |
| 9687 | } else { |
| 9688 | tok = tok->previous(); |
| 9689 | Token::eraseTokens(tok, tok->linkAt(1)->next()); |
| 9690 | tok->str(";"); |
| 9691 | } |
| 9692 | } |
| 9693 | } |
| 9694 | |
| 9695 | void Tokenizer::simplifyCPPAttribute() |
| 9696 | { |
nothing calls this directly
no test coverage detected