Skip to content

Commit a4dd8f0

Browse files
committed
modernize, use nullptr
1 parent 2d23ee2 commit a4dd8f0

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

lib/checkstl.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,24 @@ void CheckStl::iterators()
117117

118118
// the validIterator flag says if the iterator has a valid value or not
119119
bool validIterator = Token::Match(var->nameToken()->next(), "[(=:]");
120-
const Scope* invalidationScope = 0;
120+
const Scope* invalidationScope = nullptr;
121121

122122
// The container this iterator can be used with
123-
const Variable* container = 0;
124-
const Scope* containerAssignScope = 0;
123+
const Variable* container = nullptr;
124+
const Scope* containerAssignScope = nullptr;
125125

126126
// When "validatingToken" is reached the validIterator is set to true
127-
const Token* validatingToken = 0;
127+
const Token* validatingToken = nullptr;
128128

129-
const Token* eraseToken = 0;
129+
const Token* eraseToken = nullptr;
130130

131131
// Scan through the rest of the code and see if the iterator is
132132
// used against other containers.
133133
for (const Token *tok2 = var->nameToken(); tok2 && tok2 != var->scope()->classEnd; tok2 = tok2->next()) {
134134
if (invalidationScope && tok2 == invalidationScope->classEnd)
135135
validIterator = true; // Assume that the iterator becomes valid again
136136
if (containerAssignScope && tok2 == containerAssignScope->classEnd)
137-
container = 0; // We don't know which containers might be used with the iterator
137+
container = nullptr; // We don't know which containers might be used with the iterator
138138

139139
if (tok2 == validatingToken)
140140
validIterator = true;
@@ -550,15 +550,15 @@ void CheckStl::pushback()
550550
// the variable id for the vector
551551
unsigned int vectorid = 0;
552552

553-
const Token* validatingToken = 0;
553+
const Token* validatingToken = nullptr;
554554

555555
std::string invalidIterator;
556556
const Token* end2 = var->scope()->classEnd;
557557
for (const Token *tok2 = var->nameToken(); tok2 != end2; tok2 = tok2->next()) {
558558

559559
if (validatingToken == tok2) {
560560
invalidIterator.clear();
561-
validatingToken = 0;
561+
validatingToken = nullptr;
562562
}
563563

564564
// Using push_back or push_front inside a loop..
@@ -576,7 +576,7 @@ void CheckStl::pushback()
576576
const Token *tok3 = tok2->tokAt(20);
577577
for (const Token* const end3 = tok3->linkAt(-1); tok3 != end3; tok3 = tok3->next()) {
578578
if (tok3->str() == "break" || tok3->str() == "return") {
579-
pushbackTok = 0;
579+
pushbackTok = nullptr;
580580
break;
581581
} else if (Token::Match(tok3, "%varid% . push_front|push_back|insert|reserve|resize|clear|erase (", varId) && !tok3->previous()->isAssignmentOp()) {
582582
if (tok3->strAt(2) != "erase" || (tok3->tokAt(4)->varId() != iteratorId && tok3->tokAt(5)->varId() != iteratorId)) // This case is handled in: CheckStl::iterators()
@@ -932,9 +932,9 @@ void CheckStl::missingComparison()
932932
else if (Token::Match(tok3->previous(), "++ %varid% !!.", iteratorId))
933933
incrementToken = tok3;
934934
else if (Token::Match(tok3, "%varid% !=|==", iteratorId))
935-
incrementToken = 0;
935+
incrementToken = nullptr;
936936
else if (tok3->str() == "break" || tok3->str() == "return")
937-
incrementToken = 0;
937+
incrementToken = nullptr;
938938
else if (Token::Match(tok3, "%varid% = %name% . insert ( ++| %varid% ++| ,", iteratorId)) {
939939
// skip insertion..
940940
tok3 = tok3->linkAt(6);
@@ -1440,12 +1440,12 @@ void CheckStl::checkDereferenceInvalidIterator()
14401440
// Only consider conditions composed of all "&&" terms and
14411441
// conditions composed of all "||" terms
14421442
const bool isOrExpression =
1443-
Token::findsimplematch(startOfCondition, "||", endOfCondition) != 0;
1443+
Token::findsimplematch(startOfCondition, "||", endOfCondition) != nullptr;
14441444
const bool isAndExpression =
1445-
Token::findsimplematch(startOfCondition, "&&", endOfCondition) != 0;
1445+
Token::findsimplematch(startOfCondition, "&&", endOfCondition) != nullptr;
14461446

14471447
// Look for a check of the validity of an iterator
1448-
const Token* validityCheckTok = 0;
1448+
const Token* validityCheckTok = nullptr;
14491449
if (!isOrExpression && isAndExpression) {
14501450
validityCheckTok =
14511451
Token::findmatch(startOfCondition, "&& %var% != %name% . end|rend|cend|crend ( )", endOfCondition);

0 commit comments

Comments
 (0)