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

Method getMacroParameters

externals/simplecpp/simplecpp.cpp:1861–1883  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1859 }
1860
1861 std::vector<const Token *> getMacroParameters(const Token *nameTokInst, bool calledInDefine) const {
1862 if (!nameTokInst->next || nameTokInst->next->op != '(' || !functionLike())
1863 return {};
1864
1865 std::vector<const Token *> parametertokens;
1866 parametertokens.emplace_back(nameTokInst->next);
1867 unsigned int par = 0U;
1868 for (const Token *tok = nameTokInst->next->next; calledInDefine ? sameline(tok, nameTokInst) : (tok != nullptr); tok = tok->next) {
1869 if (tok->op == '(') {
1870 ++par;
1871 }
1872 else if (tok->op == ')') {
1873 if (par == 0U) {
1874 parametertokens.emplace_back(tok);
1875 break;
1876 }
1877 --par;
1878 } else if (par == 0U && tok->op == ',' && (!variadic || parametertokens.size() < args.size())) {
1879 parametertokens.emplace_back(tok);
1880 }
1881 }
1882 return parametertokens;
1883 }
1884
1885 const Token *appendTokens(TokenList &tokens,
1886 const Location &rawloc,

Callers

nothing calls this directly

Calls 2

samelineFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected