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

Method simplifyTokens1

lib/tokenize.cpp:3515–3582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3513}
3514
3515bool Tokenizer::simplifyTokens1(const std::string &configuration, int fileIndex)
3516{
3517 // Fill the map mTypeSize..
3518 fillTypeSizes();
3519
3520 mConfiguration = configuration;
3521
3522 if (mTimerResults) {
3523 Timer t("Tokenizer::simplifyTokens1::simplifyTokenList1", mTimerResults);
3524 if (!simplifyTokenList1(list.getFiles().front().c_str()))
3525 return false;
3526 } else {
3527 if (!simplifyTokenList1(list.getFiles().front().c_str()))
3528 return false;
3529 }
3530
3531 Timer::run("Tokenizer::simplifyTokens1::createAst", mTimerResults, [&]() {
3532 list.createAst();
3533 list.validateAst(mSettings.debugnormal);
3534 });
3535
3536 Timer::run("Tokenizer::simplifyTokens1::createSymbolDatabase", mTimerResults, [&]() {
3537 createSymbolDatabase();
3538 });
3539
3540 Timer::run("Tokenizer::simplifyTokens1::setValueType", mTimerResults, [&]() {
3541 mSymbolDatabase->setValueTypeInTokenList(false);
3542 mSymbolDatabase->setValueTypeInTokenList(true);
3543 });
3544
3545 if (!mSettings.buildDir.empty())
3546 Summaries::create(*this, configuration, fileIndex);
3547
3548 // TODO: apply this through Settings::ValueFlowOptions
3549 // TODO: do not run valueflow if no checks are being performed at all - e.g. unusedFunctions only
3550 // TODO: log message when this is active?
3551 const char* disableValueflowEnv = std::getenv("DISABLE_VALUEFLOW");
3552 const bool doValueFlow = !disableValueflowEnv || (std::strcmp(disableValueflowEnv, "1") != 0);
3553
3554 if (doValueFlow) {
3555 Timer::run("Tokenizer::simplifyTokens1::ValueFlow", mTimerResults, [&]() {
3556 ValueFlow::setValues(list, *mSymbolDatabase, mErrorLogger, mSettings, mTimerResults);
3557 });
3558
3559 arraySizeAfterValueFlow();
3560 }
3561
3562 // Warn about unhandled character literals
3563 if (mSettings.severity.isEnabled(Severity::portability)) {
3564 for (const Token *tok = tokens(); tok; tok = tok->next()) {
3565 if (tok->tokType() == Token::eChar && tok->values().empty()) {
3566 try {
3567 simplecpp::characterLiteralToLL(tok->str());
3568 } catch (const std::runtime_error &e) {
3569 unhandledCharLiteral(tok, e.what());
3570 }
3571 }
3572 }

Callers 15

checkInternalMethod · 0.80
bailout_Method · 0.80
tokenizeExpr_Method · 0.80
validateMethod · 0.80
testAstMethod · 0.80
checkHdrs_Method · 0.80
check_Method · 0.80
checkP_Method · 0.80
checkP_Method · 0.80
checkP_Method · 0.80

Calls 12

setValuesFunction · 0.85
tokensFunction · 0.85
frontMethod · 0.80
createAstMethod · 0.80
validateAstMethod · 0.80
nextMethod · 0.80
runFunction · 0.70
emptyMethod · 0.45
isEnabledMethod · 0.45
strMethod · 0.45

Tested by 15

bailout_Method · 0.64
tokenizeExpr_Method · 0.64
validateMethod · 0.64
testAstMethod · 0.64
checkHdrs_Method · 0.64
check_Method · 0.64
checkP_Method · 0.64
checkP_Method · 0.64
checkP_Method · 0.64
checkP_Method · 0.64