| 3513 | } |
| 3514 | |
| 3515 | bool 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 | } |