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

Function usingMatch

lib/tokenize.cpp:2704–2843  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2702 }
2703
2704 bool usingMatch(
2705 const Token *nameToken,
2706 const std::string &scope,
2707 Token *&tok,
2708 const std::string &scope1,
2709 const ScopeInfo3 *currentScope,
2710 const ScopeInfo3 *memberClassScope)
2711 {
2712 Token *tok1 = tok;
2713
2714 if (tok1 && tok1->str() != nameToken->str())
2715 return false;
2716
2717 // skip this using
2718 if (tok1 == nameToken) {
2719 tok = findSemicolon(tok1);
2720 return false;
2721 }
2722
2723 // skip other using with this name
2724 if (tok1->strAt(-1) == "using") {
2725 // fixme: this is wrong
2726 // skip to end of scope
2727 if (currentScope->bodyEnd)
2728 tok = const_cast<Token*>(currentScope->bodyEnd->previous());
2729 return false;
2730 }
2731
2732 if (tok1->tokAt(-1)->tokType() == Token::eType || tok1->tokAt(-1)->tokType() == Token::eName)
2733 return false;
2734
2735 if (Token::Match(tok1->tokAt(-1), "class|struct|union|enum|namespace")) {
2736 // fixme
2737 return false;
2738 }
2739
2740 if (Token::simpleMatch(tok1->tokAt(-2), "> ::")) {
2741 return false;
2742 }
2743
2744 if (Token::Match(tok1, "%name% (") && TokenList::isFunctionHead(tok1->next(), "{;:")) {
2745 if (Token::Match(tok1->previous(), "%name%") && !tok1->previous()->isControlFlowKeyword())
2746 return false;
2747 if (Token::Match(tok1->previous(), ">|>>") && tok1->linkAt(-1))
2748 return false;
2749 if (Token::Match(tok1->previous(), "*|&|&&")) {
2750 const Token* prev = tok1->previous();
2751 while (Token::Match(prev, "%name%|*|&|&&|::") && !prev->isControlFlowKeyword())
2752 prev = prev->previous();
2753 if (Token::Match(prev, ">|>>") && tok1->linkAt(-1))
2754 return false;
2755 if (Token::Match(prev, "[;{}] %name%"))
2756 return false;
2757 }
2758 }
2759
2760 // get qualification
2761 std::string qualification;

Callers 1

simplifyUsingMethod · 0.85

Calls 13

findSemicolonFunction · 0.85
nextMethod · 0.80
linkAtMethod · 0.80
findTypeInBaseMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45
tokAtMethod · 0.45
sizeMethod · 0.45
isKeywordMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected