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

Method simplifyTokenList1

lib/tokenize.cpp:5689–6074  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5687}
5688
5689bool Tokenizer::simplifyTokenList1(const char FileName[])
5690{
5691 if (Settings::terminated())
5692 return false;
5693
5694 // if MACRO
5695 for (Token *tok = list.front(); tok; tok = tok->next()) {
5696 if (Token::Match(tok, "if|for|while %name% (")) {
5697 if (Token::simpleMatch(tok, "for each")) {
5698 // 'for each (x in y )' -> 'for (x : y)'
5699 if (Token* in = Token::findsimplematch(tok->tokAt(2), "in", tok->linkAt(2)))
5700 in->str(":");
5701 tok->deleteNext();
5702 } else if (tok->strAt(1) == "constexpr") {
5703 tok->deleteNext();
5704 tok->isConstexpr(true);
5705 } else {
5706 syntaxError(tok);
5707 }
5708 }
5709 }
5710
5711 // Is there C++ code in C file?
5712 validateC();
5713
5714 // Combine strings and character literals, e.g. L"string", L'c', "string1" "string2"
5715 combineStringAndCharLiterals();
5716
5717 // replace inline SQL with "asm()" (Oracle PRO*C). Ticket: #1959
5718 simplifySQL();
5719
5720 createLinks();
5721
5722 // replace library function calls such as (std::min)(a, b) with std::min(a, b)
5723 simplifyParenthesizedLibraryFunctions();
5724
5725 // Simplify debug intrinsics
5726 simplifyDebug();
5727
5728 removePragma();
5729
5730 // Simplify the C alternative tokens (and, or, etc.)
5731 simplifyCAlternativeTokens();
5732
5733 simplifyFunctionTryCatch();
5734
5735 simplifyHeadersAndUnusedTemplates();
5736
5737 // Remove __asm..
5738 simplifyAsm();
5739
5740 // foo < bar < >> => foo < bar < > >
5741 if (isCPP() || mSettings.daca)
5742 splitTemplateRightAngleBrackets(!isCPP());
5743
5744 // Remove extra "template" tokens that are not used by cppcheck
5745 removeExtraTemplateKeywords();
5746

Callers

nothing calls this directly

Calls 15

terminatedFunction · 0.85
findsimplematchFunction · 0.85
isCPPFunction · 0.85
frontMethod · 0.80
nextMethod · 0.80
linkAtMethod · 0.80
deleteNextMethod · 0.80
markupFileMethod · 0.80
assignIndexesMethod · 0.80
simpleMatchFunction · 0.70
runFunction · 0.70
isCFunction · 0.70

Tested by

no test coverage detected