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

Method replace

lib/token.cpp:373–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373void Token::replace(Token *replaceThis, Token *start, Token *end)
374{
375 // Fix the whole in the old location of start and end
376 if (start->previous())
377 start->previous()->next(end->next());
378
379 if (end->next())
380 end->next()->previous(start->previous());
381
382 // Move start and end to their new location
383 if (replaceThis->previous())
384 replaceThis->previous()->next(start);
385
386 if (replaceThis->next())
387 replaceThis->next()->previous(end);
388
389 start->previous(replaceThis->previous());
390 end->next(replaceThis->next());
391
392 if (end->mTokensFrontBack->back == end) {
393 while (end->next())
394 end = end->next();
395 end->mTokensFrontBack->back = end;
396 }
397
398 // Update mProgressValue, fileIndex and linenr
399 for (Token *tok = start; tok != end->next(); tok = tok->next())
400 tok->mImpl->mProgressValue = replaceThis->mImpl->mProgressValue;
401
402 // Delete old token, which is replaced
403 delete replaceThis;
404}
405
406/**
407 * @throws InternalError thrown on unexpected command or missing varid with %varid%

Callers 15

compile_cppcheckFunction · 0.45
parseheaderFunction · 0.45
quoteFunction · 0.45
_replaceCStringsMethod · 0.45
donate-cpu.pyFile · 0.45
triage_version.pyFile · 0.45
lifetimeMessageMethod · 0.45
replaceSpecialCharsFunction · 0.45
replaceFunction · 0.45
replaceStrFunction · 0.45
findAndReplaceFunction · 0.45

Calls 1

nextMethod · 0.80

Tested by 15

__call_processFunction · 0.36
__call_processFunction · 0.36
__copy_cppcheck_premiumFunction · 0.36
test_show_all_definesFunction · 0.36
test_logFunction · 0.36
cppcheck_exFunction · 0.36
test_addon_namingngFunction · 0.36