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

Function getEnumType

lib/symboldatabase.cpp:7431–7459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7429}
7430
7431static ValueType::Type getEnumType(const Scope* scope, const Platform& platform) // TODO: also determine sign?
7432{
7433 ValueType::Type type = ValueType::Type::INT;
7434 for (const Token* tok = scope->bodyStart; tok && tok != scope->bodyEnd; tok = tok->next()) {
7435 if (const Token* lam = findLambdaEndToken(tok)) {
7436 tok = lam;
7437 continue;
7438 }
7439 if (!tok->isAssignmentOp())
7440 continue;
7441 const Token* vTok = tok->astOperand2();
7442 if (!vTok->hasKnownIntValue()) {
7443 if (!vTok->isLiteral())
7444 continue;
7445 if (const ValueType* vt = vTok->valueType()) {
7446 if ((vt->type > type && (vt->type == ValueType::Type::LONG || vt->type == ValueType::Type::LONGLONG)))
7447 type = vt->type;
7448 }
7449 continue;
7450 }
7451 const MathLib::bigint value = vTok->getKnownIntValue();
7452 if (!platform.isIntValue(value)) {
7453 type = ValueType::Type::LONG;
7454 if (!platform.isLongValue(value))
7455 type = ValueType::Type::LONGLONG;
7456 }
7457 }
7458 return type;
7459}
7460
7461static const Token* parsedecl(const Token* type,
7462 ValueType* const valuetype,

Callers 2

setValueTypeMethod · 0.85
parsedeclFunction · 0.85

Calls 6

findLambdaEndTokenFunction · 0.85
nextMethod · 0.80
isAssignmentOpMethod · 0.80
astOperand2Method · 0.80
getKnownIntValueMethod · 0.80
hasKnownIntValueMethod · 0.45

Tested by

no test coverage detected