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

Method appendTokens

externals/simplecpp/simplecpp.cpp:1885–1922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1883 }
1884
1885 const Token *appendTokens(TokenList &tokens,
1886 const Location &rawloc,
1887 const Token * const lpar,
1888 const MacroMap &macros,
1889 const std::set<TokenString> &expandedmacros,
1890 const std::vector<const Token*> &parametertokens) const {
1891 if (!lpar || lpar->op != '(')
1892 return nullptr;
1893 unsigned int par = 0;
1894 const Token *tok = lpar;
1895 while (sameline(lpar, tok)) {
1896 if (tok->op == '#' && sameline(tok,tok->next) && tok->next->op == '#' && sameline(tok,tok->next->next)) {
1897 // A##B => AB
1898 tok = expandHashHash(tokens, rawloc, tok, macros, expandedmacros, parametertokens, false);
1899 } else if (tok->op == '#' && sameline(tok, tok->next) && tok->next->op != '#') {
1900 tok = expandHash(tokens, rawloc, tok, expandedmacros, parametertokens);
1901 } else {
1902 if (!expandArg(tokens, tok, rawloc, macros, expandedmacros, parametertokens)) {
1903 tokens.push_back(new Token(*tok));
1904 if (tok->macro.empty() && (par > 0 || tok->str() != "("))
1905 tokens.back()->macro = name();
1906 }
1907
1908 if (tok->op == '(') {
1909 ++par;
1910 }
1911 else if (tok->op == ')') {
1912 --par;
1913 if (par == 0U)
1914 break;
1915 }
1916 tok = tok->next;
1917 }
1918 }
1919 for (Token *tok2 = tokens.front(); tok2; tok2 = tok2->next)
1920 tok2->location = lpar->location;
1921 return sameline(lpar,tok) ? tok : nullptr;
1922 }
1923
1924 const Token * expand(TokenList & output, const Location &loc, const Token * const nameTokInst, const MacroMap &macros, std::set<TokenString> expandedmacros) const {
1925 expandedmacros.insert(nameTokInst->str());

Callers

nothing calls this directly

Calls 5

frontMethod · 0.80
samelineFunction · 0.70
push_backMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected