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

Function compileUnaryOp

lib/tokenlist.cpp:691–709  ·  view source on GitHub ↗

* @throws InternalError thrown if maximum AST depth is exceeded */

Source from the content-addressed store, hash-verified

689 * @throws InternalError thrown if maximum AST depth is exceeded
690 */
691static void compileUnaryOp(Token *&tok, AST_state& state, void (*f)(Token *&tok, AST_state& state))
692{
693 Token *unaryop = tok;
694 if (f) {
695 tok = tok->next();
696 state.depth++;
697 if (state.depth > AST_MAX_DEPTH)
698 throw InternalError(tok, "maximum AST depth exceeded", InternalError::AST);
699 if (tok)
700 f(tok, state);
701 state.depth--;
702 }
703
704 if (!state.op.empty() && (!precedes(state.op.top(), unaryop) || unaryop->isIncDecOp() || Token::Match(unaryop, "[({[]"))) { // nullary functions, empty lists/arrays
705 unaryop->astOperand1(state.op.top());
706 state.op.pop();
707 }
708 state.op.push(unaryop);
709}
710
711static void skipGenericType(Token *&tok)
712{

Callers 4

compileTermFunction · 0.85
compileScopeFunction · 0.85
compilePrecedence2Function · 0.85
compilePrecedence3Function · 0.85

Calls 5

precedesFunction · 0.85
nextMethod · 0.80
astOperand1Method · 0.80
fFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected