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

Method getTemplateParametersInDeclaration

lib/templatesimplifier.cpp:2982–3014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2980}
2981
2982void TemplateSimplifier::getTemplateParametersInDeclaration(
2983 const Token * tok,
2984 std::vector<const Token *> & typeParametersInDeclaration)
2985{
2986 assert(tok->strAt(-1) == "<");
2987
2988 typeParametersInDeclaration.clear();
2989 const Token *end = tok->previous()->findClosingBracket();
2990 bool inDefaultValue = false;
2991 for (; tok && tok!= end; tok = tok->next()) {
2992 if (Token::simpleMatch(tok, "template <")) {
2993 const Token *closing = tok->next()->findClosingBracket();
2994 if (closing)
2995 tok = closing->next();
2996 } else if (tok->link() && Token::Match(tok, "{|(|["))
2997 tok = tok->link();
2998 else if (Token::Match(tok, "%name% ,|>|=")) {
2999 if (!inDefaultValue) {
3000 typeParametersInDeclaration.push_back(tok);
3001 if (tok->strAt(1) == "=")
3002 inDefaultValue = true;
3003 }
3004 } else if (inDefaultValue) {
3005 if (tok->str() == ",")
3006 inDefaultValue = false;
3007 else if (tok->str() == "<") {
3008 const Token *closing = tok->findClosingBracket();
3009 if (closing)
3010 tok = closing;
3011 }
3012 }
3013 }
3014}
3015
3016bool TemplateSimplifier::matchSpecialization(
3017 const Token *templateDeclarationNameToken,

Callers

nothing calls this directly

Calls 6

nextMethod · 0.80
simpleMatchFunction · 0.70
clearMethod · 0.45
findClosingBracketMethod · 0.45
push_backMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected