Skip to content

Commit 3d029bb

Browse files
committed
mitigated misc-const-correctness clang-tidy warnings
1 parent 6017026 commit 3d029bb

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

simplecpp.cpp

Lines changed: 10 additions & 9 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;
@@ -1943,6 +1943,7 @@ namespace simplecpp {
19431943
}
19441944
}
19451945

1946+
// NOLINTNEXTLINE(misc-const-correctness) - technically correct but used to access non-cost data
19461947
Token * const output_end_1 = output.back();
19471948

19481949
const Token *valueToken2;
@@ -2248,7 +2249,7 @@ namespace simplecpp {
22482249
const bool canBeConcatenatedStringOrChar = isStringLiteral_(A->str()) || isCharLiteral_(A->str());
22492250
const bool unexpectedA = (!A->name && !A->number && !A->str().empty() && !canBeConcatenatedWithEqual && !canBeConcatenatedStringOrChar);
22502251

2251-
Token * const B = tok->next->next;
2252+
const Token * const B = tok->next->next;
22522253
if (!B->name && !B->number && B->op && !B->isOneOf("#="))
22532254
throw invalidHashHash::unexpectedToken(tok->location, name(), B);
22542255

@@ -2526,11 +2527,11 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
25262527
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
25272528
if (tok->str() != "sizeof")
25282529
continue;
2529-
simplecpp::Token *tok1 = tok->next;
2530+
const simplecpp::Token *tok1 = tok->next;
25302531
if (!tok1) {
25312532
throw std::runtime_error("missing sizeof argument");
25322533
}
2533-
simplecpp::Token *tok2 = tok1->next;
2534+
const simplecpp::Token *tok2 = tok1->next;
25342535
if (!tok2) {
25352536
throw std::runtime_error("missing sizeof argument");
25362537
}
@@ -2545,7 +2546,7 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
25452546
}
25462547

25472548
std::string type;
2548-
for (simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next) {
2549+
for (const simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next) {
25492550
if ((typeToken->str() == "unsigned" || typeToken->str() == "signed") && typeToken->next->name)
25502551
continue;
25512552
if (typeToken->str() == "*" && type.find('*') != std::string::npos)
@@ -2596,11 +2597,11 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
25962597
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
25972598
if (tok->str() != HAS_INCLUDE)
25982599
continue;
2599-
simplecpp::Token *tok1 = tok->next;
2600+
const simplecpp::Token *tok1 = tok->next;
26002601
if (!tok1) {
26012602
throw std::runtime_error("missing __has_include argument");
26022603
}
2603-
simplecpp::Token *tok2 = tok1->next;
2604+
const simplecpp::Token *tok2 = tok1->next;
26042605
if (!tok2) {
26052606
throw std::runtime_error("missing __has_include argument");
26062607
}
@@ -2618,7 +2619,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26182619
const bool systemheader = (tok1 && tok1->op == '<');
26192620
std::string header;
26202621
if (systemheader) {
2621-
simplecpp::Token *tok3 = tok1->next;
2622+
const simplecpp::Token *tok3 = tok1->next;
26222623
if (!tok3) {
26232624
throw std::runtime_error("missing __has_include closing angular bracket");
26242625
}
@@ -2629,7 +2630,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26292630
}
26302631
}
26312632

2632-
for (simplecpp::Token *headerToken = tok1->next; headerToken != tok3; headerToken = headerToken->next)
2633+
for (const simplecpp::Token *headerToken = tok1->next; headerToken != tok3; headerToken = headerToken->next)
26332634
header += headerToken->str();
26342635
} else {
26352636
header = tok1->str().substr(1U, tok1->str().size() - 2U);

0 commit comments

Comments
 (0)