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

Function matchTemplateParameters

lib/templatesimplifier.cpp:3386–3423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3384}
3385
3386static bool matchTemplateParameters(const Token *nameTok, const std::list<std::string> &strings)
3387{
3388 const Token *tok = nameTok->tokAt(2);
3389 const Token *end = nameTok->next()->findClosingBracket();
3390 if (!end)
3391 return false;
3392 auto it = strings.cbegin();
3393 while (tok && tok != end && it != strings.cend()) {
3394 if (tok->isUnsigned()) {
3395 if (*it != "unsigned")
3396 return false;
3397
3398 ++it;
3399 if (it == strings.cend())
3400 return false;
3401 } else if (tok->isSigned()) {
3402 if (*it != "signed")
3403 return false;
3404
3405 ++it;
3406 if (it == strings.cend())
3407 return false;
3408 }
3409 if (tok->isLong()) {
3410 if (*it != "long")
3411 return false;
3412
3413 ++it;
3414 if (it == strings.cend())
3415 return false;
3416 }
3417 if (*it != tok->str())
3418 return false;
3419 tok = tok->next();
3420 ++it;
3421 }
3422 return it == strings.cend() && tok && tok->str() == ">";
3423}
3424
3425void TemplateSimplifier::replaceTemplateUsage(
3426 const TokenAndName &instantiation,

Callers 1

replaceTemplateUsageMethod · 0.85

Calls 5

nextMethod · 0.80
isUnsignedMethod · 0.80
tokAtMethod · 0.45
findClosingBracketMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected