@@ -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 ())
@@ -731,7 +728,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
731728 while (numtok->comment )
732729 numtok = numtok->previous ;
733730 lineDirective (fileIndex (replaceAll (strtok->str ().substr (1U , strtok->str ().size () - 2U )," \\\\ " ," \\ " )),
734- std::atol (numtok->str ().c_str ()), & location);
731+ std::atol (numtok->str ().c_str ()), location);
735732 }
736733 // #line 3
737734 else if (llNextToken->str () == " line" &&
@@ -740,7 +737,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
740737 const Token *numtok = cback ();
741738 while (numtok->comment )
742739 numtok = numtok->previous ;
743- lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), & location);
740+ lineDirective (location.fileIndex , std::atol (numtok->str ().c_str ()), location);
744741 }
745742 }
746743 // #endfile
@@ -1884,7 +1881,7 @@ namespace simplecpp {
18841881 usageList.push_back (loc);
18851882
18861883 if (nameTokInst->str () == " __FILE__" ) {
1887- output.push_back (new Token (' \" ' +loc.file ()+' \" ' , loc));
1884+ output.push_back (new Token (' \" ' +loc.file (output. getFiles () )+' \" ' , loc));
18881885 return nameTokInst->next ;
18891886 }
18901887 if (nameTokInst->str () == " __LINE__" ) {
@@ -2636,7 +2633,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26362633 }
26372634 }
26382635
2639- const std::string &sourcefile = tok->location .file ();
2636+ const std::string &sourcefile = tok->location .file (expr. getFiles () );
26402637 const bool systemheader = (tok1 && tok1->op == ' <' );
26412638 std::string header;
26422639 if (systemheader) {
@@ -3165,7 +3162,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31653162 if (outputList) {
31663163 simplecpp::Output err = {
31673164 simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND,
3168- Location (filenames) ,
3165+ {} ,
31693166 " Can not open include file '" + filename + " ' that is explicitly included."
31703167 };
31713168 outputList->push_back (std::move (err));
@@ -3198,7 +3195,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
31983195 if (!rawtok || rawtok->str () != INCLUDE)
31993196 continue ;
32003197
3201- const std::string &sourcefile = rawtok->location .file ();
3198+ const std::string &sourcefile = rawtok->location .file (filenames );
32023199
32033200 const Token * const htok = rawtok->nextSkipComments ();
32043201 if (!sameline (rawtok, htok))
@@ -3355,7 +3352,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
33553352 if (outputList) {
33563353 simplecpp::Output err = {
33573354 Output::DUI_ERROR,
3358- Location (files) ,
3355+ {} ,
33593356 " unknown standard specified: '" + dui.std + " '"
33603357 };
33613358 outputList->push_back (std::move (err));
@@ -3525,7 +3522,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
35253522
35263523 const bool systemheader = (inctok->str ()[0 ] == ' <' );
35273524 const std::string header (inctok->str ().substr (1U , inctok->str ().size () - 2U ));
3528- const FileData *const filedata = cache.get (rawtok->location .file (), header, dui, systemheader, files, outputList).first ;
3525+ const FileData *const filedata = cache.get (rawtok->location .file (files ), header, dui, systemheader, files, outputList).first ;
35293526 if (filedata == nullptr ) {
35303527 if (outputList) {
35313528 simplecpp::Output out = {
@@ -3618,7 +3615,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36183615 tok = tok->next ;
36193616 bool closingAngularBracket = false ;
36203617 if (tok) {
3621- const std::string &sourcefile = rawtok->location .file ();
3618+ const std::string &sourcefile = rawtok->location .file (files );
36223619 const bool systemheader = (tok && tok->op == ' <' );
36233620 std::string header;
36243621
@@ -3727,7 +3724,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37273724 macros.erase (tok->str ());
37283725 }
37293726 } else if (ifstates.top () == True && rawtok->str () == PRAGMA && rawtok->next && rawtok->next ->str () == ONCE && sameline (rawtok,rawtok->next )) {
3730- pragmaOnce.insert (rawtok->location .file ());
3727+ pragmaOnce.insert (rawtok->location .file (files ));
37313728 }
37323729 if (ifstates.top () != True && rawtok->nextcond )
37333730 rawtok = rawtok->nextcond ->previous ;
@@ -3783,7 +3780,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
37833780 const std::list<Location>& temp = maybeUsedMacros[macro.name ()];
37843781 usage.insert (usage.end (), temp.begin (), temp.end ());
37853782 for (std::list<Location>::const_iterator usageIt = usage.begin (); usageIt != usage.end (); ++usageIt) {
3786- MacroUsage mu (usageIt-> files , macro.valueDefinedInCode ());
3783+ MacroUsage mu (macro.valueDefinedInCode ());
37873784 mu.macroName = macro.name ();
37883785 mu.macroLocation = macro.defineLocation ();
37893786 mu.useLocation = *usageIt;
0 commit comments