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

Function skipCaseLabel

lib/tokenize.cpp:4055–4071  ·  view source on GitHub ↗

Skips until the colon at the end of the case label, the argument must point to the "case" token. In case of success returns the colon token. In case of failure returns the token that caused the error.

Source from the content-addressed store, hash-verified

4053// In case of success returns the colon token.
4054// In case of failure returns the token that caused the error.
4055static Token *skipCaseLabel(Token *tok)
4056{
4057 assert(tok->str() == "case");
4058 while (nullptr != (tok = tok->next())) {
4059 if (Token::Match(tok, "(|["))
4060 tok = tok->link();
4061 else if (tok->str() == "?") {
4062 Token * tok1 = skipTernaryOp(tok);
4063 if (!tok1)
4064 return tok;
4065 tok = tok1;
4066 }
4067 if (Token::Match(tok, "[:{};]"))
4068 return tok;
4069 }
4070 return nullptr;
4071}
4072
4073const Token * Tokenizer::startOfExecutableScope(const Token * tok)
4074{

Callers 2

simplifyAddBracesPairMethod · 0.85

Calls 3

nextMethod · 0.80
skipTernaryOpFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected