Skip to content

Commit f844662

Browse files
committed
fixed misc-const-correctness clang-tidy warnings
1 parent 80dd40b commit f844662

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

simplecpp.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ void simplecpp::TokenList::constFoldLogicalOp(Token *tok)
13291329
void simplecpp::TokenList::constFoldQuestionOp(Token **tok1)
13301330
{
13311331
bool gotoTok1 = false;
1332-
for (Token *tok = *tok1; tok && tok->op != ')'; tok = gotoTok1 ? *tok1 : tok->next) {
1332+
for (const Token *tok = *tok1; tok && tok->op != ')'; tok = gotoTok1 ? *tok1 : tok->next) {
13331333
gotoTok1 = false;
13341334
if (tok->str() != "?")
13351335
continue;
@@ -1898,7 +1898,7 @@ namespace simplecpp {
18981898
}
18991899
}
19001900

1901-
Token * const output_end_1 = output->back();
1901+
const Token * const output_end_1 = output->back();
19021902

19031903
// expand
19041904
for (const Token *tok = valueToken; tok != endToken;) {
@@ -2207,7 +2207,7 @@ namespace simplecpp {
22072207
const bool canBeConcatenatedStringOrChar = isStringLiteral_(A->str()) || isCharLiteral_(A->str());
22082208
const bool unexpectedA = (!A->name && !A->number && !A->str().empty() && !canBeConcatenatedWithEqual && !canBeConcatenatedStringOrChar);
22092209

2210-
Token * const B = tok->next->next;
2210+
const Token * const B = tok->next->next;
22112211
if (!B->name && !B->number && B->op && !B->isOneOf("#="))
22122212
throw invalidHashHash::unexpectedToken(tok->location, name(), B);
22132213

@@ -2640,11 +2640,11 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
26402640
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
26412641
if (tok->str() != "sizeof")
26422642
continue;
2643-
simplecpp::Token *tok1 = tok->next;
2643+
const simplecpp::Token *tok1 = tok->next;
26442644
if (!tok1) {
26452645
throw std::runtime_error("missing sizeof argument");
26462646
}
2647-
simplecpp::Token *tok2 = tok1->next;
2647+
const simplecpp::Token *tok2 = tok1->next;
26482648
if (!tok2) {
26492649
throw std::runtime_error("missing sizeof argument");
26502650
}
@@ -2659,7 +2659,7 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
26592659
}
26602660

26612661
std::string type;
2662-
for (simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next) {
2662+
for (const simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next) {
26632663
if ((typeToken->str() == "unsigned" || typeToken->str() == "signed") && typeToken->next->name)
26642664
continue;
26652665
if (typeToken->str() == "*" && type.find('*') != std::string::npos)
@@ -2766,11 +2766,11 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
27662766
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
27672767
if (tok->str() != HAS_INCLUDE)
27682768
continue;
2769-
simplecpp::Token *tok1 = tok->next;
2769+
const simplecpp::Token *tok1 = tok->next;
27702770
if (!tok1) {
27712771
throw std::runtime_error("missing __has_include argument");
27722772
}
2773-
simplecpp::Token *tok2 = tok1->next;
2773+
const simplecpp::Token *tok2 = tok1->next;
27742774
if (!tok2) {
27752775
throw std::runtime_error("missing __has_include argument");
27762776
}
@@ -2788,7 +2788,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
27882788
const bool systemheader = (tok1 && tok1->op == '<');
27892789
std::string header;
27902790
if (systemheader) {
2791-
simplecpp::Token *tok3 = tok1->next;
2791+
const simplecpp::Token *tok3 = tok1->next;
27922792
if (!tok3) {
27932793
throw std::runtime_error("missing __has_include closing angular bracket");
27942794
}
@@ -2799,7 +2799,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
27992799
}
28002800
}
28012801

2802-
for (simplecpp::Token *headerToken = tok1->next; headerToken != tok3; headerToken = headerToken->next)
2802+
for (const simplecpp::Token *headerToken = tok1->next; headerToken != tok3; headerToken = headerToken->next)
28032803
header += headerToken->str();
28042804
// cppcheck-suppress selfAssignment - platform-dependent implementation
28052805
header = realFilename(header);

0 commit comments

Comments
 (0)