Merge pull request #241 from lanurmi/more-nullptr

Change some more 0 literals into nullptr.
This commit is contained in:
Daniel Marjamäki 2014-02-16 23:29:23 +01:00
commit d37359217c
21 changed files with 71 additions and 71 deletions

View File

@ -79,7 +79,7 @@ void CheckBufferOverrun::arrayIndexOutOfBoundsError(const Token *tok, const Arra
errmsg << " out of bounds."; errmsg << " out of bounds.";
} }
const Token *condition = 0; const Token *condition = nullptr;
for (unsigned int i = 0; i < index.size(); ++i) { for (unsigned int i = 0; i < index.size(); ++i) {
if (condition == nullptr) if (condition == nullptr)
condition = index[i].condition; condition = index[i].condition;
@ -428,7 +428,7 @@ static bool for3(const Token * const tok,
std::string &max_value, std::string &max_value,
const bool maxMinFlipped) const bool maxMinFlipped)
{ {
assert(tok != 0); assert(tok != nullptr);
if (Token::Match(tok, "%varid% = %num% + %varid% )", varid)) { if (Token::Match(tok, "%varid% = %num% + %varid% )", varid)) {
if (!for_maxvalue(tok->tokAt(2), min_value, max_value)) if (!for_maxvalue(tok->tokAt(2), min_value, max_value))
return false; return false;
@ -1498,7 +1498,7 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
std::string type; std::string type;
// varid : The variable id for the array // varid : The variable id for the array
const Variable *var = 0; const Variable *var = nullptr;
// nextTok : number of tokens used in variable declaration - used to skip to next statement. // nextTok : number of tokens used in variable declaration - used to skip to next statement.
int nextTok = 0; int nextTok = 0;

View File

@ -917,8 +917,8 @@ void CheckClass::checkMemset()
continue; continue;
const Token *typeTok = 0; const Token *typeTok = nullptr;
const Scope *type = 0; const Scope *type = nullptr;
if (Token::Match(arg3, "sizeof ( %type% ) )")) if (Token::Match(arg3, "sizeof ( %type% ) )"))
typeTok = arg3->tokAt(2); typeTok = arg3->tokAt(2);
else if (Token::Match(arg3, "sizeof ( %type% :: %type% ) )")) else if (Token::Match(arg3, "sizeof ( %type% :: %type% ) )"))
@ -1252,7 +1252,7 @@ bool CheckClass::hasAllocation(const Function *func, const Scope* scope)
return true; return true;
// check for deallocating memory // check for deallocating memory
const Token *var = 0; const Token *var = nullptr;
if (Token::Match(tok, "free ( %var%")) if (Token::Match(tok, "free ( %var%"))
var = tok->tokAt(2); var = tok->tokAt(2);
else if (Token::Match(tok, "delete [ ] %var%")) else if (Token::Match(tok, "delete [ ] %var%"))
@ -1395,7 +1395,7 @@ void CheckClass::virtualDestructor()
// Find the destructor declaration for the base class. // Find the destructor declaration for the base class.
const Function *base_destructor = derivedFromScope->getDestructor(); const Function *base_destructor = derivedFromScope->getDestructor();
const Token *base = 0; const Token *base = nullptr;
if (base_destructor) if (base_destructor)
base = base_destructor->token; base = base_destructor->token;

View File

@ -98,7 +98,7 @@ void CheckExceptionSafety::deallocThrow()
const unsigned int varid(tok->varId()); const unsigned int varid(tok->varId());
// Token where throw occurs // Token where throw occurs
const Token *ThrowToken = 0; const Token *ThrowToken = nullptr;
// is there a throw after the deallocation? // is there a throw after the deallocation?
const Token* const end2 = tok->scope()->classEnd; const Token* const end2 = tok->scope()->classEnd;

View File

@ -318,7 +318,7 @@ void CheckIO::invalidScanf()
for (std::size_t j = 0; j < functions; ++j) { for (std::size_t j = 0; j < functions; ++j) {
const Scope * scope = symbolDatabase->functionScopes[j]; const Scope * scope = symbolDatabase->functionScopes[j];
for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) { for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
const Token *formatToken = 0; const Token *formatToken = nullptr;
if (Token::Match(tok, "scanf|vscanf ( %str% ,")) if (Token::Match(tok, "scanf|vscanf ( %str% ,"))
formatToken = tok->tokAt(2); formatToken = tok->tokAt(2);
else if (Token::Match(tok, "sscanf|vsscanf|fscanf|vfscanf (")) { else if (Token::Match(tok, "sscanf|vsscanf|fscanf|vfscanf (")) {
@ -424,7 +424,7 @@ static bool findFormat(unsigned int arg, const Token *firstArg,
argTok->variable()->dimensionKnown(0) && argTok->variable()->dimensionKnown(0) &&
argTok->variable()->dimension(0) != 0)))) { argTok->variable()->dimension(0) != 0)))) {
*formatArgTok = argTok->nextArgument(); *formatArgTok = argTok->nextArgument();
*formatStringTok = 0; *formatStringTok = nullptr;
if (argTok->variable()) { if (argTok->variable()) {
const Token *varTok = argTok->variable()->nameToken(); const Token *varTok = argTok->variable()->nameToken();
if (Token::Match(varTok, "%var% ; %var% = %str% ;") && if (Token::Match(varTok, "%var% ; %var% = %str% ;") &&
@ -1330,7 +1330,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings)
tok = tok->tokAt(2); tok = tok->tokAt(2);
if (!tok || !(tok->type() == Token::eVariable || tok->type() == Token::eFunction)) if (!tok || !(tok->type() == Token::eVariable || tok->type() == Token::eFunction))
return; return;
const Token *varTok = 0; const Token *varTok = nullptr;
const Token *tok1 = tok->next(); const Token *tok1 = tok->next();
for (; tok1; tok1 = tok1->next()) { for (; tok1; tok1 = tok1->next()) {
if (tok1->str() == "," || tok1->str() == ")") { if (tok1->str() == "," || tok1->str() == ")") {

View File

@ -629,7 +629,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
Token *ftok = getcode(func->functionScope->classStart->next(), callstack, 0, alloctype, dealloctype, false, 1); Token *ftok = getcode(func->functionScope->classStart->next(), callstack, 0, alloctype, dealloctype, false, 1);
simplifycode(ftok); simplifycode(ftok);
const char *ret = 0; const char *ret = nullptr;
if (Token::simpleMatch(ftok, "; alloc ; }")) if (Token::simpleMatch(ftok, "; alloc ; }"))
ret = "alloc"; ret = "alloc";
else if (Token::simpleMatch(ftok, "; dealloc ; }")) else if (Token::simpleMatch(ftok, "; dealloc ; }"))
@ -688,7 +688,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
while (func_ && func_->str() == ";") while (func_ && func_->str() == ";")
func_ = func_->next(); func_ = func_->next();
const char *ret = 0; const char *ret = nullptr;
/** @todo handle "goto" */ /** @todo handle "goto" */
if (Token::findsimplematch(func_, "dealloc")) if (Token::findsimplematch(func_, "dealloc"))
ret = "dealloc"; ret = "dealloc";
@ -782,7 +782,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
; ;
else { else {
const Token *skipToToken = 0; const Token *skipToToken = nullptr;
// scan statement for interesting keywords / varid // scan statement for interesting keywords / varid
for (tok2 = tok->next(); tok2; tok2 = tok2->next()) { for (tok2 = tok->next(); tok2; tok2 = tok2->next()) {

View File

@ -629,8 +629,8 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
continue; continue;
// vartok : token for the variable // vartok : token for the variable
const Token *vartok = 0; const Token *vartok = nullptr;
const Token *checkConditionStart = 0; const Token *checkConditionStart = nullptr;
if (Token::Match(tok, "( ! %var% )|&&")) { if (Token::Match(tok, "( ! %var% )|&&")) {
vartok = tok->tokAt(2); vartok = tok->tokAt(2);
checkConditionStart = vartok->next(); checkConditionStart = vartok->next();
@ -892,7 +892,7 @@ void CheckNullPointer::nullConstantDereference()
} }
} }
const Variable *ovar = 0; const Variable *ovar = nullptr;
if (Token::Match(tok, "0 ==|!= %var% !!.")) if (Token::Match(tok, "0 ==|!= %var% !!."))
ovar = tok->tokAt(2)->variable(); ovar = tok->tokAt(2)->variable();
else if (Token::Match(tok, "%var% ==|!= 0")) else if (Token::Match(tok, "%var% ==|!= 0"))

View File

@ -514,7 +514,7 @@ void CheckOther::invalidPointerCast()
continue; continue;
// Find casted variable // Find casted variable
const Variable *var = 0; const Variable *var = nullptr;
bool allocation = false; bool allocation = false;
bool ref = false; bool ref = false;
if (Token::Match(nextTok, "new %type%")) if (Token::Match(nextTok, "new %type%"))

View File

@ -113,7 +113,7 @@ void CheckSizeof::checkSizeofForPointerSize()
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) { for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
const Token *tokVar; const Token *tokVar;
const Token *variable; const Token *variable;
const Token *variable2 = 0; const Token *variable2 = nullptr;
// Find any function that may use sizeof on a pointer // Find any function that may use sizeof on a pointer
// Once leaving those tests, it is mandatory to have: // Once leaving those tests, it is mandatory to have:

View File

@ -655,7 +655,7 @@ void CheckStl::pushback()
if (varId == 0) if (varId == 0)
continue; continue;
const Token *pushbackTok = 0; const Token *pushbackTok = nullptr;
// Count { and } for tok3 // Count { and } for tok3
const Token *tok3 = tok2->tokAt(20); const Token *tok3 = tok2->tokAt(20);
@ -1077,7 +1077,7 @@ void CheckStl::missingComparison()
break; break;
} }
const Token *incrementToken = 0; const Token *incrementToken = nullptr;
// Parse loop.. // Parse loop..
for (const Token *tok3 = i->classStart; tok3 != i->classEnd; tok3 = tok3->next()) { for (const Token *tok3 = i->classStart; tok3 != i->classEnd; tok3 = tok3->next()) {

View File

@ -51,7 +51,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
if (tok->previous() && tok->previous()->str() == ">") if (tok->previous() && tok->previous()->str() == ">")
continue; continue;
const Token *funcname = 0; const Token *funcname = nullptr;
if (Token::Match(tok, "%type% %var% (")) if (Token::Match(tok, "%type% %var% ("))
funcname = tok->next(); funcname = tok->next();
@ -188,7 +188,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
} }
const Token *funcname = 0; const Token *funcname = nullptr;
if (Token::Match(tok->next(), "%var% (")) { if (Token::Match(tok->next(), "%var% (")) {
funcname = tok->next(); funcname = tok->next();

View File

@ -40,7 +40,7 @@ public:
/** Store information about variable usage */ /** Store information about variable usage */
class VariableUsage { class VariableUsage {
public: public:
VariableUsage(const Variable *var = 0, VariableUsage(const Variable *var = nullptr,
VariableType type = standard, VariableType type = standard,
bool read = false, bool read = false,
bool write = false, bool write = false,

View File

@ -449,7 +449,7 @@ void CppCheck::executeRules(const std::string &tokenlist, const Tokenizer &token
if (rule.pattern.empty() || rule.id.empty() || rule.severity.empty() || rule.tokenlist != tokenlist) if (rule.pattern.empty() || rule.id.empty() || rule.severity.empty() || rule.tokenlist != tokenlist)
continue; continue;
const char *error = 0; const char *error = nullptr;
int erroffset = 0; int erroffset = 0;
pcre *re = pcre_compile(rule.pattern.c_str(),0,&error,&erroffset,nullptr); pcre *re = pcre_compile(rule.pattern.c_str(),0,&error,&erroffset,nullptr);
if (!re) { if (!re) {

View File

@ -54,7 +54,7 @@ public:
/** character that is inserted in expanded macros */ /** character that is inserted in expanded macros */
static char macroChar; static char macroChar;
Preprocessor(Settings *settings = 0, ErrorLogger *errorLogger = 0); Preprocessor(Settings *settings = nullptr, ErrorLogger *errorLogger = nullptr);
static bool missingIncludeFlag; static bool missingIncludeFlag;

View File

@ -310,8 +310,8 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
// check if in class or structure // check if in class or structure
else if (scope->type == Scope::eClass || scope->type == Scope::eStruct) { else if (scope->type == Scope::eClass || scope->type == Scope::eStruct) {
const Token *funcStart = 0; const Token *funcStart = nullptr;
const Token *argStart = 0; const Token *argStart = nullptr;
// What section are we in.. // What section are we in..
if (tok->str() == "private:") if (tok->str() == "private:")
@ -558,8 +558,8 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
scope->definedType->friendList.push_back(friendInfo); scope->definedType->friendList.push_back(friendInfo);
} }
} else if (scope->type == Scope::eNamespace || scope->type == Scope::eGlobal) { } else if (scope->type == Scope::eNamespace || scope->type == Scope::eGlobal) {
const Token *funcStart = 0; const Token *funcStart = nullptr;
const Token *argStart = 0; const Token *argStart = nullptr;
// function? // function?
if (isFunction(tok, scope, &funcStart, &argStart)) { if (isFunction(tok, scope, &funcStart, &argStart)) {
@ -2723,7 +2723,7 @@ bool SymbolDatabase::isCPP() const
const Scope *SymbolDatabase::findScope(const Token *tok, const Scope *startScope) const const Scope *SymbolDatabase::findScope(const Token *tok, const Scope *startScope) const
{ {
const Scope *scope = 0; const Scope *scope = nullptr;
// absolute path // absolute path
if (tok->str() == "::") { if (tok->str() == "::") {
tok = tok->next(); tok = tok->next();

View File

@ -846,7 +846,7 @@ Token* Token::nextArgument() const
const Token * Token::findClosingBracket() const const Token * Token::findClosingBracket() const
{ {
const Token *closing = 0; const Token *closing = nullptr;
if (_str == "<") { if (_str == "<") {
unsigned int depth = 0; unsigned int depth = 0;

View File

@ -382,7 +382,7 @@ public:
* @param title Title for the printout or use default parameter or 0 * @param title Title for the printout or use default parameter or 0
* for no title. * for no title.
*/ */
void printOut(const char *title = 0) const; void printOut(const char *title = nullptr) const;
/** /**
* For debugging purposes, prints token and all tokens * For debugging purposes, prints token and all tokens
@ -591,7 +591,7 @@ public:
} }
const ValueFlow::Value * getMaxValue(bool condition) const { const ValueFlow::Value * getMaxValue(bool condition) const {
const ValueFlow::Value *ret = 0; const ValueFlow::Value *ret = nullptr;
std::list<ValueFlow::Value>::const_iterator it; std::list<ValueFlow::Value>::const_iterator it;
for (it = values.begin(); it != values.end(); ++it) { for (it = values.begin(); it != values.end(); ++it) {
if ((!ret || it->intvalue > ret->intvalue) && if ((!ret || it->intvalue > ret->intvalue) &&

View File

@ -603,19 +603,19 @@ void Tokenizer::simplifyTypedef()
Token *typeName; Token *typeName;
std::list<std::string> pointers; std::list<std::string> pointers;
Token *typeStart = 0; Token *typeStart = nullptr;
Token *typeEnd = 0; Token *typeEnd = nullptr;
Token *argStart = 0; Token *argStart = nullptr;
Token *argEnd = 0; Token *argEnd = nullptr;
Token *arrayStart = 0; Token *arrayStart = nullptr;
Token *arrayEnd = 0; Token *arrayEnd = nullptr;
Token *specStart = 0; Token *specStart = nullptr;
Token *specEnd = 0; Token *specEnd = nullptr;
Token *typeDef = tok; Token *typeDef = tok;
Token *argFuncRetStart = 0; Token *argFuncRetStart = nullptr;
Token *argFuncRetEnd = 0; Token *argFuncRetEnd = nullptr;
Token *funcStart = 0; Token *funcStart = nullptr;
Token *funcEnd = 0; Token *funcEnd = nullptr;
Token *tokOffset = tok->next(); Token *tokOffset = tok->next();
bool function = false; bool function = false;
bool functionPtr = false; bool functionPtr = false;
@ -626,8 +626,8 @@ void Tokenizer::simplifyTypedef()
bool refToArray = false; bool refToArray = false;
bool ptrMember = false; bool ptrMember = false;
bool typeOf = false; bool typeOf = false;
Token *namespaceStart = 0; Token *namespaceStart = nullptr;
Token *namespaceEnd = 0; Token *namespaceEnd = nullptr;
// check for invalid input // check for invalid input
if (!tok->next()) { if (!tok->next()) {
@ -4440,7 +4440,7 @@ void Tokenizer::simplifyConditionOperator()
else else
tok->deleteNext(8); tok->deleteNext(8);
Token *starttok = 0; Token *starttok = nullptr;
std::string str; std::string str;
if (isReturn) if (isReturn)
@ -7347,9 +7347,9 @@ void Tokenizer::simplifyEnum()
(!temp->isName() || !Token::Match(temp->next(), "[{:;]"))) (!temp->isName() || !Token::Match(temp->next(), "[{:;]")))
continue; continue;
Token *start = tok; Token *start = tok;
Token *enumType = 0; Token *enumType = nullptr;
Token *typeTokenStart = 0; Token *typeTokenStart = nullptr;
Token *typeTokenEnd = 0; Token *typeTokenEnd = nullptr;
// check for C++0x enum class // check for C++0x enum class
if (Token::Match(tok->next(), "class|struct")) if (Token::Match(tok->next(), "class|struct"))
@ -7965,7 +7965,7 @@ void Tokenizer::eraseDeadCode(Token *begin, const Token *end)
std::vector<unsigned int> switchindents; std::vector<unsigned int> switchindents;
bool checklabel = false; bool checklabel = false;
Token *tok = begin; Token *tok = begin;
Token *tokcheck = 0; Token *tokcheck = nullptr;
while (tok->next() && tok->next() != end) { while (tok->next() && tok->next() != end) {
if (tok->next()->str() == "(") { if (tok->next()->str() == "(") {
++roundbraces; ++roundbraces;
@ -8639,11 +8639,11 @@ void Tokenizer::removeExceptionSpecifications()
bool Tokenizer::validate() const bool Tokenizer::validate() const
{ {
std::stack<const Token *> linktok; std::stack<const Token *> linktok;
const Token *lastTok = 0; const Token *lastTok = nullptr;
for (const Token *tok = tokens(); tok; tok = tok->next()) { for (const Token *tok = tokens(); tok; tok = tok->next()) {
lastTok = tok; lastTok = tok;
if (Token::Match(tok, "[{([]") || (tok->str() == "<" && tok->link())) { if (Token::Match(tok, "[{([]") || (tok->str() == "<" && tok->link())) {
if (tok->link() == 0) { if (tok->link() == nullptr) {
cppcheckError(tok); cppcheckError(tok);
return false; return false;
} }
@ -8652,7 +8652,7 @@ bool Tokenizer::validate() const
} }
else if (Token::Match(tok, "[})]]") || (tok->str() == ">" && tok->link())) { else if (Token::Match(tok, "[})]]") || (tok->str() == ">" && tok->link())) {
if (tok->link() == 0) { if (tok->link() == nullptr) {
cppcheckError(tok); cppcheckError(tok);
return false; return false;
} }
@ -8675,7 +8675,7 @@ bool Tokenizer::validate() const
linktok.pop(); linktok.pop();
} }
else if (tok->link() != 0) { else if (tok->link() != nullptr) {
cppcheckError(tok); cppcheckError(tok);
return false; return false;
} }
@ -8867,7 +8867,7 @@ void Tokenizer::simplifyErrNoInWhile()
if (tok->str() != "errno") if (tok->str() != "errno")
continue; continue;
Token *endpar = 0; Token *endpar = nullptr;
if (Token::Match(tok->previous(), "&& errno == EINTR ) { ;| }")) if (Token::Match(tok->previous(), "&& errno == EINTR ) { ;| }"))
endpar = tok->tokAt(3); endpar = tok->tokAt(3);
else if (Token::Match(tok->tokAt(-2), "&& ( errno == EINTR ) ) { ;| }")) else if (Token::Match(tok->tokAt(-2), "&& ( errno == EINTR ) ) { ;| }"))
@ -9018,7 +9018,7 @@ void Tokenizer::simplifyStructDecl()
} }
if (!Token::simpleMatch(tok2, "} ;")) if (!Token::simpleMatch(tok2, "} ;"))
continue; continue;
Token *vartok = 0; Token *vartok = nullptr;
tok2 = tok1->tokAt(2); tok2 = tok1->tokAt(2);
while (Token::Match(tok2, "%type% %var% ;")) { while (Token::Match(tok2, "%type% %var% ;")) {
if (!vartok) { if (!vartok) {
@ -9295,7 +9295,7 @@ void Tokenizer::simplifyBitfields()
goback = false; goback = false;
tok = tok->previous(); tok = tok->previous();
} }
Token *last = 0; Token *last = nullptr;
if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %var% :") && if (Token::Match(tok, ";|{|}|public:|protected:|private: const| %type% %var% :") &&
!Token::Match(tok->next(), "case|public|protected|private|class|struct") && !Token::Match(tok->next(), "case|public|protected|private|class|struct") &&

View File

@ -63,7 +63,7 @@ public:
* \param unknown set to true if it's unknown if the scope is noreturn * \param unknown set to true if it's unknown if the scope is noreturn
* \return true if scope ends with a function call that might be 'noreturn' * \return true if scope ends with a function call that might be 'noreturn'
*/ */
bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = 0) const; bool IsScopeNoReturn(const Token *endScopeToken, bool *unknown = nullptr) const;
/** /**
* Tokenize code * Tokenize code

View File

@ -698,7 +698,7 @@ static Token * createAstAtToken(Token *tok)
{ {
if (Token::simpleMatch(tok,"for (")) { if (Token::simpleMatch(tok,"for (")) {
Token *tok2 = tok->tokAt(2); Token *tok2 = tok->tokAt(2);
Token *init1 = 0; Token *init1 = nullptr;
const Token * const endPar = tok->next()->link(); const Token * const endPar = tok->next()->link();
while (tok2 && tok2 != endPar && tok2->str() != ";") { while (tok2 && tok2 != endPar && tok2->str() != ";") {
if (tok2->str() == "<" && tok2->link()) { if (tok2->str() == "<" && tok2->link()) {

View File

@ -608,7 +608,7 @@ static void valueFlowForLoop(TokenList *tokenlist, ErrorLogger *errorLogger, con
if (vartok->varId() == 0U) if (vartok->varId() == 0U)
continue; continue;
tok = vartok->tokAt(4); tok = vartok->tokAt(4);
const Token *num2tok = 0; const Token *num2tok = nullptr;
if (Token::Match(tok, "%varid% <|<=|!=", vartok->varId())) { if (Token::Match(tok, "%varid% <|<=|!=", vartok->varId())) {
tok = tok->next(); tok = tok->next();
num2tok = tok->astOperand2(); num2tok = tok->astOperand2();

View File

@ -836,7 +836,7 @@ private:
void hasSubClassConstructor() { void hasSubClassConstructor() {
GET_SYMBOL_DB("class Foo { class Sub; }; class Foo::Sub { Sub() {} };"); GET_SYMBOL_DB("class Foo { class Sub; }; class Foo::Sub { Sub() {} };");
ASSERT(db != 0); ASSERT(db != nullptr);
if (db) { if (db) {
bool seen_something = false; bool seen_something = false;
@ -930,11 +930,11 @@ private:
ASSERT(db && db->scopeList.size() == 4); ASSERT(db && db->scopeList.size() == 4);
if (db) { if (db) {
const Scope* foo = db->findScopeByName("Foo"); const Scope* foo = db->findScopeByName("Foo");
ASSERT(foo != 0); ASSERT(foo != nullptr);
const Scope* bar1 = db->findScopeByName("Bar1"); const Scope* bar1 = db->findScopeByName("Bar1");
ASSERT(bar1 != 0); ASSERT(bar1 != nullptr);
const Scope* bar2 = db->findScopeByName("Bar2"); const Scope* bar2 = db->findScopeByName("Bar2");
ASSERT(bar2 != 0); ASSERT(bar2 != nullptr);
if (foo && bar1 && bar2) { if (foo && bar1 && bar2) {
ASSERT(bar1->definedType->friendList.size() == 1 && bar1->definedType->friendList.front().name == "Foo" && bar1->definedType->friendList.front().type == foo->definedType); ASSERT(bar1->definedType->friendList.size() == 1 && bar1->definedType->friendList.front().name == "Foo" && bar1->definedType->friendList.front().type == foo->definedType);
@ -1159,7 +1159,7 @@ private:
} }
} }
ASSERT(scope != 0); ASSERT(scope != nullptr);
if (!scope) if (!scope)
return; return;
@ -1193,7 +1193,7 @@ private:
} }
} }
ASSERT(scope != 0); ASSERT(scope != nullptr);
if (!scope) if (!scope)
return; return;
@ -1836,14 +1836,14 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
if (db) { if (db) {
const Scope * bar = db->findScopeByName("bar"); const Scope * bar = db->findScopeByName("bar");
ASSERT(bar != 0); ASSERT(bar != nullptr);
if (bar) { if (bar) {
unsigned int linenrs[] = { 2, 1 }; unsigned int linenrs[] = { 2, 1 };
unsigned int index = 0; unsigned int index = 0;
for (const Token * tok = bar->classStart->next(); tok != bar->classEnd; tok = tok->next()) { for (const Token * tok = bar->classStart->next(); tok != bar->classEnd; tok = tok->next()) {
if (Token::Match(tok, "%var% (") && !tok->varId() && Token::simpleMatch(tok->linkAt(1), ") ;")) { if (Token::Match(tok, "%var% (") && !tok->varId() && Token::simpleMatch(tok->linkAt(1), ") ;")) {
const Function * function = db->findFunction(tok); const Function * function = db->findFunction(tok);
ASSERT(function != 0); ASSERT(function != nullptr);
if (function) { if (function) {
std::stringstream expected; std::stringstream expected;
expected << "Function call on line " << tok->linenr() << " calls function on line " << linenrs[index] << std::endl; expected << "Function call on line " << tok->linenr() << " calls function on line " << linenrs[index] << std::endl;