@@ -65,8 +65,9 @@ Directive::DirectiveToken::DirectiveToken(const simplecpp::Token & _tok) :
6565
6666char  Preprocessor::macroChar = char (1 );
6767
68- Preprocessor::Preprocessor (const  Settings& settings, ErrorLogger &errorLogger, Standards::Language lang)
69-     : mSettings(settings)
68+ Preprocessor::Preprocessor (simplecpp::TokenList& tokens, const  Settings& settings, ErrorLogger &errorLogger, Standards::Language lang)
69+     : mTokens(tokens)
70+     , mSettings(settings)
7071    , mErrorLogger(errorLogger)
7172    , mLang(lang)
7273{
@@ -301,12 +302,12 @@ static void addInlineSuppressions(const simplecpp::TokenList &tokens, const Sett
301302        bad.emplace_back (suppr.fileName , suppr.lineNumber , " Suppress Begin: No matching end" 
302303}
303304
304- void  Preprocessor::inlineSuppressions (const  simplecpp::TokenList &tokens,  SuppressionList &suppressions)
305+ void  Preprocessor::inlineSuppressions (SuppressionList &suppressions)
305306{
306307    if  (!mSettings .inlineSuppressions )
307308        return ;
308309    std::list<BadInlineSuppression> err;
309-     ::addInlineSuppressions (tokens , mSettings , suppressions, err);
310+     ::addInlineSuppressions (mTokens , mSettings , suppressions, err);
310311    for  (const  auto  &filedata : mFileCache ) {
311312        ::addInlineSuppressions (filedata->tokens, mSettings , suppressions, err);
312313    }
@@ -315,24 +316,24 @@ void Preprocessor::inlineSuppressions(const simplecpp::TokenList &tokens, Suppre
315316    }
316317}
317318
318- std::vector<RemarkComment> Preprocessor::getRemarkComments (const  simplecpp::TokenList &tokens ) const 
319+ std::vector<RemarkComment> Preprocessor::getRemarkComments () const 
319320{
320321    std::vector<RemarkComment> ret;
321-     addRemarkComments (tokens , ret);
322+     addRemarkComments (mTokens , ret);
322323    for  (const  auto  &filedata : mFileCache ) {
323324        addRemarkComments (filedata->tokens , ret);
324325    }
325326    return  ret;
326327}
327328
328- std::list<Directive> Preprocessor::createDirectives (const  simplecpp::TokenList &tokens ) const 
329+ std::list<Directive> Preprocessor::createDirectives () const 
329330{
330331    //  directive list..
331332    std::list<Directive> directives;
332333
333334    std::vector<const  simplecpp::TokenList *> list;
334335    list.reserve (1U  + mFileCache .size ());
335-     list.push_back (&tokens );
336+     list.push_back (&mTokens );
336337    std::transform (mFileCache .cbegin (), mFileCache .cend (), std::back_inserter (list),
337338                   [](const  std::unique_ptr<simplecpp::FileData> &filedata) {
338339        return  &filedata->tokens ;
@@ -656,15 +657,15 @@ static void getConfigs(const simplecpp::TokenList &tokens, std::set<std::string>
656657}
657658
658659
659- std::set<std::string> Preprocessor::getConfigs (const  simplecpp::TokenList &tokens ) const 
660+ std::set<std::string> Preprocessor::getConfigs () const 
660661{
661662    std::set<std::string> ret = { " " 
662-     if  (!tokens .cfront ())
663+     if  (!mTokens .cfront ())
663664        return  ret;
664665
665666    std::set<std::string> defined  = { " __cplusplus" 
666667
667-     ::getConfigs (tokens , defined , mSettings .userDefines, mSettings .userUndefs, ret);
668+     ::getConfigs (mTokens , defined , mSettings .userDefines, mSettings .userUndefs, ret);
668669
669670    for  (const  auto  &filedata : mFileCache ) {
670671        if  (!mSettings .configurationExcluded (filedata->filename ))
@@ -774,53 +775,53 @@ void Preprocessor::handleErrors(const simplecpp::OutputList& outputList, bool th
774775    }
775776}
776777
777- bool  Preprocessor::loadFiles (const  simplecpp::TokenList &rawtokens,  std::vector<std::string> &files)
778+ bool  Preprocessor::loadFiles (std::vector<std::string> &files)
778779{
779780    const  simplecpp::DUI dui = createDUI (mSettings , " " mLang );
780781
781782    simplecpp::OutputList outputList;
782-     mFileCache  = simplecpp::load (rawtokens , files, dui, &outputList);
783+     mFileCache  = simplecpp::load (mTokens , files, dui, &outputList);
783784    handleErrors (outputList, false );
784785    return  !hasErrors (outputList);
785786}
786787
787- void  Preprocessor::removeComments (simplecpp::TokenList &tokens)  const 
788+ void  Preprocessor::removeComments () 
788789{
789-     tokens .removeComments ();
790+     mTokens .removeComments ();
790791    for  (const  auto  &filedata : mFileCache ) {
791792        filedata->tokens .removeComments ();
792793    }
793794}
794795
795- void  Preprocessor::setPlatformInfo (simplecpp::TokenList &tokens,  const  Settings& settings )
796+ void  Preprocessor::setPlatformInfo ()
796797{
797-     tokens .sizeOfType [" bool" settings .platform .sizeof_bool ;
798-     tokens .sizeOfType [" short" settings .platform .sizeof_short ;
799-     tokens .sizeOfType [" int" settings .platform .sizeof_int ;
800-     tokens .sizeOfType [" long" settings .platform .sizeof_long ;
801-     tokens .sizeOfType [" long long" settings .platform .sizeof_long_long ;
802-     tokens .sizeOfType [" float" settings .platform .sizeof_float ;
803-     tokens .sizeOfType [" double" settings .platform .sizeof_double ;
804-     tokens .sizeOfType [" long double" settings .platform .sizeof_long_double ;
805-     tokens .sizeOfType [" bool *" settings .platform .sizeof_pointer ;
806-     tokens .sizeOfType [" short *" settings .platform .sizeof_pointer ;
807-     tokens .sizeOfType [" int *" settings .platform .sizeof_pointer ;
808-     tokens .sizeOfType [" long *" settings .platform .sizeof_pointer ;
809-     tokens .sizeOfType [" long long *" settings .platform .sizeof_pointer ;
810-     tokens .sizeOfType [" float *" settings .platform .sizeof_pointer ;
811-     tokens .sizeOfType [" double *" settings .platform .sizeof_pointer ;
812-     tokens .sizeOfType [" long double *" settings .platform .sizeof_pointer ;
798+     mTokens .sizeOfType [" bool" mSettings .platform .sizeof_bool ;
799+     mTokens .sizeOfType [" short" mSettings .platform .sizeof_short ;
800+     mTokens .sizeOfType [" int" mSettings .platform .sizeof_int ;
801+     mTokens .sizeOfType [" long" mSettings .platform .sizeof_long ;
802+     mTokens .sizeOfType [" long long" mSettings .platform .sizeof_long_long ;
803+     mTokens .sizeOfType [" float" mSettings .platform .sizeof_float ;
804+     mTokens .sizeOfType [" double" mSettings .platform .sizeof_double ;
805+     mTokens .sizeOfType [" long double" mSettings .platform .sizeof_long_double ;
806+     mTokens .sizeOfType [" bool *" mSettings .platform .sizeof_pointer ;
807+     mTokens .sizeOfType [" short *" mSettings .platform .sizeof_pointer ;
808+     mTokens .sizeOfType [" int *" mSettings .platform .sizeof_pointer ;
809+     mTokens .sizeOfType [" long *" mSettings .platform .sizeof_pointer ;
810+     mTokens .sizeOfType [" long long *" mSettings .platform .sizeof_pointer ;
811+     mTokens .sizeOfType [" float *" mSettings .platform .sizeof_pointer ;
812+     mTokens .sizeOfType [" double *" mSettings .platform .sizeof_pointer ;
813+     mTokens .sizeOfType [" long double *" mSettings .platform .sizeof_pointer ;
813814}
814815
815- simplecpp::TokenList Preprocessor::preprocess (const  simplecpp::TokenList &tokens1,  const   std::string &cfg, std::vector<std::string> &files, bool  throwError)
816+ simplecpp::TokenList Preprocessor::preprocess (const  std::string &cfg, std::vector<std::string> &files, bool  throwError)
816817{
817818    const  simplecpp::DUI dui = createDUI (mSettings , cfg, mLang );
818819
819820    simplecpp::OutputList outputList;
820821    std::list<simplecpp::MacroUsage> macroUsage;
821822    std::list<simplecpp::IfCond> ifCond;
822823    simplecpp::TokenList tokens2 (files);
823-     simplecpp::preprocess (tokens2, tokens1 , files, mFileCache , dui, &outputList, ¯oUsage, &ifCond);
824+     simplecpp::preprocess (tokens2, mTokens , files, mFileCache , dui, &outputList, ¯oUsage, &ifCond);
824825    mMacroUsage  = std::move (macroUsage);
825826    mIfCond  = std::move (ifCond);
826827
@@ -831,9 +832,9 @@ simplecpp::TokenList Preprocessor::preprocess(const simplecpp::TokenList &tokens
831832    return  tokens2;
832833}
833834
834- std::string Preprocessor::getcode (const  simplecpp::TokenList &tokens1,  const   std::string &cfg, std::vector<std::string> &files, const  bool  writeLocations)
835+ std::string Preprocessor::getcode (const  std::string &cfg, std::vector<std::string> &files, const  bool  writeLocations)
835836{
836-     simplecpp::TokenList tokens2 = preprocess (tokens1,  cfg, files, false );
837+     simplecpp::TokenList tokens2 = preprocess (cfg, files, false );
837838    unsigned  int  prevfile = 0 ;
838839    unsigned  int  line = 1 ;
839840    std::ostringstream ret;
@@ -929,7 +930,9 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
929930
930931void  Preprocessor::getErrorMessages (ErrorLogger &errorLogger, const  Settings &settings)
931932{
932-     Preprocessor preprocessor (settings, errorLogger, Standards::Language::CPP);
933+     std::vector<std::string> files;
934+     simplecpp::TokenList tokens (files);
935+     Preprocessor preprocessor (tokens, settings, errorLogger, Standards::Language::CPP);
933936    preprocessor.missingInclude (" " 1 , " " 
934937    preprocessor.missingInclude (" " 1 , " " 
935938    preprocessor.error (" " 1 , " #error message" //  #error ..
@@ -971,10 +974,10 @@ void Preprocessor::dump(std::ostream &out) const
971974    }
972975}
973976
974- std::size_t  Preprocessor::calculateHash (const  simplecpp::TokenList &tokens1,  const   std::string &toolinfo) const 
977+ std::size_t  Preprocessor::calculateHash (const  std::string &toolinfo) const 
975978{
976979    std::string hashData = toolinfo;
977-     for  (const  simplecpp::Token *tok = tokens1 .cfront (); tok; tok = tok->next ) {
980+     for  (const  simplecpp::Token *tok = mTokens .cfront (); tok; tok = tok->next ) {
978981        if  (!tok->comment ) {
979982            hashData += tok->str ();
980983            hashData += static_cast <char >(tok->location .line );
@@ -993,9 +996,9 @@ std::size_t Preprocessor::calculateHash(const simplecpp::TokenList &tokens1, con
993996    return  (std::hash<std::string>{})(hashData);
994997}
995998
996- void  Preprocessor::simplifyPragmaAsm (simplecpp::TokenList &tokenList)  const 
999+ void  Preprocessor::simplifyPragmaAsm () 
9971000{
998-     Preprocessor::simplifyPragmaAsmPrivate (tokenList );
1001+     Preprocessor::simplifyPragmaAsmPrivate (mTokens );
9991002    for  (const  auto  &filedata : mFileCache ) {
10001003        Preprocessor::simplifyPragmaAsmPrivate (filedata->tokens );
10011004    }
0 commit comments