@@ -1317,7 +1317,7 @@ void simplecpp::TokenList::constFoldLogicalOp(Token *tok)
13171317void simplecpp::TokenList::constFoldQuestionOp (Token **tok1)
13181318{
13191319 bool gotoTok1 = false ;
1320- for (Token *tok = *tok1; tok && tok->op != ' )' ; tok = gotoTok1 ? *tok1 : tok->next ) {
1320+ for (const Token *tok = *tok1; tok && tok->op != ' )' ; tok = gotoTok1 ? *tok1 : tok->next ) {
13211321 gotoTok1 = false ;
13221322 if (tok->str () != " ?" )
13231323 continue ;
@@ -1886,7 +1886,7 @@ namespace simplecpp {
18861886 }
18871887 }
18881888
1889- Token * const output_end_1 = output->back ();
1889+ const Token * const output_end_1 = output->back ();
18901890
18911891 // expand
18921892 for (const Token *tok = valueToken; tok != endToken;) {
@@ -2195,7 +2195,7 @@ namespace simplecpp {
21952195 const bool canBeConcatenatedStringOrChar = isStringLiteral_ (A->str ()) || isCharLiteral_ (A->str ());
21962196 const bool unexpectedA = (!A->name && !A->number && !A->str ().empty () && !canBeConcatenatedWithEqual && !canBeConcatenatedStringOrChar);
21972197
2198- Token * const B = tok->next ->next ;
2198+ const Token * const B = tok->next ->next ;
21992199 if (!B->name && !B->number && B->op && !B->isOneOf (" #=" ))
22002200 throw invalidHashHash::unexpectedToken (tok->location , name (), B);
22012201
@@ -2633,11 +2633,11 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
26332633 for (simplecpp::Token *tok = expr.front (); tok; tok = tok->next ) {
26342634 if (tok->str () != " sizeof" )
26352635 continue ;
2636- simplecpp::Token *tok1 = tok->next ;
2636+ const simplecpp::Token *tok1 = tok->next ;
26372637 if (!tok1) {
26382638 throw std::runtime_error (" missing sizeof argument" );
26392639 }
2640- simplecpp::Token *tok2 = tok1->next ;
2640+ const simplecpp::Token *tok2 = tok1->next ;
26412641 if (!tok2) {
26422642 throw std::runtime_error (" missing sizeof argument" );
26432643 }
@@ -2652,7 +2652,7 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
26522652 }
26532653
26542654 std::string type;
2655- for (simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next ) {
2655+ for (const simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next ) {
26562656 if ((typeToken->str () == " unsigned" || typeToken->str () == " signed" ) && typeToken->next ->name )
26572657 continue ;
26582658 if (typeToken->str () == " *" && type.find (' *' ) != std::string::npos)
@@ -2690,11 +2690,11 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26902690 for (simplecpp::Token *tok = expr.front (); tok; tok = tok->next ) {
26912691 if (tok->str () != HAS_INCLUDE)
26922692 continue ;
2693- simplecpp::Token *tok1 = tok->next ;
2693+ const simplecpp::Token *tok1 = tok->next ;
26942694 if (!tok1) {
26952695 throw std::runtime_error (" missing __has_include argument" );
26962696 }
2697- simplecpp::Token *tok2 = tok1->next ;
2697+ const simplecpp::Token *tok2 = tok1->next ;
26982698 if (!tok2) {
26992699 throw std::runtime_error (" missing __has_include argument" );
27002700 }
@@ -2712,7 +2712,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
27122712 const bool systemheader = (tok1 && tok1->op == ' <' );
27132713 std::string header;
27142714 if (systemheader) {
2715- simplecpp::Token *tok3 = tok1->next ;
2715+ const simplecpp::Token *tok3 = tok1->next ;
27162716 if (!tok3) {
27172717 throw std::runtime_error (" missing __has_include closing angular bracket" );
27182718 }
@@ -2723,7 +2723,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
27232723 }
27242724 }
27252725
2726- for (simplecpp::Token *headerToken = tok1->next ; headerToken != tok3; headerToken = headerToken->next )
2726+ for (const simplecpp::Token *headerToken = tok1->next ; headerToken != tok3; headerToken = headerToken->next )
27272727 header += headerToken->str ();
27282728 // cppcheck-suppress selfAssignment - platform-dependent implementation
27292729 header = realFilename (header);
0 commit comments