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

Method expandHash

externals/simplecpp/simplecpp.cpp:2279–2294  ·  view source on GitHub ↗

* Expand #X => "X" * @param output destination tokenlist * @param loc location for expanded token * @param tok The # token * @param expandedmacros set with expanded macros, with this macro * @param parametertokens parameters given when expanding this macro * @return token after the X */

Source from the content-addressed store, hash-verified

2277 * @return token after the X
2278 */
2279 const Token *expandHash(TokenList &output, const Location &loc, const Token *tok, const std::set<TokenString> &expandedmacros, const std::vector<const Token*> &parametertokens) const {
2280 TokenList tokenListHash(files);
2281 const MacroMap macros2; // temporarily bypass macro expansion
2282 tok = expandToken(tokenListHash, loc, tok->next, macros2, expandedmacros, parametertokens);
2283 std::ostringstream ostr;
2284 ostr << '\"';
2285 for (const Token *hashtok = tokenListHash.cfront(), *next; hashtok; hashtok = next) {
2286 next = hashtok->next;
2287 ostr << hashtok->str();
2288 if (next && hashtok->whitespaceahead)
2289 ostr << ' ';
2290 }
2291 ostr << '\"';
2292 output.push_back(newMacroToken(escapeString(ostr.str()), loc, isReplaced(expandedmacros)));
2293 return tok;
2294 }
2295
2296 /**
2297 * Expand A##B => AB

Callers

nothing calls this directly

Calls 3

escapeStringFunction · 0.85
strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected