use nullptr

This commit is contained in:
Daniel Marjamäki 2014-02-16 10:32:10 +01:00
parent 052840f8f5
commit 23efc68dd7
16 changed files with 193 additions and 193 deletions

View File

@ -37,7 +37,7 @@ void CheckAssert::assertWithSideEffects()
return;
const Token *tok = findAssertPattern(_tokenizer->tokens());
const Token *endTok = tok ? tok->next()->link() : NULL;
const Token *endTok = tok ? tok->next()->link() : nullptr;
while (tok && endTok) {
for (const Token* tmp = tok->tokAt(1); tmp != endTok; tmp = tmp->next()) {
@ -92,7 +92,7 @@ void CheckAssert::assertWithSideEffects()
}
tok = findAssertPattern(endTok->next());
endTok = tok ? tok->next()->link() : NULL;
endTok = tok ? tok->next()->link() : nullptr;
}
}
//---------------------------------------------------------------------------

View File

@ -56,7 +56,7 @@ void CheckAssignIf::assignIf()
// Casting address
if (Token::Match(endToken->tokAt(-4), "* ) & %any% ;"))
endToken = NULL;
endToken = nullptr;
if (endToken && Token::Match(endToken->tokAt(-2), "[&|] %num% ;")) {
bitop = endToken->strAt(-2).at(0);
@ -108,11 +108,11 @@ bool CheckAssignIf::assignIfParseScope(const Token * const assignTok,
else if (ftok->str() == ",")
argumentNumber++;
}
ftok = ftok ? ftok->previous() : NULL;
ftok = ftok ? ftok->previous() : nullptr;
if (!(ftok && ftok->function()))
return true;
const Variable *par = ftok->function()->getArgumentVar(argumentNumber);
if (par == NULL || par->isReference() || par->isPointer())
if (par == nullptr || par->isReference() || par->isPointer())
return true;
}
if (tok2->str() == "}")

View File

@ -85,7 +85,7 @@ bool CheckAutoVariables::isAutoVarArray(const Token *tok)
static bool checkRvalueExpression(const Token * const vartok)
{
const Variable * const var = vartok->variable();
if (var == NULL)
if (var == nullptr)
return false;
const Token * const next = vartok->next();

View File

@ -450,7 +450,7 @@ void CheckBool::checkComparisonOfBoolExpressionWithInt()
// boolean result in lhs compared with <|<=|>|>=
else if (tok->isComparisonOp() && !Token::Match(tok,"==|!=") && !isNonBoolLHSExpr(tok->previous())) {
const Token *lhs = tok;
while (NULL != (lhs = lhs->previous())) {
while (nullptr != (lhs = lhs->previous())) {
if ((lhs->isName() && !Token::Match(lhs,"or|and")) || lhs->isNumber())
continue;
if (lhs->isArithmeticalOp())
@ -466,7 +466,7 @@ void CheckBool::checkComparisonOfBoolExpressionWithInt()
if (_tokenizer->isCPP() && tok->str() == ">" &&
(Token::Match(lhs->previous(), "%var% <") || lhs->str() == ">"))
continue;
while (NULL != (lhs = lhs->previous())) {
while (nullptr != (lhs = lhs->previous())) {
if ((lhs->isName() && lhs->str() != "return") || lhs->isNumber())
continue;
if (Token::Match(lhs,"[+-*/.]"))

View File

@ -81,11 +81,11 @@ void CheckBufferOverrun::arrayIndexOutOfBoundsError(const Token *tok, const Arra
const Token *condition = 0;
for (unsigned int i = 0; i < index.size(); ++i) {
if (condition == NULL)
if (condition == nullptr)
condition = index[i].condition;
}
if (condition != NULL) {
if (condition != nullptr) {
errmsg << " Otherwise condition '" << condition->expressionString() << "' is redundant.";
std::list<const Token *> callstack;
callstack.push_back(tok);
@ -756,7 +756,7 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &tok, unsigned int p
const Variable* const argument = func->getArgumentVar(par-1);
const Token *nameToken;
if (argument && Token::Match(argument->typeStartToken(), "%type% %var% [ %num% ] [,)[]")
&& (nameToken = argument->nameToken()) != NULL) {
&& (nameToken = argument->nameToken()) != nullptr) {
const Token *tok2 = nameToken->next();
MathLib::bigint argsize = _tokenizer->sizeOfType(argument->typeStartToken());
@ -926,7 +926,7 @@ void CheckBufferOverrun::arrayIndexInForLoop(const Token *tok, const ArrayInfo &
if (max_value > size && Token::simpleMatch(tok3, "; ) {")) {
const Token * const endToken = tok3->linkAt(2);
const Token *useToken = NULL;
const Token *useToken = nullptr;
bool incrementInLoop = false;
for (const Token *loopTok = tok3->tokAt(3); loopTok != endToken; loopTok = loopTok->next()) {
if (Token::Match(loopTok, "%varid% [ %var% ++| ]", arrayInfo.declarationId()) && loopTok->tokAt(2)->varId() == counter_varid)
@ -935,7 +935,7 @@ void CheckBufferOverrun::arrayIndexInForLoop(const Token *tok, const ArrayInfo &
incrementInLoop = true;
}
if ((useToken != NULL) && incrementInLoop)
if ((useToken != nullptr) && incrementInLoop)
bufferOverrunError(useToken, arrayInfo.varname());
}
}
@ -1408,7 +1408,7 @@ void CheckBufferOverrun::checkReadlinkBufferUsage(const Token* ftok, const Token
const Token* bufParam = ftok->tokAt(2)->nextArgument();
if (funcname == "readlinkat")
bufParam = bufParam ? bufParam->nextArgument() : NULL;
bufParam = bufParam ? bufParam->nextArgument() : nullptr;
if (!Token::Match(bufParam, "%varid% , %num% )", varid))
return;
@ -1522,7 +1522,7 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
nextTok = 8;
} else if (Token::Match(tok, "[;{}] %var% = %str% ;") &&
tok->next()->varId() > 0 &&
NULL != Token::findmatch(_tokenizer->tokens(), "[;{}] const| %type% * %varid% ;", tok->next()->varId())) {
nullptr != Token::findmatch(_tokenizer->tokens(), "[;{}] const| %type% * %varid% ;", tok->next()->varId())) {
size = 1 + int(tok->tokAt(3)->strValue().size());
type = "char";
var = tok->next()->variable();
@ -1707,7 +1707,7 @@ void CheckBufferOverrun::checkStructVariable()
}
// Goto end of statement.
const Token *CheckTok = NULL;
const Token *CheckTok = nullptr;
while (tok3 && tok3 != func_scope->classEnd) {
// End of statement.
if (tok3->str() == ";") {

View File

@ -64,7 +64,7 @@ namespace {
CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
: Check(myName(), tokenizer, settings, errorLogger),
symbolDatabase(tokenizer?tokenizer->getSymbolDatabase():NULL)
symbolDatabase(tokenizer?tokenizer->getSymbolDatabase():nullptr)
{
}
@ -910,7 +910,7 @@ void CheckClass::checkMemset()
const Token* arg1 = tok->tokAt(2);
const Token* arg3 = arg1;
arg3 = arg3->nextArgument();
arg3 = (arg3 != NULL) ? arg3->nextArgument() : NULL;
arg3 = (arg3 != nullptr) ? arg3->nextArgument() : nullptr;
if (!arg3)
// weird, shouldn't happen: memset etc should have
// 3 arguments.
@ -1604,7 +1604,7 @@ static unsigned int countParameters(const Token *tok)
return 0;
unsigned int numpar = 1;
while (NULL != (tok = tok->nextArgument()))
while (nullptr != (tok = tok->nextArgument()))
numpar++;
return numpar;

View File

@ -94,7 +94,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
}
// Function usage..
const Token *scopeEnd = NULL;
const Token *scopeEnd = nullptr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next()) {
// parsing of library code to find called functions
@ -175,7 +175,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
}
}
if (scopeEnd == NULL) {
if (scopeEnd == nullptr) {
if (!Token::Match(tok, ")|= const| {"))
continue;
scopeEnd = tok;
@ -183,7 +183,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
scopeEnd = scopeEnd->next();
scopeEnd = scopeEnd->link();
} else if (tok == scopeEnd) {
scopeEnd = NULL;
scopeEnd = nullptr;
continue;
}
@ -220,7 +220,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
if (ftok->str() == "<")
ftok = ftok->link();
if (Token::Match(ftok->linkAt(1), ") const|throw|{"))
funcname = NULL;
funcname = nullptr;
}
if (funcname) {

View File

@ -48,7 +48,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
: _tokenizer(tokenizer), _settings(settings), _errorLogger(errorLogger)
{
// create global scope
scopeList.push_back(Scope(this, NULL, NULL));
scopeList.push_back(Scope(this, nullptr, nullptr));
// pointer to current scope
Scope *scope = &scopeList.back();
@ -59,7 +59,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
std::map<const Token *, Scope *> back;
// find all scopes
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok ? tok->next() : NULL) {
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok ? tok->next() : nullptr) {
// Locate next class
if (Token::Match(tok, "class|struct|union|namespace ::| %var% {|:|::") &&
tok->strAt(-1) != "friend") {
@ -856,7 +856,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
// create variable symbol table
_variableList.resize(_tokenizer->varIdCount() + 1);
std::fill_n(_variableList.begin(), _variableList.size(), (const Variable*)NULL);
std::fill_n(_variableList.begin(), _variableList.size(), (const Variable*)nullptr);
// check all scopes for variables
for (std::list<Scope>::iterator it = scopeList.begin(); it != scopeList.end(); ++it) {
@ -1449,7 +1449,7 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
scopeList.pop_back();
while (tok1->next())
tok1 = tok1->next();
*scope = NULL;
*scope = nullptr;
*tok = tok1;
return;
}
@ -1459,8 +1459,8 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
*tok = tok1;
} else {
scopeList.pop_back();
*scope = NULL;
*tok = NULL;
*scope = nullptr;
*tok = nullptr;
}
}
@ -1483,7 +1483,7 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
// check for invalid code
if (!tok2 || !tok2->next())
return NULL;
return nullptr;
if (tok2->str() == "virtual") {
base.isVirtual = true;
@ -1524,7 +1524,7 @@ const Token *Type::initBaseInfo(const Token *tok, const Token *tok1)
}
base.name = tok2->str();
base.type = NULL;
base.type = nullptr;
// add unhandled templates
if (tok2->next() && tok2->next()->str() == "<") {
@ -1916,8 +1916,8 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
for (const Token* tok = start->next(); tok; tok = tok->next()) {
const Token* startTok = tok;
const Token* endTok = NULL;
const Token* nameTok = NULL;
const Token* endTok = nullptr;
const Token* nameTok = nullptr;
if (tok->str() == "," || tok->str() == ")")
return; // Syntax error
@ -1962,7 +1962,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
endTok = tok->previous();
}
const ::Type *argType = NULL;
const ::Type *argType = nullptr;
if (!typeTok->isStandardType()) {
argType = symbolDatabase->findVariableType(scope, typeTok);
if (!argType) {
@ -2094,23 +2094,23 @@ Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *
numConstructors(0),
numCopyOrMoveConstructors(0),
type(type_),
definedType(NULL),
functionOf(NULL),
function(NULL)
definedType(nullptr),
functionOf(nullptr),
function(nullptr)
{
}
Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *nestedIn_) :
check(check_),
classDef(classDef_),
classStart(NULL),
classEnd(NULL),
classStart(nullptr),
classEnd(nullptr),
nestedIn(nestedIn_),
numConstructors(0),
numCopyOrMoveConstructors(0),
definedType(NULL),
functionOf(NULL),
function(NULL)
definedType(nullptr),
functionOf(nullptr),
function(nullptr)
{
const Token *nameTok = classDef;
if (!classDef) {
@ -2197,7 +2197,7 @@ void Scope::getVariableList()
}
// syntax error?
else if (tok->next() == NULL)
else if (tok->next() == nullptr)
break;
// Is it a function?
@ -2296,8 +2296,8 @@ void Scope::getVariableList()
const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
{
// This is the start of a statement
const Token *vartok = NULL;
const Token *typetok = NULL;
const Token *vartok = nullptr;
const Token *typetok = nullptr;
// Is it a throw..?
if (Token::Match(tok, "throw %any% (") &&
@ -2340,7 +2340,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
return tok;
}
const Type *vType = NULL;
const Type *vType = nullptr;
if (typetok) {
vType = check->findVariableType(this, typetok);
@ -2376,7 +2376,7 @@ const Variable *Scope::getVariable(const std::string &varname) const
return &*iter;
}
return NULL;
return nullptr;
}
static const Token* skipScopeIdentifiers(const Token* tok)
@ -2406,7 +2406,7 @@ bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const
return false;
const Token* localTypeTok = skipScopeIdentifiers(tok);
const Token* localVarTok = NULL;
const Token* localVarTok = nullptr;
if (Token::Match(localTypeTok, "%type% <")) {
const Token* closeTok = localTypeTok->next()->link();
@ -2445,7 +2445,7 @@ bool Scope::isVariableDeclaration(const Token* tok, const Token*& vartok, const
typetok = localTypeTok;
}
return NULL != vartok;
return nullptr != vartok;
}
@ -2486,7 +2486,7 @@ const Type* SymbolDatabase::findVariableType(const Scope *start, const Token *ty
}
}
return NULL;
return nullptr;
}
//---------------------------------------------------------------------------

View File

@ -86,7 +86,7 @@ void TemplateSimplifier::cleanupAfterSimplify(Token *tokens)
break;
}
if (!Token::Match(end, "%var%|::|<|>|>>|,")) {
end = NULL;
end = nullptr;
break;
}
end = end->next();
@ -425,7 +425,7 @@ std::set<std::string> TemplateSimplifier::expandSpecialized(Token *tokens)
tok->deleteThis();
// Use this special template in the code..
while (NULL != (tok2 = const_cast<Token *>(Token::findmatch(tok2, pattern.c_str())))) {
while (nullptr != (tok2 = const_cast<Token *>(Token::findmatch(tok2, pattern.c_str())))) {
Token::eraseTokens(tok2, Token::findsimplematch(tok2, "("));
tok2->str(name);
}

View File

@ -70,7 +70,7 @@ static bool bailoutFunctionPar(const Token *tok, const ValueFlow::Value &value,
tok = tok->link();
tok = tok->previous();
}
tok = tok ? tok->previous() : NULL;
tok = tok ? tok->previous() : nullptr;
if (!Token::Match(tok,"%var% ("))
return false; // not a function => dont bailout
@ -126,7 +126,7 @@ static const Token * skipValueInConditionalExpression(const Token * const valuet
tokens.push(tok2->astOperand1());
}
}
return NULL;
return nullptr;
}
static bool bailoutSelfAssignment(const Token * const tok)
@ -137,9 +137,9 @@ static bool bailoutSelfAssignment(const Token * const tok)
parent = parent->astParent();
// Assignment where lhs variable exists in rhs => return true
if (parent != NULL &&
if (parent != nullptr &&
parent->astOperand2() == op &&
parent->astOperand1() != NULL &&
parent->astOperand1() != nullptr &&
parent->str() == "=") {
for (const Token *lhs = parent->astOperand1(); lhs; lhs = lhs->astOperand1()) {
if (lhs->varId() == tok->varId())
@ -709,12 +709,12 @@ static void valueFlowSubFunction(TokenList *tokenlist, ErrorLogger *errorLogger,
// Get function argument, and check if parameter is passed by value
const Function * const function = ftok->astOperand1()->function();
const Variable * const arg = function ? function->getArgumentVar(argnr) : NULL;
if (!Token::Match(arg ? arg->typeStartToken() : NULL, "%type% %var% ,|)"))
const Variable * const arg = function ? function->getArgumentVar(argnr) : nullptr;
if (!Token::Match(arg ? arg->typeStartToken() : nullptr, "%type% %var% ,|)"))
continue;
// Function scope..
const Scope * const functionScope = function ? function->functionScope : NULL;
const Scope * const functionScope = function ? function->functionScope : nullptr;
if (!functionScope)
continue;

View File

@ -64,7 +64,7 @@ private:
#else
current_dir.resize(1024);
#endif
while (getcwd(&current_dir[0], current_dir.size()) == NULL && errno == ERANGE) {
while (getcwd(&current_dir[0], current_dir.size()) == nullptr && errno == ERANGE) {
current_dir.resize(current_dir.size() + 1024);
}

View File

@ -125,7 +125,7 @@ public:
}
private:
void check(const char code[], const Settings *settings = NULL) {
void check(const char code[], const Settings *settings = nullptr) {
// Clear the error buffer..
errout.str("");
@ -385,7 +385,7 @@ private:
const unsigned int varId(Token::findmatch(tokenizer.tokens(), varname)->varId());
// getcode..
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, NULL);
CheckMemoryLeakInFunction checkMemoryLeak(&tokenizer, &settings, nullptr);
checkMemoryLeak.parse_noreturn();
std::list<const Token *> callstack;
callstack.push_back(0);
@ -662,7 +662,7 @@ private:
}
}
CheckMemoryLeakInFunction checkMemoryLeak(NULL, &settings, this);
CheckMemoryLeakInFunction checkMemoryLeak(nullptr, &settings, this);
checkMemoryLeak.simplifycode(tokens);
return list.front()->stringifyList(0, false);

View File

@ -196,7 +196,7 @@ private:
TEST_CASE(checkComparisonFunctionIsAlwaysTrueOrFalse);
}
void check(const char code[], const char *filename = NULL, bool experimental = false, bool inconclusive = true, bool posix = false, bool runSimpleChecks=true, Settings* settings = 0) {
void check(const char code[], const char *filename = nullptr, bool experimental = false, bool inconclusive = true, bool posix = false, bool runSimpleChecks=true, Settings* settings = 0) {
// Clear the error buffer..
errout.str("");
@ -258,11 +258,11 @@ private:
ErrorLogger *_next;
};
void check_preprocess_suppress(const char precode[], const char *filename = NULL) {
void check_preprocess_suppress(const char precode[], const char *filename = nullptr) {
// Clear the error buffer..
errout.str("");
if (filename == NULL)
if (filename == nullptr)
filename = "test.cpp";
Settings settings;
@ -4120,20 +4120,20 @@ private:
}
void redundantGetAndSetUserId() {
check("seteuid(geteuid());\n", NULL, false , false, true);
check("seteuid(geteuid());\n", nullptr, false , false, true);
ASSERT_EQUALS("[test.cpp:1]: (warning) Redundant get and set of user id.\n", errout.str());
check("setuid(getuid());\n", NULL, false , false, true);
check("setuid(getuid());\n", nullptr, false , false, true);
ASSERT_EQUALS("[test.cpp:1]: (warning) Redundant get and set of user id.\n", errout.str());
check("setgid(getgid());\n", NULL, false , false, true);
check("setgid(getgid());\n", nullptr, false , false, true);
ASSERT_EQUALS("[test.cpp:1]: (warning) Redundant get and set of user id.\n", errout.str());
check("setegid(getegid());\n", NULL, false , false, true);
check("setegid(getegid());\n", nullptr, false , false, true);
ASSERT_EQUALS("[test.cpp:1]: (warning) Redundant get and set of user id.\n", errout.str());
check("seteuid(getuid());\n", NULL, false , false, true);
check("seteuid(getuid());\n", nullptr, false , false, true);
ASSERT_EQUALS("", errout.str());
check("seteuid(foo());\n", NULL, false , false, true);
check("seteuid(foo());\n", nullptr, false , false, true);
ASSERT_EQUALS("", errout.str());
check("foo(getuid());\n", NULL, false , false, true);
check("foo(getuid());\n", nullptr, false , false, true);
ASSERT_EQUALS("", errout.str());
}
@ -4713,12 +4713,12 @@ private:
// make sure there are not "same expression" fp when there are different casts
check("void f(long x) { if ((int32_t)x == (int64_t)x) {} }",
NULL, // filename
nullptr, // filename
false, // experimental
false, // inconclusive
false, // posix
false, // runSimpleChecks
NULL // settings
nullptr // settings
);
ASSERT_EQUALS("", errout.str());
@ -4763,7 +4763,7 @@ private:
check("float f(float x) { return x-x; }"); // ticket #4485 (Inf)
ASSERT_EQUALS("", errout.str());
check("float f(float x) { return (X double)x == (X double)x; }", NULL, false, false, false, false);
check("float f(float x) { return (X double)x == (X double)x; }", nullptr, false, false, false, false);
ASSERT_EQUALS("", errout.str());
check("struct X { float f; };\n"
@ -6158,7 +6158,7 @@ private:
" int i;\n"
" i = 1;\n"
" i = 1;\n"
"}", NULL, false, false, false, false);
"}", nullptr, false, false, false, false);
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance) Variable 'i' is reassigned a value before the old one has been used.\n", errout.str());
check("void f() {\n"
@ -6219,7 +6219,7 @@ private:
" i = 1;\n"
" bar();\n"
" i = 1;\n"
"}", NULL, false, false, false, false);
"}", nullptr, false, false, false, false);
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (performance) Variable 'i' is reassigned a value before the old one has been used.\n", errout.str());
check("void bar(int i) {}\n"
@ -6227,7 +6227,7 @@ private:
" i = 1;\n"
" bar(i);\n" // Passed as argument
" i = 1;\n"
"}", NULL, false, false, false, false);
"}", nullptr, false, false, false, false);
ASSERT_EQUALS("", errout.str());
// Branch tests
@ -6303,7 +6303,7 @@ private:
" x = 1;\n"
" x = 1;\n"
" return x + 1;\n"
"}", NULL, false, false, false, false);
"}", nullptr, false, false, false, false);
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (performance) Variable 'x' is reassigned a value before the old one has been used.\n", errout.str());
// from #3103 (avoid a false positive)
@ -6533,7 +6533,7 @@ private:
"if (pipe(pipefd) == -1) {\n"
" return;\n"
" }\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer 'pipefd' must have size of 2 integers if used as parameter of pipe().\n", errout.str());
check("void f(){\n"
@ -6541,7 +6541,7 @@ private:
"if (pipe(pipefd) == -1) {\n"
" return;\n"
" }\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("", errout.str());
check("void f(){\n"
@ -6549,7 +6549,7 @@ private:
"if (pipe(pipefd) == -1) {\n"
" return;\n"
" }\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("", errout.str());
check("void f(){\n"
@ -6557,7 +6557,7 @@ private:
"if (pipe2(pipefd,0) == -1) {\n"
" return;\n"
" }\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer 'pipefd' must have size of 2 integers if used as parameter of pipe().\n", errout.str());
check("void f(){\n"
@ -6565,7 +6565,7 @@ private:
"if (pipe2(pipefd,0) == -1) {\n"
" return;\n"
" }\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("", errout.str());
check("void f(){\n"
@ -6573,7 +6573,7 @@ private:
"if (pipe2(pipefd,0) == -1) {\n"
" return;\n"
" }\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("", errout.str());
// avoid crash with pointer variable
@ -6790,22 +6790,22 @@ private:
// check usleep(), which is allowed to be called with in a range of [0,999999]
check("void f(){\n"
"usleep(10000);\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("", errout.str());
check("void f(){\n"
"usleep(999999);\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("", errout.str());
check("void f(){\n"
"usleep(1000000);\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid usleep() argument nr 1. The value is 1000000 but the valid values are '0-999999'.\n", errout.str());
check("void f(){\n"
"usleep(1000001);\n"
"}",NULL,false,false,true);
"}",nullptr,false,false,true);
ASSERT_EQUALS("[test.cpp:2]: (error) Invalid usleep() argument nr 1. The value is 1000001 but the valid values are '0-999999'.\n", errout.str());
}
@ -6814,38 +6814,38 @@ private:
" if (a < 0)\n"
" return a++,\n"
" do_something();\n"
"}", NULL, true, false, false, false);
"}", nullptr, true, false, false, false);
ASSERT_EQUALS("[test.cpp:3]: (style) Comma is used in return statement. The comma can easily be misread as a ';'.\n", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return a++, do_something();\n"
"}", NULL, true, false, false, false);
"}", nullptr, true, false, false, false);
ASSERT_EQUALS("", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return a+5,\n"
" do_something();\n"
"}", NULL, true, false, false, false);
"}", nullptr, true, false, false, false);
ASSERT_EQUALS("[test.cpp:3]: (style) Comma is used in return statement. The comma can easily be misread as a ';'.\n", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return a+5, do_something();\n"
"}", NULL, true, false, false, false);
"}", nullptr, true, false, false, false);
ASSERT_EQUALS("", errout.str());
check("int fun(int a) {\n"
" if (a < 0)\n"
" return c<int,\nint>::b;\n"
"}", NULL, true, false, false, false);
"}", nullptr, true, false, false, false);
ASSERT_EQUALS("", errout.str());
// ticket #4927 Segfault in CheckOther::checkCommaSeparatedReturn() on invalid code
check("int main() {\n"
" return 0\n"
"}", NULL, true, false, false, false);
"}", nullptr, true, false, false, false);
ASSERT_EQUALS("", errout.str());
// #4943 take care of C++11 initializer lists
@ -6856,7 +6856,7 @@ private:
" { \"2\" },\n"
" { \"3\" }\n"
" };\n"
"}", NULL, true, false, false, false);
"}", nullptr, true, false, false, false);
ASSERT_EQUALS("", errout.str());
}

View File

@ -1198,7 +1198,7 @@ private:
void match_cfg_def() {
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
{
std::map<std::string, std::string> cfg;
@ -1619,7 +1619,7 @@ private:
"#if A == 1\n"
";\n"
"#endif\n";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\n;\n\n", preprocessor.getcode(filedata,"",""));
}
@ -1627,7 +1627,7 @@ private:
const char filedata[] = "#if ('A' == 0x41)\n"
"123\n"
"#endif\n";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n123\n\n", preprocessor.getcode(filedata,"",""));
}
@ -1635,7 +1635,7 @@ private:
const char filedata[] = "#if !(A)\n"
"123\n"
"#endif\n";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n123\n\n", preprocessor.getcode(filedata,"",""));
}
@ -1688,7 +1688,7 @@ private:
const std::string code("#if X || Y\n"
"a1;\n"
"#endif\n");
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\na1;\n\n", preprocessor.getcode(code, "X", "test.c"));
ASSERT_EQUALS("\na1;\n\n", preprocessor.getcode(code, "Y", "test.c"));
}
@ -1764,7 +1764,7 @@ private:
// Preprocess => actual result..
std::istringstream istr(filedata);
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("#define str \"abc\" \"def\"\n\nabcdef = str;\n", preprocessor.read(istr, "test.c"));
}
@ -1775,7 +1775,7 @@ private:
// Preprocess => actual result..
std::istringstream istr(filedata);
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("#define sqr(aa) aa * aa\n\nsqr(5);\n", preprocessor.read(istr, "test.c"));
}
@ -1786,7 +1786,7 @@ private:
// Preprocess => actual result..
std::istringstream istr(filedata);
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("const char *str = \"abcdefghi\"\n\n\n", preprocessor.read(istr, "test.c"));
}
@ -2254,7 +2254,7 @@ private:
"int z;\n"
"z = 0;\n";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\nint z;\nz = 0;\n", preprocessor.getcode(filedata, "", ""));
}
}
@ -2496,7 +2496,7 @@ private:
const char code[] = "#pragma once\n"
"int x";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
const std::list<std::string> includePaths;
std::map<std::string,std::string> defs;
std::set<std::string> pragmaOnce;
@ -2815,7 +2815,7 @@ private:
}
void define_if1() {
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
{
const char filedata[] = "#define A 0\n"
@ -2839,7 +2839,7 @@ private:
"#if (B==A) || (B==C)\n"
"FOO\n"
"#endif";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\n\nFOO\n\n", preprocessor.getcode(filedata,"",""));
}
@ -2848,7 +2848,7 @@ private:
"#if (A==0)\n"
"FOO\n"
"#endif";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\nFOO\n\n", preprocessor.getcode(filedata,"",""));
}
@ -2857,7 +2857,7 @@ private:
"#if X==123\n"
"FOO\n"
"#endif";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\nFOO\n\n", preprocessor.getcode(filedata,"",""));
}
@ -2868,7 +2868,7 @@ private:
"#if B==0x0010\n"
"FOO\n"
"#endif";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\n\nFOO\n\n", preprocessor.getcode(filedata,"",""));
}
{
@ -2878,7 +2878,7 @@ private:
"#if C==0x0010\n"
"FOO\n"
"#endif";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\n\n\nFOO\n\n", preprocessor.getcode(filedata,"",""));
}
{
@ -2886,7 +2886,7 @@ private:
"#if A==1\n"
"FOO\n"
"#endif";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\n\n\n", preprocessor.getcode(filedata,"",""));
}
}
@ -2903,7 +2903,7 @@ private:
"#if B >= 0\n"
"456\n"
"#endif\n";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
const std::string actualA0 = preprocessor.getcode(filedata, "A=0", "test.c");
ASSERT_EQUALS(true, actualA0.find("123") != std::string::npos);
ASSERT_EQUALS(false, actualA0.find("456") != std::string::npos);
@ -3035,7 +3035,7 @@ private:
"B me;\n";
// Preprocess => actual result..
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\n\n\n\n\n$int me;\n", preprocessor.getcode(filedata, "", "a.cpp"));
ASSERT_EQUALS("\n\n\n\n\n\n$char me;\n", preprocessor.getcode(filedata, "A", "a.cpp"));
}
@ -3064,7 +3064,7 @@ private:
"#endif\n";
// Preprocess => actual result..
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
ASSERT_EQUALS("\n\n\n\n", preprocessor.getcode(filedata, "", "a.cpp"));
ASSERT_EQUALS("\n\n\n\n", preprocessor.getcode(filedata, "A", "a.cpp"));
}
@ -3268,7 +3268,7 @@ private:
"Fred & Wilma\n"
"#endif\n");
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
std::string actual = preprocessor.getcode(src, "X=1", "test.c");
ASSERT_EQUALS("\nFred & Wilma\n\n", actual);
@ -3279,13 +3279,13 @@ private:
"Fred & Wilma\n"
"#endif\n");
{
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
std::string actual = preprocessor.getcode(src, "X=1", "test.c");
ASSERT_EQUALS("\n\n\n", actual);
}
{
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
std::string actual = preprocessor.getcode(src, "X=1;Y=2", "test.c");
ASSERT_EQUALS("\nFred & Wilma\n\n", actual);
}
@ -3298,7 +3298,7 @@ private:
"#if (X == Y)\n"
"Fred & Wilma\n"
"#endif\n";
Preprocessor preprocessor(NULL,this);
Preprocessor preprocessor(nullptr,this);
const std::string actual = preprocessor.getcode(code, "TEST", "test.c");
ASSERT_EQUALS("\n\n\nFred & Wilma\n\n", actual);
}
@ -3306,7 +3306,7 @@ private:
void predefine4() {
// #3577
const char code[] = "char buf[X];\n";
Preprocessor preprocessor(NULL,this);
Preprocessor preprocessor(nullptr,this);
const std::string actual = preprocessor.getcode(code, "X=123", "test.c");
ASSERT_EQUALS("char buf[$123];\n", actual);
}
@ -3314,13 +3314,13 @@ private:
void predefine5() { // #3737, #5119 - automatically define __cplusplus
// #3737...
const char code[] = "#ifdef __cplusplus\n123\n#endif";
Preprocessor preprocessor(NULL,this);
Preprocessor preprocessor(nullptr,this);
ASSERT_EQUALS("\n\n\n", preprocessor.getcode(code, "X=123", "test.c"));
ASSERT_EQUALS("\n123\n\n", preprocessor.getcode(code, "X=123", "test.cpp"));
// #5119...
ASSERT_EQUALS(false, Preprocessor::cplusplus(NULL,"test.c"));
ASSERT_EQUALS(true, Preprocessor::cplusplus(NULL,"test.cpp"));
ASSERT_EQUALS(false, Preprocessor::cplusplus(nullptr,"test.c"));
ASSERT_EQUALS(true, Preprocessor::cplusplus(nullptr,"test.cpp"));
Settings settings;
ASSERT_EQUALS(true, Preprocessor::cplusplus(&settings,"test.cpp"));
@ -3359,7 +3359,7 @@ private:
std::map<std::string, std::string> cfg;
cfg["C"] = "";
std::string condition("defined(A) || defined(B) || defined(C)");
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
preprocessor.simplifyCondition(cfg, condition, true);
ASSERT_EQUALS("1", condition);
}
@ -3367,7 +3367,7 @@ private:
void invalidElIf() {
// #2942 - segfault
const char code[] = "#elif (){\n";
Preprocessor preprocessor(NULL,this);
Preprocessor preprocessor(nullptr,this);
const std::string actual = preprocessor.getcode(code, "TEST", "test.c");
ASSERT_EQUALS("\n", actual);
}
@ -3376,7 +3376,7 @@ private:
const std::string filePath("test.c");
const std::list<std::string> includePaths;
std::map<std::string,std::string> defs;
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
// ifdef
{
@ -3589,7 +3589,7 @@ private:
const std::string filePath("test.c");
const std::list<std::string> includePaths;
std::map<std::string,std::string> defs;
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
// #3405
{
@ -3656,7 +3656,7 @@ private:
"\n"
"#endif";
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
const std::list<std::string> includePaths;
std::map<std::string,std::string> defs;
@ -3698,7 +3698,7 @@ private:
const std::list<std::string> includePaths;
std::map<std::string,std::string> defs;
std::set<std::string> pragmaOnce;
Preprocessor preprocessor(NULL, this);
Preprocessor preprocessor(nullptr, this);
std::istringstream istr(code);
const std::string s(preprocessor.read(istr, ""));
@ -3963,9 +3963,9 @@ private:
void macroChar() {
const char filedata[] = "#define X 1\nX\n";
ASSERT_EQUALS("\n$1\n", OurPreprocessor::expandMacros(filedata,NULL));
ASSERT_EQUALS("\n$1\n", OurPreprocessor::expandMacros(filedata,nullptr));
OurPreprocessor::macroChar = char(1);
ASSERT_EQUALS("\n" + std::string(char(1),1U) + "1\n", OurPreprocessor::expandMacros(filedata,NULL));
ASSERT_EQUALS("\n" + std::string(char(1),1U) + "1\n", OurPreprocessor::expandMacros(filedata,nullptr));
OurPreprocessor::macroChar = '$';
}

View File

@ -41,10 +41,10 @@ class TestSymbolDatabase: public TestFixture {
public:
TestSymbolDatabase()
:TestFixture("TestSymbolDatabase")
,si(NULL, NULL, NULL)
,vartok(NULL)
,typetok(NULL)
,t(NULL)
,si(nullptr, nullptr, nullptr)
,vartok(nullptr)
,typetok(nullptr)
,t(nullptr)
,found(false) {
}
@ -56,9 +56,9 @@ private:
bool found;
void reset() {
vartok = NULL;
typetok = NULL;
t = NULL;
vartok = nullptr;
typetok = nullptr;
t = nullptr;
found = false;
}
@ -216,10 +216,10 @@ private:
void array() const {
std::istringstream code("int a[10+2];");
TokenList list(NULL);
TokenList list(nullptr);
list.createTokens(code, "test.c");
list.front()->tokAt(2)->link(list.front()->tokAt(6));
Variable v(list.front()->next(), list.front(), list.back(), 0, Public, NULL, NULL);
Variable v(list.front()->next(), list.front(), list.back(), 0, Public, nullptr, nullptr);
ASSERT(v.isArray());
ASSERT_EQUALS(1U, v.dimensions().size());
ASSERT_EQUALS(0U, v.dimension(0));
@ -227,11 +227,11 @@ private:
void test_isVariableDeclarationCanHandleNull() {
reset();
bool result = si.isVariableDeclaration(NULL, vartok, typetok);
bool result = si.isVariableDeclaration(nullptr, vartok, typetok);
ASSERT_EQUALS(false, result);
ASSERT(NULL == vartok);
ASSERT(NULL == typetok);
Variable v(NULL, NULL, NULL, 0, Public, 0, 0);
ASSERT(nullptr == vartok);
ASSERT(nullptr == typetok);
Variable v(nullptr, nullptr, nullptr, 0, Public, 0, 0);
}
void test_isVariableDeclarationIdentifiesSimpleDeclaration() {
@ -337,8 +337,8 @@ private:
givenACodeSampleToTokenize constness("const int* cp;");
bool result = si.isVariableDeclaration(constness.tokens(), vartok, typetok);
ASSERT_EQUALS(false, result);
ASSERT(NULL == vartok);
ASSERT(NULL == typetok);
ASSERT(nullptr == vartok);
ASSERT(nullptr == typetok);
}
void test_isVariableDeclarationIdentifiesFirstOfManyVariables() {
@ -561,7 +561,7 @@ private:
{
reset();
std::istringstream code("std::string s;");
TokenList list(NULL);
TokenList list(nullptr);
list.createTokens(code, "test.cpp");
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
ASSERT_EQUALS(true, result);
@ -575,7 +575,7 @@ private:
{
reset();
std::istringstream code("std::vector<int> v;");
TokenList list(NULL);
TokenList list(nullptr);
list.createTokens(code, "test.cpp");
list.front()->tokAt(3)->link(list.front()->tokAt(5));
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
@ -590,7 +590,7 @@ private:
{
reset();
std::istringstream code("SomeClass s;");
TokenList list(NULL);
TokenList list(nullptr);
list.createTokens(code, "test.cpp");
bool result = si.isVariableDeclaration(list.front(), vartok, typetok);
ASSERT_EQUALS(true, result);
@ -616,7 +616,7 @@ private:
tokenizer.tokenize(istr, "test.cpp");
const Token *tok = Token::findmatch(tokenizer.tokens(), ". x");
tok = tok ? tok->next() : NULL;
tok = tok ? tok->next() : nullptr;
ASSERT(tok && tok->variable() && Token::Match(tok->variable()->typeStartToken(), "int x ;"));
ASSERT(tok && tok->varId() == 0U); // It's possible to set a varId
}
@ -636,7 +636,7 @@ private:
tokenizer.tokenize(istr, "test.cpp");
const Token *tok = Token::findmatch(tokenizer.tokens(), ". x");
tok = tok ? tok->next() : NULL;
tok = tok ? tok->next() : nullptr;
ASSERT(tok && tok->variable() && Token::Match(tok->variable()->typeStartToken(), "int x ;"));
ASSERT(tok && tok->varId() == 0U); // It's possible to set a varId
}
@ -656,7 +656,7 @@ private:
tokenizer.tokenize(istr, "test.cpp");
const Token *tok = Token::findmatch(tokenizer.tokens(), ". x");
tok = tok ? tok->next() : NULL;
tok = tok ? tok->next() : nullptr;
ASSERT(tok && tok->variable() && Token::Match(tok->variable()->typeStartToken(), "int x ;"));
ASSERT(tok && tok->varId() == 0U); // It's possible to set a varId
}
@ -727,7 +727,7 @@ private:
if (db) {
const Scope *scope = findFunctionScopeByToken(db, tokenizer.tokens()->tokAt(4));
ASSERT(scope == NULL);
ASSERT(scope == nullptr);
const Function *function = findFunctionByName("func", &db->scopeList.back());
@ -805,7 +805,7 @@ private:
if (db) {
const Scope *scope = findFunctionScopeByToken(db, tokenizer.tokens()->tokAt(6));
ASSERT(scope == NULL);
ASSERT(scope == nullptr);
const Function *function = findFunctionByName("func", &db->scopeList.back());
@ -946,13 +946,13 @@ private:
void parseFunctionCorrect() {
// ticket 3188 - "if" statement parsed as function
GET_SYMBOL_DB("void func(i) int i; { if (i == 1) return; }\n")
ASSERT(db != NULL);
ASSERT(db != nullptr);
// 3 scopes: Global, function, if
ASSERT_EQUALS(3, db->scopeList.size());
ASSERT(findFunctionByName("func", &db->scopeList.back()) != NULL);
ASSERT(findFunctionByName("if", &db->scopeList.back()) == NULL);
ASSERT(findFunctionByName("func", &db->scopeList.back()) != nullptr);
ASSERT(findFunctionByName("if", &db->scopeList.back()) == nullptr);
}
void parseFunctionDeclarationCorrect() {
@ -1151,7 +1151,7 @@ private:
"namespace barney { X::X(int) { } }");
// Locate the scope for the class..
const Scope *scope = NULL;
const Scope *scope = nullptr;
for (std::list<Scope>::const_iterator it = db->scopeList.begin(); it != db->scopeList.end(); ++it) {
if (it->isClassOrStruct()) {
scope = &(*it);
@ -1185,7 +1185,7 @@ private:
"}");
// Locate the scope for the class..
const Scope *scope = NULL;
const Scope *scope = nullptr;
for (std::list<Scope>::const_iterator it = db->scopeList.begin(); it != db->scopeList.end(); ++it) {
if (it->isClassOrStruct()) {
scope = &(*it);
@ -1490,13 +1490,13 @@ private:
ASSERT_EQUALS(4U, db->scopeList.size());
// Find the scope for the Fred struct..
const Scope *fredScope = NULL;
const Scope *fredScope = nullptr;
for (std::list<Scope>::const_iterator scope = db->scopeList.begin(); scope != db->scopeList.end(); ++scope) {
if (scope->isClassOrStruct() && scope->className == "Fred")
fredScope = &(*scope);
}
ASSERT(fredScope != NULL);
if (fredScope == NULL)
ASSERT(fredScope != nullptr);
if (fredScope == nullptr)
return;
// The struct Fred has two functions, a constructor and a destructor
@ -1722,7 +1722,7 @@ private:
void symboldatabase42() { // only put variables in variable list
GET_SYMBOL_DB("void f() { extern int x(); }\n");
ASSERT(!!db);
const Scope * const fscope = db ? db->findScopeByName("f") : NULL;
const Scope * const fscope = db ? db->findScopeByName("f") : nullptr;
ASSERT(!!fscope);
ASSERT_EQUALS(0U, fscope ? fscope->varlist.size() : ~0U); // "x" is not a variable
}

View File

@ -587,7 +587,7 @@ private:
void isArithmeticalOp() const {
std::vector<std::string>::const_iterator test_op, test_ops_end = arithmeticalOps.end();
for (test_op = arithmeticalOps.begin(); test_op != test_ops_end; ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(true, tok.isArithmeticalOp());
}
@ -602,7 +602,7 @@ private:
std::vector<std::string>::const_iterator other_op, other_ops_end = other_ops.end();
for (other_op = other_ops.begin(); other_op != other_ops_end; ++other_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*other_op);
ASSERT_EQUALS_MSG(false, tok.isArithmeticalOp(), "Failing arithmetical operator: " + *other_op);
}
@ -618,7 +618,7 @@ private:
std::vector<std::string>::const_iterator test_op, test_ops_end = test_ops.end();
for (test_op = test_ops.begin(); test_op != test_ops_end; ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(true, tok.isOp());
}
@ -629,7 +629,7 @@ private:
std::vector<std::string>::const_iterator other_op, other_ops_end = other_ops.end();
for (other_op = other_ops.begin(); other_op != other_ops_end; ++other_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*other_op);
ASSERT_EQUALS_MSG(false, tok.isOp(), "Failing normal operator: " + *other_op);
}
@ -644,7 +644,7 @@ private:
std::vector<std::string>::const_iterator test_op, test_ops_end = test_ops.end();
for (test_op = test_ops.begin(); test_op != test_ops_end; ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(true, tok.isConstOp());
}
@ -656,7 +656,7 @@ private:
std::vector<std::string>::const_iterator other_op, other_ops_end = other_ops.end();
for (other_op = other_ops.begin(); other_op != other_ops_end; ++other_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*other_op);
ASSERT_EQUALS_MSG(false, tok.isConstOp(), "Failing normal operator: " + *other_op);
}
@ -672,7 +672,7 @@ private:
std::vector<std::string>::const_iterator test_op, test_ops_end = test_ops.end();
for (test_op = test_ops.begin(); test_op != test_ops_end; ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(true, tok.isExtendedOp());
}
@ -680,7 +680,7 @@ private:
// Negative test against assignment operators
std::vector<std::string>::const_iterator other_op, other_ops_end = assignmentOps.end();
for (other_op = assignmentOps.begin(); other_op != other_ops_end; ++other_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*other_op);
ASSERT_EQUALS_MSG(false, tok.isExtendedOp(), "Failing assignment operator: " + *other_op);
}
@ -689,7 +689,7 @@ private:
void isAssignmentOp() const {
std::vector<std::string>::const_iterator test_op, test_ops_end = assignmentOps.end();
for (test_op = assignmentOps.begin(); test_op != test_ops_end; ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(true, tok.isAssignmentOp());
}
@ -704,7 +704,7 @@ private:
std::vector<std::string>::const_iterator other_op, other_ops_end = other_ops.end();
for (other_op = other_ops.begin(); other_op != other_ops_end; ++other_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*other_op);
ASSERT_EQUALS_MSG(false, tok.isAssignmentOp(), "Failing assignment operator: " + *other_op);
}
@ -713,26 +713,26 @@ private:
void operators() const {
std::vector<std::string>::const_iterator test_op;
for (test_op = extendedOps.begin(); test_op != extendedOps.end(); ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(Token::eExtendedOp, tok.type());
}
for (test_op = logicalOps.begin(); test_op != logicalOps.end(); ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(Token::eLogicalOp, tok.type());
}
for (test_op = bitOps.begin(); test_op != bitOps.end(); ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(Token::eBitOp, tok.type());
}
for (test_op = comparisonOps.begin(); test_op != comparisonOps.end(); ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS(Token::eComparisonOp, tok.type());
}
Token tok(NULL);
Token tok(nullptr);
tok.str("++");
ASSERT_EQUALS(Token::eIncDecOp, tok.type());
tok.str("--");
@ -740,7 +740,7 @@ private:
}
void literals() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("\"foo\"");
ASSERT(tok.type() == Token::eString);
@ -771,13 +771,13 @@ private:
std::vector<std::string>::const_iterator test_op, test_ops_end = standard_types.end();
for (test_op = standard_types.begin(); test_op != test_ops_end; ++test_op) {
Token tok(NULL);
Token tok(nullptr);
tok.str(*test_op);
ASSERT_EQUALS_MSG(true, tok.isStandardType(), "Failing standard type: " + *test_op);
}
// Negative test
Token tok(0);
Token tok(nullptr);
tok.str("string");
ASSERT_EQUALS(false, tok.isStandardType());
@ -787,7 +787,7 @@ private:
}
void updateProperties() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("foobar");
ASSERT_EQUALS(true, tok.isName());
@ -800,7 +800,7 @@ private:
}
void updatePropertiesConcatStr() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("true");
ASSERT_EQUALS(true, tok.isBoolean());
@ -812,32 +812,32 @@ private:
}
void isNameGuarantees1() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("Name");
ASSERT_EQUALS(true, tok.isName());
}
void isNameGuarantees2() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("_name");
ASSERT_EQUALS(true, tok.isName());
}
void isNameGuarantees3() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("_123");
ASSERT_EQUALS(true, tok.isName());
}
void isNameGuarantees4() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("123456");
ASSERT_EQUALS(false, tok.isName());
ASSERT_EQUALS(true, tok.isNumber());
}
void isNameGuarantees5() const {
Token tok(NULL);
Token tok(nullptr);
tok.str("a123456");
ASSERT_EQUALS(true, tok.isName());
ASSERT_EQUALS(false, tok.isNumber());
@ -848,7 +848,7 @@ private:
givenACodeSampleToTokenize var("std::deque<std::set<int> > intsets;");
const Token* t = var.tokens()->findClosingBracket();
ASSERT(t == NULL);
ASSERT(t == nullptr);
}
void canFindMatchingBracketsInnerPair() const {
@ -879,10 +879,10 @@ private:
givenACodeSampleToTokenize var("X < (2 < 1) > x1;\n");
const Token* t = var.tokens()->next()->findClosingBracket();
ASSERT(t != NULL && t->str() == ">");
ASSERT(t != nullptr && t->str() == ">");
t = var.tokens()->tokAt(4)->findClosingBracket();
ASSERT(t != NULL && t->str() == ")");
ASSERT(t != nullptr && t->str() == ")");
}
};