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

Method createTokensVarDecl

lib/clangimport.cpp:1531–1570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1529}
1530
1531Token * clangimport::AstNode::createTokensVarDecl(TokenList &tokenList)
1532{
1533 const std::string addr = mExtTokens.front();
1534 if (contains(mExtTokens, "static"))
1535 addtoken(tokenList, "static");
1536 int typeIndex = mExtTokens.size() - 1;
1537 while (typeIndex > 1 && std::isalpha(mExtTokens[typeIndex][0]))
1538 typeIndex--;
1539 const std::string type = mExtTokens[typeIndex];
1540 const std::string name = mExtTokens[typeIndex - 1];
1541 const Token *startToken = tokenList.back();
1542 const ::Type *recordType = addTypeTokens(tokenList, type);
1543 if (!startToken)
1544 startToken = tokenList.front();
1545 else if (startToken->str() != "static")
1546 startToken = startToken->next();
1547 Token *vartok1 = addtoken(tokenList, name);
1548 auto *scope = const_cast<Scope *>(tokenList.back()->scope());
1549 scope->varlist.emplace_back(vartok1, unquote(type), startToken, vartok1->previous(), 0, scope->defaultAccess(), recordType, scope);
1550 mData->varDecl(addr, vartok1, &scope->varlist.back());
1551 if (mExtTokens.back() == "cinit" && !children.empty()) {
1552 Token *eq = addtoken(tokenList, "=");
1553 eq->astOperand1(vartok1);
1554 eq->astOperand2(children.back()->createTokens(tokenList));
1555 return eq;
1556 }
1557 if (mExtTokens.back() == "callinit") {
1558 Token *par1 = addtoken(tokenList, "(");
1559 par1->astOperand1(vartok1);
1560 par1->astOperand2(getChild(0)->createTokens(tokenList));
1561 Token *par2 = addtoken(tokenList, ")");
1562 par1->link(par2);
1563 par2->link(par1);
1564 return par1;
1565 }
1566 if (mExtTokens.back() == "listinit") {
1567 return getChild(0)->createTokens(tokenList);
1568 }
1569 return vartok1;
1570}
1571
1572static void setTypes(TokenList &tokenList)
1573{

Callers

nothing calls this directly

Calls 13

containsFunction · 0.85
frontMethod · 0.80
nextMethod · 0.80
scopeMethod · 0.80
defaultAccessMethod · 0.80
varDeclMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
unquoteFunction · 0.70
sizeMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected