@@ -377,17 +377,17 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0)
377377 simplecpp::OutputList outputList;
378378 simplecpp::TokenList tokens (code, mFiles , file0, &outputList);
379379
380- createTokens (& tokens);
380+ createTokens (std::move ( tokens) );
381381
382382 return outputList.empty ();
383383}
384384
385385// ---------------------------------------------------------------------------
386386
387- void TokenList::createTokens (const simplecpp::TokenList * tokenList)
387+ void TokenList::createTokens (simplecpp::TokenList&& tokenList)
388388{
389- if (tokenList-> cfront ())
390- mOrigFiles = mFiles = tokenList-> cfront ()->location .files ;
389+ if (tokenList. cfront ())
390+ mOrigFiles = mFiles = tokenList. cfront ()->location .files ;
391391 else
392392 mFiles .clear ();
393393
@@ -401,7 +401,7 @@ void TokenList::createTokens(const simplecpp::TokenList *tokenList)
401401 mIsCpp = (mSettings ->enforcedLang == Settings::CPP);
402402 }
403403
404- for (const simplecpp::Token *tok = tokenList-> cfront (); tok; tok = tok-> next ) {
404+ for (const simplecpp::Token *tok = tokenList. cfront (); tok;) {
405405
406406 std::string str = tok->str ();
407407
@@ -423,6 +423,10 @@ void TokenList::createTokens(const simplecpp::TokenList *tokenList)
423423 mTokensFrontBack .back ->linenr (tok->location .line );
424424 mTokensFrontBack .back ->column (tok->location .col );
425425 mTokensFrontBack .back ->isExpandedMacro (!tok->macro .empty ());
426+
427+ tok = tok->next ;
428+ if (tok)
429+ tokenList.deleteToken (tok->previous );
426430 }
427431
428432 if (mSettings && mSettings ->relativePaths ) {
0 commit comments