Skip to content

Commit 5e8b5b8

Browse files
committed
mitigated misc-const-correctness clang-tidy warnings
1 parent a2a65b8 commit 5e8b5b8

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

simplecpp.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,7 @@ void simplecpp::TokenList::constFoldLogicalOp(Token *tok)
13291329
void simplecpp::TokenList::constFoldQuestionOp(Token **tok1)
13301330
{
13311331
bool gotoTok1 = false;
1332+
// NOLINTNEXTLINE(misc-const-correctness) - technically correct but used to access non-cost data
13321333
for (Token *tok = *tok1; tok && tok->op != ')'; tok = gotoTok1 ? *tok1 : tok->next) {
13331334
gotoTok1 = false;
13341335
if (tok->str() != "?")
@@ -1945,6 +1946,7 @@ namespace simplecpp {
19451946
}
19461947
}
19471948

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

19501952
const Token *valueToken2;
@@ -2250,7 +2252,7 @@ namespace simplecpp {
22502252
const bool canBeConcatenatedStringOrChar = isStringLiteral_(A->str()) || isCharLiteral_(A->str());
22512253
const bool unexpectedA = (!A->name && !A->number && !A->str().empty() && !canBeConcatenatedWithEqual && !canBeConcatenatedStringOrChar);
22522254

2253-
Token * const B = tok->next->next;
2255+
const Token * const B = tok->next->next;
22542256
if (!B->name && !B->number && B->op && !B->isOneOf("#="))
22552257
throw invalidHashHash::unexpectedToken(tok->location, name(), B);
22562258

@@ -2528,11 +2530,11 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
25282530
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
25292531
if (tok->str() != "sizeof")
25302532
continue;
2531-
simplecpp::Token *tok1 = tok->next;
2533+
const simplecpp::Token *tok1 = tok->next;
25322534
if (!tok1) {
25332535
throw std::runtime_error("missing sizeof argument");
25342536
}
2535-
simplecpp::Token *tok2 = tok1->next;
2537+
const simplecpp::Token *tok2 = tok1->next;
25362538
if (!tok2) {
25372539
throw std::runtime_error("missing sizeof argument");
25382540
}
@@ -2547,7 +2549,7 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
25472549
}
25482550

25492551
std::string type;
2550-
for (simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next) {
2552+
for (const simplecpp::Token *typeToken = tok1; typeToken != tok2; typeToken = typeToken->next) {
25512553
if ((typeToken->str() == "unsigned" || typeToken->str() == "signed") && typeToken->next->name)
25522554
continue;
25532555
if (typeToken->str() == "*" && type.find('*') != std::string::npos)
@@ -2598,11 +2600,11 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
25982600
for (simplecpp::Token *tok = expr.front(); tok; tok = tok->next) {
25992601
if (tok->str() != HAS_INCLUDE)
26002602
continue;
2601-
simplecpp::Token *tok1 = tok->next;
2603+
const simplecpp::Token *tok1 = tok->next;
26022604
if (!tok1) {
26032605
throw std::runtime_error("missing __has_include argument");
26042606
}
2605-
simplecpp::Token *tok2 = tok1->next;
2607+
const simplecpp::Token *tok2 = tok1->next;
26062608
if (!tok2) {
26072609
throw std::runtime_error("missing __has_include argument");
26082610
}
@@ -2620,7 +2622,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26202622
const bool systemheader = (tok1 && tok1->op == '<');
26212623
std::string header;
26222624
if (systemheader) {
2623-
simplecpp::Token *tok3 = tok1->next;
2625+
const simplecpp::Token *tok3 = tok1->next;
26242626
if (!tok3) {
26252627
throw std::runtime_error("missing __has_include closing angular bracket");
26262628
}
@@ -2631,7 +2633,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
26312633
}
26322634
}
26332635

2634-
for (simplecpp::Token *headerToken = tok1->next; headerToken != tok3; headerToken = headerToken->next)
2636+
for (const simplecpp::Token *headerToken = tok1->next; headerToken != tok3; headerToken = headerToken->next)
26352637
header += headerToken->str();
26362638
} else {
26372639
header = tok1->str().substr(1U, tok1->str().size() - 2U);

0 commit comments

Comments
 (0)