@@ -422,7 +422,7 @@ class FileStream : public simplecpp::TokenList::Stream {
422422 {
423423 if (!file) {
424424 files.push_back (filename);
425- throw simplecpp::Output (simplecpp::Output::FILE_NOT_FOUND, simplecpp::Location (files) , " File is missing: " + filename);
425+ throw simplecpp::Output (simplecpp::Output::FILE_NOT_FOUND, {} , " File is missing: " + filename);
426426 }
427427 init ();
428428 }
@@ -564,11 +564,11 @@ void simplecpp::TokenList::dump(bool linenrs) const
564564std::string simplecpp::TokenList::stringify (bool linenrs) const
565565{
566566 std::ostringstream ret;
567- Location loc (files) ;
567+ Location loc;
568568 bool filechg = true ;
569569 for (const Token *tok = cfront (); tok; tok = tok->next ) {
570570 if (tok->location .line < loc.line || tok->location .fileIndex != loc.fileIndex ) {
571- ret << " \n #line " << tok->location .line << " \" " << tok->location .file () << " \"\n " ;
571+ ret << " \n #line " << tok->location .line << " \" " << tok->location .file (files ) << " \"\n " ;
572572 loc = tok->location ;
573573 filechg = true ;
574574 }
@@ -633,16 +633,16 @@ static bool isStringLiteralPrefix(const std::string &str)
633633 str == " R" || str == " uR" || str == " UR" || str == " LR" || str == " u8R" ;
634634}
635635
636- void simplecpp::TokenList::lineDirective (unsigned int fileIndex, unsigned int line, Location * location)
636+ void simplecpp::TokenList::lineDirective (unsigned int fileIndex, unsigned int line, Location & location)
637637{
638- if (fileIndex != location-> fileIndex || line >= location-> line ) {
639- location-> fileIndex = fileIndex;
640- location-> line = line;
638+ if (fileIndex != location. fileIndex || line >= location. line ) {
639+ location. fileIndex = fileIndex;
640+ location. line = line;
641641 return ;
642642 }
643643
644- if (line + 2 >= location-> line ) {
645- location-> line = line;
644+ if (line + 2 >= location. line ) {
645+ location. line = line;
646646 while (cback ()->op != ' #' )
647647 deleteToken (back ());
648648 deleteToken (back ());
@@ -660,10 +660,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
660660
661661 const Token *oldLastToken = nullptr ;
662662
663- Location location (files);
664- location.fileIndex = fileIndex (filename);
665- location.line = 1U ;
666- location.col = 1U ;
663+ Location location (fileIndex (filename), 1 , 1 );
667664 while (stream.good ()) {
668665 unsigned char ch = stream.readChar ();
669666 if (!stream.good ())
@@ -732,7 +729,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
732729 while (numtok->comment )
733730 numtok = numtok->previous ;
734731 lineDirective (fileIndex (replaceAll (strtok->str ().substr (1U , strtok->str ().size () - 2U )," \\\\ " ," \\ " )),
735- std::atol (numtok->str ().c_str ()), & location);
732+ std::atol (numtok->str ().c_str ()), location);
736733 }
737734 // #line 3
738735 else if (llNextToken->str () == " line" &&
@@ -741,7 +738,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
741738 const Token *numtok = cback ();
742739 while (numtok->comment )
743740 numtok = numtok->previous ;
744- lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), & location);
741+ lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), location);
745742 }
746743 }
747744 // #endfile
@@ -1885,7 +1882,7 @@ namespace simplecpp {
18851882 usageList.push_back (loc);
18861883
18871884 if (nameTokInst->str () == " __FILE__" ) {
1888- output.push_back (new Token (' \" ' +loc.file ()+' \" ' , loc));
1885+ output.push_back (new Token (' \" ' +loc.file (output. getFiles () )+' \" ' , loc));
18891886 return nameTokInst->next ;
18901887 }
18911888 if (nameTokInst->str () == " __LINE__" ) {
@@ -2637,7 +2634,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26372634 }
26382635 }
26392636
2640- const std::string &sourcefile = tok->location .file ();
2637+ const std::string &sourcefile = tok->location .file (expr. getFiles () );
26412638 const bool systemheader = (tok1 && tok1->op == ' <' );
26422639 std::string header;
26432640 if (systemheader) {
@@ -3179,7 +3176,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31793176 if (outputList) {
31803177 simplecpp::Output err = {
31813178 simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND,
3182- Location (filenames) ,
3179+ {} ,
31833180 " Can not open include file '" + filename + " ' that is explicitly included."
31843181 };
31853182 outputList->push_back (std::move (err));
@@ -3212,7 +3209,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
32123209 if (!rawtok || rawtok->str () != INCLUDE)
32133210 continue ;
32143211
3215- const std::string &sourcefile = rawtok->location .file ();
3212+ const std::string &sourcefile = rawtok->location .file (filenames );
32163213
32173214 const Token * const htok = rawtok->nextSkipComments ();
32183215 if (!sameline (rawtok, htok))
@@ -3369,7 +3366,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33693366 if (outputList) {
33703367 simplecpp::Output err = {
33713368 Output::DUI_ERROR,
3372- Location (files) ,
3369+ {} ,
33733370 " unknown standard specified: '" + dui.std + " '"
33743371 };
33753372 outputList->push_back (std::move (err));
@@ -3539,7 +3536,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35393536
35403537 const bool systemheader = (inctok->str ()[0 ] == ' <' );
35413538 const std::string header (inctok->str ().substr (1U , inctok->str ().size () - 2U ));
3542- const FileData *const filedata = cache.get (rawtok->location .file (), header, dui, systemheader, files, outputList).first ;
3539+ const FileData *const filedata = cache.get (rawtok->location .file (files ), header, dui, systemheader, files, outputList).first ;
35433540 if (filedata == nullptr ) {
35443541 if (outputList) {
35453542 simplecpp::Output out = {
@@ -3632,7 +3629,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36323629 tok = tok->next ;
36333630 bool closingAngularBracket = false ;
36343631 if (tok) {
3635- const std::string &sourcefile = rawtok->location .file ();
3632+ const std::string &sourcefile = rawtok->location .file (files );
36363633 const bool systemheader = (tok && tok->op == ' <' );
36373634 std::string header;
36383635
@@ -3740,7 +3737,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37403737 macros.erase (tok->str ());
37413738 }
37423739 } else if (ifstates.top () == True && rawtok->str () == PRAGMA && rawtok->next && rawtok->next ->str () == ONCE && sameline (rawtok,rawtok->next )) {
3743- pragmaOnce.insert (rawtok->location .file ());
3740+ pragmaOnce.insert (rawtok->location .file (files ));
37443741 }
37453742 if (ifstates.top () != True && rawtok->nextcond )
37463743 rawtok = rawtok->nextcond ->previous ;
@@ -3796,7 +3793,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37963793 const std::list<Location>& temp = maybeUsedMacros[macro.name ()];
37973794 usage.insert (usage.end (), temp.begin (), temp.end ());
37983795 for (std::list<Location>::const_iterator usageIt = usage.begin (); usageIt != usage.end (); ++usageIt) {
3799- MacroUsage mu (usageIt-> files , macro.valueDefinedInCode ());
3796+ MacroUsage mu (macro.valueDefinedInCode ());
38003797 mu.macroName = macro.name ();
38013798 mu.macroLocation = macro.defineLocation ();
38023799 mu.useLocation = *usageIt;
0 commit comments