@@ -153,7 +153,7 @@ static unsigned long long stringToULL(const std::string &s)
153153 return ret;
154154}
155155
156- // TODO: added an undercore since this conflicts with a function of the same name in utils.h from Cppcheck source when building Cppcheck with MSBuild
156+ // TODO: added an undercore since this conflicts with a function of the same name in utils.h from Cppcheck source when building Cppcheck with MSBuild
157157static bool startsWith_ (const std::string &s, const std::string &p)
158158{
159159 return (s.size () >= p.size ()) && std::equal (p.begin (), p.end (), s.begin ());
@@ -3391,7 +3391,7 @@ std::map<std::string, simplecpp::TokenList*> simplecpp::load(const simplecpp::To
33913391 return ret;
33923392}
33933393
3394- static bool preprocessToken (simplecpp::TokenList &output, const simplecpp::Token **tok1, simplecpp::MacroMap ¯os, std::vector<std::string> &files, simplecpp::OutputList *outputList)
3394+ static bool preprocessToken (simplecpp::TokenList &output, const simplecpp::Token **tok1, simplecpp::MacroMap ¯os, std::vector<std::string> &files, simplecpp::OutputList *outputList, const simplecpp::DUI &dui )
33953395{
33963396 const simplecpp::Token * const tok = *tok1;
33973397 const simplecpp::MacroMap::const_iterator it = macros.find (tok->str ());
@@ -3411,7 +3411,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
34113411 }
34123412 output.takeTokens (value);
34133413 } else {
3414- if (!tok->comment )
3414+ if (!dui. removeComments || ! tok->comment )
34153415 output.push_back (new simplecpp::Token (*tok));
34163416 *tok1 = tok->next ;
34173417 }
@@ -3624,7 +3624,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
36243624 TokenList inc2 (files);
36253625 if (!inc1.empty () && inc1.cfront ()->name ) {
36263626 const Token *inctok = inc1.cfront ();
3627- if (!preprocessToken (inc2, &inctok, macros, files, outputList)) {
3627+ if (!preprocessToken (inc2, &inctok, macros, files, outputList, dui )) {
36283628 output.clear ();
36293629 return ;
36303630 }
@@ -3800,7 +3800,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
38003800 maybeUsedMacros[rawtok->next ->str ()].push_back (rawtok->next ->location );
38013801
38023802 const Token *tmp = tok;
3803- if (!preprocessToken (expr, &tmp, macros, files, outputList)) {
3803+ if (!preprocessToken (expr, &tmp, macros, files, outputList, dui )) {
38043804 output.clear ();
38053805 return ;
38063806 }
@@ -3885,7 +3885,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
38853885 const Location loc (rawtok->location );
38863886 TokenList tokens (files);
38873887
3888- if (!preprocessToken (tokens, &rawtok, macros, files, outputList)) {
3888+ if (!preprocessToken (tokens, &rawtok, macros, files, outputList, dui )) {
38893889 output.clear ();
38903890 return ;
38913891 }
0 commit comments