Skip to content

Commit 8283561

Browse files
committed
fixed misc-const-correctness clang-tidy warnings
1 parent 44e7b76 commit 8283561

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

simplecpp.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ void simplecpp::TokenList::constFoldLogicalOp(Token *tok)
13171317
void 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

@@ -2637,7 +2637,7 @@ static void simplifySizeof(simplecpp::TokenList &expr, const std::map<std::strin
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)
@@ -2694,7 +2694,7 @@ static void simplifyHasInclude(simplecpp::TokenList &expr, const simplecpp::DUI
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

Comments
 (0)