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

Method insertTokens

lib/tokenlist.cpp:295–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293//---------------------------------------------------------------------------
294
295void TokenList::insertTokens(Token *dest, const Token *src, nonneg int n)
296{
297 // TODO: put the linking in a helper?
298 std::stack<Token *> link;
299
300 while (n > 0) {
301 if (!src)
302 throw InternalError(dest, std::string(__func__) + ": invalid source range", InternalError::INTERNAL);
303 dest->insertToken(src->str(), src->originalName());
304 dest = dest->next();
305
306 // Set links
307 if (Token::Match(dest, "(|[|{"))
308 link.push(dest);
309 else if (!link.empty() && Token::Match(dest, ")|]|}")) {
310 Token::createMutualLinks(dest, link.top());
311 link.pop();
312 }
313
314 dest->fileIndex(src->fileIndex());
315 dest->linenr(src->linenr());
316 dest->column(src->column());
317 dest->varId(src->varId());
318 dest->tokType(src->tokType());
319 dest->flags(src->flags());
320 if (!src->getMacroName().empty())
321 dest->setMacroName(src->getMacroName());
322 src = src->next();
323 --n;
324 }
325}
326
327//---------------------------------------------------------------------------
328

Callers

nothing calls this directly

Calls 6

insertTokenMethod · 0.80
nextMethod · 0.80
fileIndexMethod · 0.80
columnMethod · 0.80
strMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected