MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / skipTernaryOp

Function skipTernaryOp

lib/templatesimplifier.cpp:2485–2506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2483}
2484
2485static Token *skipTernaryOp(Token *tok, const Token *backToken)
2486{
2487 unsigned int colonLevel = 1;
2488 while (nullptr != (tok = tok->next())) {
2489 if (tok->str() == "?") {
2490 ++colonLevel;
2491 } else if (tok->str() == ":") {
2492 --colonLevel;
2493 if (colonLevel == 0) {
2494 tok = tok->next();
2495 break;
2496 }
2497 }
2498 if (tok->link() && tok->str() == "(")
2499 tok = tok->link();
2500 else if (Token::Match(tok->next(), "[{};)]") || tok->next() == backToken)
2501 break;
2502 }
2503 if (colonLevel > 0) // Ticket #5214: Make sure the ':' matches the proper '?'
2504 return nullptr;
2505 return tok;
2506}
2507
2508static void invalidateInst(const Token* beg, const Token* end, std::vector<newInstantiation>* newInst) {
2509 if (!newInst)

Callers 1

simplifyTemplateArgsMethod · 0.70

Calls 2

nextMethod · 0.80
strMethod · 0.45

Tested by

no test coverage detected