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

Method recursiveExpandToken

externals/simplecpp/simplecpp.cpp:2102–2135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2100 }
2101
2102 const Token *recursiveExpandToken(TokenList &output, TokenList &temp, const Location &loc, const Token *tok, const MacroMap &macros, const std::set<TokenString> &expandedmacros, const std::vector<const Token*> &parametertokens) const {
2103 if (!temp.cback() || !temp.cback()->name || !tok->next || tok->next->op != '(') {
2104 output.takeTokens(temp);
2105 return tok->next;
2106 }
2107
2108 if (!sameline(tok, tok->next)) {
2109 output.takeTokens(temp);
2110 return tok->next;
2111 }
2112
2113 const MacroMap::const_iterator it = macros.find(temp.cback()->str());
2114 if (it == macros.end() || expandedmacros.find(temp.cback()->str()) != expandedmacros.end()) {
2115 output.takeTokens(temp);
2116 return tok->next;
2117 }
2118
2119 const Macro &calledMacro = it->second;
2120 if (!calledMacro.functionLike()) {
2121 output.takeTokens(temp);
2122 return tok->next;
2123 }
2124
2125 TokenList temp2(files);
2126 temp2.push_back(new Token(temp.cback()->str(), tok->location));
2127
2128 const Token * const tok2 = appendTokens(temp2, loc, tok->next, macros, expandedmacros, parametertokens);
2129 if (!tok2)
2130 return tok->next;
2131 output.takeTokens(temp);
2132 output.deleteToken(output.back());
2133 calledMacro.expand(output, loc, temp2.cfront(), macros, expandedmacros);
2134 return tok2->next;
2135 }
2136
2137 const Token *expandToken(TokenList &output, const Location &loc, const Token *tok, const MacroMap &macros, const std::set<TokenString> &expandedmacros, const std::vector<const Token*> &parametertokens) const {
2138 // Not name..

Callers

nothing calls this directly

Calls 8

functionLikeMethod · 0.80
deleteTokenMethod · 0.80
expandMethod · 0.80
samelineFunction · 0.70
findMethod · 0.45
strMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected