Use nullptr instead of 0 or NULL (#936)
This commit is contained in:
parent
c1b0a07ab3
commit
b8cd7dbb5c
|
@ -78,7 +78,7 @@
|
||||||
/*static*/ FILE* CppCheckExecutor::exceptionOutput = stdout;
|
/*static*/ FILE* CppCheckExecutor::exceptionOutput = stdout;
|
||||||
|
|
||||||
CppCheckExecutor::CppCheckExecutor()
|
CppCheckExecutor::CppCheckExecutor()
|
||||||
: _settings(0), time1(0), errorOutput(nullptr), errorlist(false)
|
: _settings(nullptr), time1(0), errorOutput(nullptr), errorlist(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.reportProgress)
|
if (settings.reportProgress)
|
||||||
time1 = std::time(0);
|
time1 = std::time(nullptr);
|
||||||
|
|
||||||
if (!settings.outputFile.empty()) {
|
if (!settings.outputFile.empty()) {
|
||||||
errorOutput = new std::ofstream(settings.outputFile);
|
errorOutput = new std::ofstream(settings.outputFile);
|
||||||
|
@ -930,7 +930,7 @@ int CppCheckExecutor::check_internal(CppCheck& cppcheck, int /*argc*/, const cha
|
||||||
reportErr(ErrorLogger::ErrorMessage::getXMLFooter());
|
reportErr(ErrorLogger::ErrorMessage::getXMLFooter());
|
||||||
}
|
}
|
||||||
|
|
||||||
_settings = 0;
|
_settings = nullptr;
|
||||||
if (returnValue)
|
if (returnValue)
|
||||||
return settings.exitCode;
|
return settings.exitCode;
|
||||||
else
|
else
|
||||||
|
|
|
@ -188,7 +188,7 @@ static void addFiles2(std::map<std::string, std::size_t> &files,
|
||||||
std::string new_path;
|
std::string new_path;
|
||||||
new_path.reserve(path.length() + 100);// prealloc some memory to avoid constant new/deletes in loop
|
new_path.reserve(path.length() + 100);// prealloc some memory to avoid constant new/deletes in loop
|
||||||
|
|
||||||
while ((readdir_r(dir, &entry, &dir_result) == 0) && (dir_result != NULL)) {
|
while ((readdir_r(dir, &entry, &dir_result) == 0) && (dir_result != nullptr)) {
|
||||||
|
|
||||||
if ((std::strcmp(dir_result->d_name, ".") == 0) ||
|
if ((std::strcmp(dir_result->d_name, ".") == 0) ||
|
||||||
(std::strcmp(dir_result->d_name, "..") == 0))
|
(std::strcmp(dir_result->d_name, "..") == 0))
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
Check::Check(const std::string &aname)
|
Check::Check(const std::string &aname)
|
||||||
: _tokenizer(0), _settings(0), _errorLogger(0), _name(aname)
|
: _tokenizer(nullptr), _settings(nullptr), _errorLogger(nullptr), _name(aname)
|
||||||
{
|
{
|
||||||
for (std::list<Check*>::iterator i = instances().begin(); i != instances().end(); ++i) {
|
for (std::list<Check*>::iterator i = instances().begin(); i != instances().end(); ++i) {
|
||||||
if ((*i)->name() > aname) {
|
if ((*i)->name() > aname) {
|
||||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
||||||
/** report an error */
|
/** report an error */
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
void reportError(const std::list<const Token *> &callstack, Severity::SeverityType severity, const T id, const U msg, const CWE &cwe, bool inconclusive) {
|
void reportError(const std::list<const Token *> &callstack, Severity::SeverityType severity, const T id, const U msg, const CWE &cwe, bool inconclusive) {
|
||||||
const ErrorLogger::ErrorMessage errmsg(callstack, _tokenizer?&_tokenizer->list:0, severity, id, msg, cwe, inconclusive);
|
const ErrorLogger::ErrorMessage errmsg(callstack, _tokenizer ? &_tokenizer->list : nullptr, severity, id, msg, cwe, inconclusive);
|
||||||
if (_errorLogger)
|
if (_errorLogger)
|
||||||
_errorLogger->reportErr(errmsg);
|
_errorLogger->reportErr(errmsg);
|
||||||
else
|
else
|
||||||
|
|
|
@ -52,7 +52,7 @@ void Check64BitPortability::pointerassignment()
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
for (std::size_t i = 0; i < functions; ++i) {
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||||
if (scope->function == 0 || !scope->function->hasBody()) // We only look for functions with a body
|
if (scope->function == nullptr || !scope->function->hasBody()) // We only look for functions with a body
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool retPointer = false;
|
bool retPointer = false;
|
||||||
|
|
|
@ -65,8 +65,8 @@ private:
|
||||||
void boostForeachError(const Token *tok);
|
void boostForeachError(const Token *tok);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckBoost c(0, settings, errorLogger);
|
CheckBoost c(nullptr, settings, errorLogger);
|
||||||
c.boostForeachError(0);
|
c.boostForeachError(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
|
|
@ -1299,7 +1299,7 @@ void CheckBufferOverrun::checkGlobalAndLocalVariable()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var == 0)
|
if (var == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const MathLib::bigint totalSize = size * static_cast<int>(sizeOfType(var->typeStartToken()));
|
const MathLib::bigint totalSize = size * static_cast<int>(sizeOfType(var->typeStartToken()));
|
||||||
|
|
|
@ -504,7 +504,7 @@ bool CheckClass::isBaseClassFunc(const Token *tok, const Scope *scope)
|
||||||
void CheckClass::initializeVarList(const Function &func, std::list<const Function *> &callstack, const Scope *scope, std::vector<Usage> &usage)
|
void CheckClass::initializeVarList(const Function &func, std::list<const Function *> &callstack, const Scope *scope, std::vector<Usage> &usage)
|
||||||
{
|
{
|
||||||
if (!func.functionScope)
|
if (!func.functionScope)
|
||||||
throw InternalError(0, "Internal Error: Invalid syntax"); // #5702
|
throw InternalError(nullptr, "Internal Error: Invalid syntax"); // #5702
|
||||||
bool initList = func.isConstructor();
|
bool initList = func.isConstructor();
|
||||||
const Token *ftok = func.arg->link()->next();
|
const Token *ftok = func.arg->link()->next();
|
||||||
int level = 0;
|
int level = 0;
|
||||||
|
@ -1022,7 +1022,7 @@ static const Scope* findFunctionOf(const Scope* scope)
|
||||||
return scope->functionOf;
|
return scope->functionOf;
|
||||||
scope = scope->nestedIn;
|
scope = scope->nestedIn;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckClass::checkMemset()
|
void CheckClass::checkMemset()
|
||||||
|
@ -1364,7 +1364,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_settings->library.isScopeNoReturn(last, 0)) {
|
if (_settings->library.isScopeNoReturn(last, nullptr)) {
|
||||||
// Typical wrong way to prohibit default assignment operator
|
// Typical wrong way to prohibit default assignment operator
|
||||||
// by always throwing an exception or calling a noreturn function
|
// by always throwing an exception or calling a noreturn function
|
||||||
operatorEqShouldBeLeftUnimplementedError(func->token);
|
operatorEqShouldBeLeftUnimplementedError(func->token);
|
||||||
|
@ -2049,7 +2049,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool&
|
||||||
|
|
||||||
void CheckClass::checkConstError(const Token *tok, const std::string &classname, const std::string &funcname, bool suggestStatic)
|
void CheckClass::checkConstError(const Token *tok, const std::string &classname, const std::string &funcname, bool suggestStatic)
|
||||||
{
|
{
|
||||||
checkConstError2(tok, 0, classname, funcname, suggestStatic);
|
checkConstError2(tok, nullptr, classname, funcname, suggestStatic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const std::string &classname, const std::string &funcname, bool suggestStatic)
|
void CheckClass::checkConstError2(const Token *tok1, const Token *tok2, const std::string &classname, const std::string &funcname, bool suggestStatic)
|
||||||
|
|
|
@ -197,8 +197,8 @@ private:
|
||||||
c.memsetError(nullptr, "memfunc", "classname", "class");
|
c.memsetError(nullptr, "memfunc", "classname", "class");
|
||||||
c.memsetErrorReference(nullptr, "memfunc", "class");
|
c.memsetErrorReference(nullptr, "memfunc", "class");
|
||||||
c.memsetErrorFloat(nullptr, "class");
|
c.memsetErrorFloat(nullptr, "class");
|
||||||
c.mallocOnClassWarning(nullptr, "malloc", 0);
|
c.mallocOnClassWarning(nullptr, "malloc", nullptr);
|
||||||
c.mallocOnClassError(nullptr, "malloc", 0, "std::string");
|
c.mallocOnClassError(nullptr, "malloc", nullptr, "std::string");
|
||||||
c.operatorEqReturnError(nullptr, "class");
|
c.operatorEqReturnError(nullptr, "class");
|
||||||
c.virtualDestructorError(nullptr, "Base", "Derived", false);
|
c.virtualDestructorError(nullptr, "Base", "Derived", false);
|
||||||
c.thisSubtractionError(nullptr);
|
c.thisSubtractionError(nullptr);
|
||||||
|
@ -208,10 +208,10 @@ private:
|
||||||
c.operatorEqToSelfError(nullptr);
|
c.operatorEqToSelfError(nullptr);
|
||||||
c.checkConstError(nullptr, "class", "function", false);
|
c.checkConstError(nullptr, "class", "function", false);
|
||||||
c.checkConstError(nullptr, "class", "function", true);
|
c.checkConstError(nullptr, "class", "function", true);
|
||||||
c.initializerListError(nullptr, 0, "class", "variable");
|
c.initializerListError(nullptr, nullptr, "class", "variable");
|
||||||
c.suggestInitializationList(nullptr, "variable");
|
c.suggestInitializationList(nullptr, "variable");
|
||||||
c.selfInitializationError(nullptr, "var");
|
c.selfInitializationError(nullptr, "var");
|
||||||
c.duplInheritedMembersError(nullptr, 0, "class", "class", "variable", false, false);
|
c.duplInheritedMembersError(nullptr, nullptr, "class", "class", "variable", false, false);
|
||||||
c.copyCtorAndEqOperatorError(nullptr, "class", false, false);
|
c.copyCtorAndEqOperatorError(nullptr, "class", false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void CheckCondition::assignIf()
|
||||||
|
|
||||||
if (Token::Match(tok->tokAt(-2), "[;{}] %var% =")) {
|
if (Token::Match(tok->tokAt(-2), "[;{}] %var% =")) {
|
||||||
const Variable *var = tok->previous()->variable();
|
const Variable *var = tok->previous()->variable();
|
||||||
if (var == 0)
|
if (var == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
char bitop = '\0';
|
char bitop = '\0';
|
||||||
|
@ -241,7 +241,7 @@ static void getnumchildren(const Token *tok, std::list<MathLib::bigint> &numchil
|
||||||
/* Return whether tok is in the body for a function returning a boolean. */
|
/* Return whether tok is in the body for a function returning a boolean. */
|
||||||
static bool inBooleanFunction(const Token *tok)
|
static bool inBooleanFunction(const Token *tok)
|
||||||
{
|
{
|
||||||
const Scope *scope = tok ? tok->scope() : 0;
|
const Scope *scope = tok ? tok->scope() : nullptr;
|
||||||
while (scope && scope->isLocal())
|
while (scope && scope->isLocal())
|
||||||
scope = scope->nestedIn;
|
scope = scope->nestedIn;
|
||||||
if (scope && scope->type == Scope::eFunction) {
|
if (scope && scope->type == Scope::eFunction) {
|
||||||
|
|
|
@ -138,12 +138,12 @@ private:
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckCondition c(nullptr, settings, errorLogger);
|
CheckCondition c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
c.assignIfError(nullptr, 0, emptyString, false);
|
c.assignIfError(nullptr, nullptr, emptyString, false);
|
||||||
c.badBitmaskCheckError(nullptr);
|
c.badBitmaskCheckError(nullptr);
|
||||||
c.comparisonError(nullptr, "&", 6, "==", 1, false);
|
c.comparisonError(nullptr, "&", 6, "==", 1, false);
|
||||||
c.multiConditionError(nullptr,1);
|
c.multiConditionError(nullptr,1);
|
||||||
c.mismatchingBitAndError(nullptr, 0xf0, 0, 1);
|
c.mismatchingBitAndError(nullptr, 0xf0, nullptr, 1);
|
||||||
c.oppositeInnerConditionError(nullptr, 0);
|
c.oppositeInnerConditionError(nullptr, nullptr);
|
||||||
c.incorrectLogicOperatorError(nullptr, "foo > 3 && foo < 4", true, false);
|
c.incorrectLogicOperatorError(nullptr, "foo > 3 && foo < 4", true, false);
|
||||||
c.redundantConditionError(nullptr, "If x > 11 the condition x > 10 is always true.", false);
|
c.redundantConditionError(nullptr, "If x > 11 the condition x > 10 is always true.", false);
|
||||||
c.moduloAlwaysTrueFalseError(nullptr, "1");
|
c.moduloAlwaysTrueFalseError(nullptr, "1");
|
||||||
|
|
|
@ -144,7 +144,7 @@ private:
|
||||||
c.rethrowCopyError(nullptr, "varname");
|
c.rethrowCopyError(nullptr, "varname");
|
||||||
c.catchExceptionByValueError(nullptr);
|
c.catchExceptionByValueError(nullptr);
|
||||||
c.noexceptThrowError(nullptr);
|
c.noexceptThrowError(nullptr);
|
||||||
c.unhandledExceptionSpecificationError(nullptr, 0, "funcname");
|
c.unhandledExceptionSpecificationError(nullptr, nullptr, "funcname");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Short description of class (for --doc) */
|
/** Short description of class (for --doc) */
|
||||||
|
|
|
@ -1413,7 +1413,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings,
|
||||||
top = top->astParent();
|
top = top->astParent();
|
||||||
const ValueType *valuetype = top->argumentType();
|
const ValueType *valuetype = top->argumentType();
|
||||||
if (valuetype && valuetype->type >= ValueType::Type::BOOL) {
|
if (valuetype && valuetype->type >= ValueType::Type::BOOL) {
|
||||||
typeToken = tempToken = new Token(0);
|
typeToken = tempToken = new Token(nullptr);
|
||||||
if (valuetype->pointer && valuetype->constness & 1) {
|
if (valuetype->pointer && valuetype->constness & 1) {
|
||||||
tempToken->str("const");
|
tempToken->str("const");
|
||||||
tempToken->insertToken("a");
|
tempToken->insertToken("a");
|
||||||
|
@ -1490,7 +1490,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings,
|
||||||
if (function->retType->classScope->enumType)
|
if (function->retType->classScope->enumType)
|
||||||
typeToken = function->retType->classScope->enumType;
|
typeToken = function->retType->classScope->enumType;
|
||||||
else {
|
else {
|
||||||
tempToken = new Token(0);
|
tempToken = new Token(nullptr);
|
||||||
tempToken->fileIndex(tok1->fileIndex());
|
tempToken->fileIndex(tok1->fileIndex());
|
||||||
tempToken->linenr(tok1->linenr());
|
tempToken->linenr(tok1->linenr());
|
||||||
tempToken->str("int");
|
tempToken->str("int");
|
||||||
|
@ -1511,7 +1511,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings,
|
||||||
if (function->retType->classScope->enumType)
|
if (function->retType->classScope->enumType)
|
||||||
typeToken = function->retType->classScope->enumType;
|
typeToken = function->retType->classScope->enumType;
|
||||||
else {
|
else {
|
||||||
tempToken = new Token(0);
|
tempToken = new Token(nullptr);
|
||||||
tempToken->fileIndex(tok1->fileIndex());
|
tempToken->fileIndex(tok1->fileIndex());
|
||||||
tempToken->linenr(tok1->linenr());
|
tempToken->linenr(tok1->linenr());
|
||||||
tempToken->str("int");
|
tempToken->str("int");
|
||||||
|
@ -1536,7 +1536,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings,
|
||||||
// check for some common well known functions
|
// check for some common well known functions
|
||||||
else if (isCPP && ((Token::Match(tok1->previous(), "%var% . size|empty|c_str ( ) [,)]") && isStdContainer(tok1->previous())) ||
|
else if (isCPP && ((Token::Match(tok1->previous(), "%var% . size|empty|c_str ( ) [,)]") && isStdContainer(tok1->previous())) ||
|
||||||
(Token::Match(tok1->previous(), "] . size|empty|c_str ( ) [,)]") && isStdContainer(tok1->previous()->link()->previous())))) {
|
(Token::Match(tok1->previous(), "] . size|empty|c_str ( ) [,)]") && isStdContainer(tok1->previous()->link()->previous())))) {
|
||||||
tempToken = new Token(0);
|
tempToken = new Token(nullptr);
|
||||||
tempToken->fileIndex(tok1->fileIndex());
|
tempToken->fileIndex(tok1->fileIndex());
|
||||||
tempToken->linenr(tok1->linenr());
|
tempToken->linenr(tok1->linenr());
|
||||||
if (tok1->next()->str() == "size") {
|
if (tok1->next()->str() == "size") {
|
||||||
|
@ -1576,8 +1576,8 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings,
|
||||||
variableInfo = varTok->variable();
|
variableInfo = varTok->variable();
|
||||||
|
|
||||||
if (!variableInfo || !isStdVectorOrString()) {
|
if (!variableInfo || !isStdVectorOrString()) {
|
||||||
variableInfo = 0;
|
variableInfo = nullptr;
|
||||||
typeToken = 0;
|
typeToken = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1597,7 +1597,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * arg, const Settings *settings,
|
||||||
if (variableInfo->type() && variableInfo->type()->classScope && variableInfo->type()->classScope->enumType)
|
if (variableInfo->type() && variableInfo->type()->classScope && variableInfo->type()->classScope->enumType)
|
||||||
typeToken = variableInfo->type()->classScope->enumType;
|
typeToken = variableInfo->type()->classScope->enumType;
|
||||||
else {
|
else {
|
||||||
tempToken = new Token(0);
|
tempToken = new Token(nullptr);
|
||||||
tempToken->fileIndex(tok1->fileIndex());
|
tempToken->fileIndex(tok1->fileIndex());
|
||||||
tempToken->linenr(tok1->linenr());
|
tempToken->linenr(tok1->linenr());
|
||||||
tempToken->str("int");
|
tempToken->str("int");
|
||||||
|
@ -1636,7 +1636,7 @@ bool CheckIO::ArgumentInfo::isStdVectorOrString()
|
||||||
_template = true;
|
_template = true;
|
||||||
return true;
|
return true;
|
||||||
} else if (variableInfo->isStlType(stl_string)) {
|
} else if (variableInfo->isStlType(stl_string)) {
|
||||||
tempToken = new Token(0);
|
tempToken = new Token(nullptr);
|
||||||
tempToken->fileIndex(variableInfo->typeStartToken()->fileIndex());
|
tempToken->fileIndex(variableInfo->typeStartToken()->fileIndex());
|
||||||
tempToken->linenr(variableInfo->typeStartToken()->linenr());
|
tempToken->linenr(variableInfo->typeStartToken()->linenr());
|
||||||
if (variableInfo->typeStartToken()->strAt(2) == "string")
|
if (variableInfo->typeStartToken()->strAt(2) == "string")
|
||||||
|
@ -1654,7 +1654,7 @@ bool CheckIO::ArgumentInfo::isStdVectorOrString()
|
||||||
_template = true;
|
_template = true;
|
||||||
return true;
|
return true;
|
||||||
} else if (Token::Match(nameTok, "std :: string|wstring")) {
|
} else if (Token::Match(nameTok, "std :: string|wstring")) {
|
||||||
tempToken = new Token(0);
|
tempToken = new Token(nullptr);
|
||||||
tempToken->fileIndex(variableInfo->typeStartToken()->fileIndex());
|
tempToken->fileIndex(variableInfo->typeStartToken()->fileIndex());
|
||||||
tempToken->linenr(variableInfo->typeStartToken()->linenr());
|
tempToken->linenr(variableInfo->typeStartToken()->linenr());
|
||||||
if (nameTok->strAt(2) == "string")
|
if (nameTok->strAt(2) == "string")
|
||||||
|
|
|
@ -299,7 +299,7 @@ void CheckMemoryLeak::reportErr(const Token *tok, Severity::SeverityType severit
|
||||||
|
|
||||||
void CheckMemoryLeak::reportErr(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe) const
|
void CheckMemoryLeak::reportErr(const std::list<const Token *> &callstack, Severity::SeverityType severity, const std::string &id, const std::string &msg, const CWE &cwe) const
|
||||||
{
|
{
|
||||||
const ErrorLogger::ErrorMessage errmsg(callstack, tokenizer?&tokenizer->list:0, severity, id, msg, cwe, false);
|
const ErrorLogger::ErrorMessage errmsg(callstack, tokenizer ? &tokenizer->list : nullptr, severity, id, msg, cwe, false);
|
||||||
if (errorLogger)
|
if (errorLogger)
|
||||||
errorLogger->reportErr(errmsg);
|
errorLogger->reportErr(errmsg);
|
||||||
else
|
else
|
||||||
|
@ -527,7 +527,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
||||||
{
|
{
|
||||||
if (test_white_list(tok->str(), _settings, tokenizer->isCPP())) {
|
if (test_white_list(tok->str(), _settings, tokenizer->isCPP())) {
|
||||||
if (call_func_keywords.find(tok->str())!=call_func_keywords.end())
|
if (call_func_keywords.find(tok->str())!=call_func_keywords.end())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
// is the varid a parameter?
|
// is the varid a parameter?
|
||||||
for (const Token *tok2 = tok->tokAt(2); tok2 && tok2 != tok->linkAt(1); tok2 = tok2->next()) {
|
for (const Token *tok2 = tok->tokAt(2); tok2 && tok2 != tok->linkAt(1); tok2 = tok2->next()) {
|
||||||
|
@ -548,14 +548,14 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings->library.isnoreturn(tok) && tok->strAt(-1) != "=")
|
if (_settings->library.isnoreturn(tok) && tok->strAt(-1) != "=")
|
||||||
return "exit";
|
return "exit";
|
||||||
|
|
||||||
if (varid > 0 && (getReallocationType(tok, varid) != No || getDeallocationType(tok, varid) != No))
|
if (varid > 0 && (getReallocationType(tok, varid) != No || getDeallocationType(tok, varid) != No))
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
if (callstack.size() > 2)
|
if (callstack.size() > 2)
|
||||||
return "dealloc_";
|
return "dealloc_";
|
||||||
|
@ -571,7 +571,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
||||||
if (varid == 0) {
|
if (varid == 0) {
|
||||||
const Function* func = tok->function();
|
const Function* func = tok->function();
|
||||||
if (!func || !func->hasBody())
|
if (!func || !func->hasBody())
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
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);
|
||||||
|
@ -669,7 +669,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
||||||
if (Token::Match(tok, "%varid% . %name% [,)]", varid))
|
if (Token::Match(tok, "%varid% . %name% [,)]", varid))
|
||||||
return "use";
|
return "use";
|
||||||
}
|
}
|
||||||
return (eq || _settings->experimental) ? 0 : "callfunc";
|
return (eq || _settings->experimental) ? nullptr : "callfunc";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
std::set<unsigned int> extravar;
|
std::set<unsigned int> extravar;
|
||||||
|
|
||||||
// The first token should be ";"
|
// The first token should be ";"
|
||||||
Token* rethead = new Token(0);
|
Token* rethead = new Token(nullptr);
|
||||||
rethead->str(";");
|
rethead->str(";");
|
||||||
rethead->linenr(tok->linenr());
|
rethead->linenr(tok->linenr());
|
||||||
rethead->fileIndex(tok->fileIndex());
|
rethead->fileIndex(tok->fileIndex());
|
||||||
|
@ -802,7 +802,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
// todo: check how the return value is used.
|
// todo: check how the return value is used.
|
||||||
if (!Token::Match(tok->previous(), "[;{}]")) {
|
if (!Token::Match(tok->previous(), "[;{}]")) {
|
||||||
TokenList::deleteTokens(rethead);
|
TokenList::deleteTokens(rethead);
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
alloc = Malloc;
|
alloc = Malloc;
|
||||||
tok = tok->next()->link();
|
tok = tok->next()->link();
|
||||||
|
@ -2060,7 +2060,7 @@ void CheckMemoryLeakInFunction::checkScope(const Token *startTok, const std::str
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the variable is not allocated at all => no memory leak
|
// If the variable is not allocated at all => no memory leak
|
||||||
if (Token::findsimplematch(tok, "alloc") == 0) {
|
if (Token::findsimplematch(tok, "alloc") == nullptr) {
|
||||||
TokenList::deleteTokens(tok);
|
TokenList::deleteTokens(tok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2072,7 +2072,7 @@ void CheckMemoryLeakInFunction::checkScope(const Token *startTok, const std::str
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the variable is not allocated at all => no memory leak
|
// If the variable is not allocated at all => no memory leak
|
||||||
if (Token::findsimplematch(tok, "alloc") == 0) {
|
if (Token::findsimplematch(tok, "alloc") == nullptr) {
|
||||||
TokenList::deleteTokens(tok);
|
TokenList::deleteTokens(tok);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2113,7 +2113,7 @@ void CheckMemoryLeakInFunction::checkScope(const Token *startTok, const std::str
|
||||||
// Unhandled case..
|
// Unhandled case..
|
||||||
if (!noerr)
|
if (!noerr)
|
||||||
reportError(first, Severity::debug, "debug",
|
reportError(first, Severity::debug, "debug",
|
||||||
"inconclusive leak of " + varname + ": " + tok->stringifyList(false, false, false, false, false, 0, 0));
|
"inconclusive leak of " + varname + ": " + tok->stringifyList(false, false, false, false, false, nullptr, nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenList::deleteTokens(tok);
|
TokenList::deleteTokens(tok);
|
||||||
|
@ -2196,7 +2196,7 @@ static bool isInMemberFunc(const Scope* scope)
|
||||||
while (scope->nestedIn && !scope->functionOf)
|
while (scope->nestedIn && !scope->functionOf)
|
||||||
scope = scope->nestedIn;
|
scope = scope->nestedIn;
|
||||||
|
|
||||||
return (scope->functionOf != 0);
|
return (scope->functionOf != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckMemoryLeakInFunction::check()
|
void CheckMemoryLeakInFunction::check()
|
||||||
|
|
|
@ -181,7 +181,7 @@ public:
|
||||||
class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak {
|
class CPPCHECKLIB CheckMemoryLeakInFunction : private Check, public CheckMemoryLeak {
|
||||||
public:
|
public:
|
||||||
/** @brief This constructor is used when registering this class */
|
/** @brief This constructor is used when registering this class */
|
||||||
CheckMemoryLeakInFunction() : Check(myName()), CheckMemoryLeak(0, 0, 0), symbolDatabase(nullptr) {
|
CheckMemoryLeakInFunction() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr), symbolDatabase(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief This constructor is used when running checks */
|
/** @brief This constructor is used when running checks */
|
||||||
|
@ -191,7 +191,7 @@ public:
|
||||||
if (tokenizr)
|
if (tokenizr)
|
||||||
symbolDatabase = tokenizr->getSymbolDatabase();
|
symbolDatabase = tokenizr->getSymbolDatabase();
|
||||||
else
|
else
|
||||||
symbolDatabase = 0;
|
symbolDatabase = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief run all simplified checks */
|
/** @brief run all simplified checks */
|
||||||
|
@ -329,7 +329,7 @@ private:
|
||||||
|
|
||||||
class CPPCHECKLIB CheckMemoryLeakInClass : private Check, private CheckMemoryLeak {
|
class CPPCHECKLIB CheckMemoryLeakInClass : private Check, private CheckMemoryLeak {
|
||||||
public:
|
public:
|
||||||
CheckMemoryLeakInClass() : Check(myName()), CheckMemoryLeak(0, 0, 0) {
|
CheckMemoryLeakInClass() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckMemoryLeakInClass(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
CheckMemoryLeakInClass(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
|
@ -356,9 +356,9 @@ private:
|
||||||
void unsafeClassError(const Token *tok, const std::string &classname, const std::string &varname);
|
void unsafeClassError(const Token *tok, const std::string &classname, const std::string &varname);
|
||||||
|
|
||||||
void getErrorMessages(ErrorLogger *e, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *e, const Settings *settings) const {
|
||||||
CheckMemoryLeakInClass c(0, settings, e);
|
CheckMemoryLeakInClass c(nullptr, settings, e);
|
||||||
c.publicAllocationError(0, "varname");
|
c.publicAllocationError(nullptr, "varname");
|
||||||
c.unsafeClassError(0, "class", "class::varname");
|
c.unsafeClassError(nullptr, "class", "class::varname");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string myName() {
|
static std::string myName() {
|
||||||
|
@ -376,7 +376,7 @@ private:
|
||||||
|
|
||||||
class CPPCHECKLIB CheckMemoryLeakStructMember : private Check, private CheckMemoryLeak {
|
class CPPCHECKLIB CheckMemoryLeakStructMember : private Check, private CheckMemoryLeak {
|
||||||
public:
|
public:
|
||||||
CheckMemoryLeakStructMember() : Check(myName()), CheckMemoryLeak(0, 0, 0) {
|
CheckMemoryLeakStructMember() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckMemoryLeakStructMember(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
CheckMemoryLeakStructMember(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
|
@ -415,7 +415,7 @@ private:
|
||||||
|
|
||||||
class CPPCHECKLIB CheckMemoryLeakNoVar : private Check, private CheckMemoryLeak {
|
class CPPCHECKLIB CheckMemoryLeakNoVar : private Check, private CheckMemoryLeak {
|
||||||
public:
|
public:
|
||||||
CheckMemoryLeakNoVar() : Check(myName()), CheckMemoryLeak(0, 0, 0) {
|
CheckMemoryLeakNoVar() : Check(myName()), CheckMemoryLeak(nullptr, nullptr, nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckMemoryLeakNoVar(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
CheckMemoryLeakNoVar(const Tokenizer *tokenizr, const Settings *settings, ErrorLogger *errLog)
|
||||||
|
|
|
@ -387,7 +387,7 @@ void CheckNullPointer::nullConstantDereference()
|
||||||
const std::size_t functions = symbolDatabase->functionScopes.size();
|
const std::size_t functions = symbolDatabase->functionScopes.size();
|
||||||
for (std::size_t i = 0; i < functions; ++i) {
|
for (std::size_t i = 0; i < functions; ++i) {
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||||
if (scope->function == 0 || !scope->function->hasBody()) // We only look for functions with a body
|
if (scope->function == nullptr || !scope->function->hasBody()) // We only look for functions with a body
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const Token *tok = scope->classStart;
|
const Token *tok = scope->classStart;
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& us
|
||||||
if (Token::simpleMatch(tok, "for ("))
|
if (Token::simpleMatch(tok, "for ("))
|
||||||
forHeadEnd = tok->linkAt(1);
|
forHeadEnd = tok->linkAt(1);
|
||||||
if (tok == forHeadEnd)
|
if (tok == forHeadEnd)
|
||||||
forHeadEnd = 0;
|
forHeadEnd = nullptr;
|
||||||
|
|
||||||
if (loopVariable && noContinue && tok->scope() == scope && !forHeadEnd && scope->type != Scope::eSwitch && Token::Match(tok, "%varid% =", var->declarationId())) { // Assigned in outer scope.
|
if (loopVariable && noContinue && tok->scope() == scope && !forHeadEnd && scope->type != Scope::eSwitch && Token::Match(tok, "%varid% =", var->declarationId())) { // Assigned in outer scope.
|
||||||
loopVariable = false;
|
loopVariable = false;
|
||||||
|
|
|
@ -275,8 +275,8 @@ private:
|
||||||
|
|
||||||
//performance
|
//performance
|
||||||
c.redundantCopyError(nullptr, "varname");
|
c.redundantCopyError(nullptr, "varname");
|
||||||
c.redundantCopyError(nullptr, 0, "var");
|
c.redundantCopyError(nullptr, nullptr, "var");
|
||||||
c.redundantAssignmentError(nullptr, 0, "var", false);
|
c.redundantAssignmentError(nullptr, nullptr, "var", false);
|
||||||
|
|
||||||
// style/warning
|
// style/warning
|
||||||
c.checkComparisonFunctionIsAlwaysTrueOrFalseError(nullptr, "isless","varName",false);
|
c.checkComparisonFunctionIsAlwaysTrueOrFalseError(nullptr, "isless","varName",false);
|
||||||
|
@ -288,15 +288,15 @@ private:
|
||||||
c.unknownSignCharArrayIndexError(nullptr);
|
c.unknownSignCharArrayIndexError(nullptr);
|
||||||
c.charBitOpError(nullptr);
|
c.charBitOpError(nullptr);
|
||||||
c.variableScopeError(nullptr, "varname");
|
c.variableScopeError(nullptr, "varname");
|
||||||
c.redundantAssignmentInSwitchError(nullptr, 0, "var");
|
c.redundantAssignmentInSwitchError(nullptr, nullptr, "var");
|
||||||
c.redundantCopyInSwitchError(nullptr, 0, "var");
|
c.redundantCopyInSwitchError(nullptr, nullptr, "var");
|
||||||
c.suspiciousCaseInSwitchError(nullptr, "||");
|
c.suspiciousCaseInSwitchError(nullptr, "||");
|
||||||
c.suspiciousEqualityComparisonError(nullptr);
|
c.suspiciousEqualityComparisonError(nullptr);
|
||||||
c.selfAssignmentError(nullptr, "varname");
|
c.selfAssignmentError(nullptr, "varname");
|
||||||
c.clarifyCalculationError(nullptr, "+");
|
c.clarifyCalculationError(nullptr, "+");
|
||||||
c.clarifyStatementError(nullptr);
|
c.clarifyStatementError(nullptr);
|
||||||
c.duplicateBranchError(nullptr, 0);
|
c.duplicateBranchError(nullptr, nullptr);
|
||||||
c.duplicateExpressionError(nullptr, 0, "&&");
|
c.duplicateExpressionError(nullptr, nullptr, "&&");
|
||||||
c.duplicateExpressionTernaryError(nullptr);
|
c.duplicateExpressionTernaryError(nullptr);
|
||||||
c.duplicateBreakError(nullptr, false);
|
c.duplicateBreakError(nullptr, false);
|
||||||
c.unreachableCodeError(nullptr, false);
|
c.unreachableCodeError(nullptr, false);
|
||||||
|
|
|
@ -188,19 +188,19 @@ void CheckSizeof::checkSizeofForPointerSize()
|
||||||
// Only keep variables which are pointers
|
// Only keep variables which are pointers
|
||||||
const Variable *var = variable->variable();
|
const Variable *var = variable->variable();
|
||||||
if (!var || !var->isPointer() || var->isArray()) {
|
if (!var || !var->isPointer() || var->isArray()) {
|
||||||
variable = 0;
|
variable = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variable2) {
|
if (variable2) {
|
||||||
var = variable2->variable();
|
var = variable2->variable();
|
||||||
if (!var || !var->isPointer() || var->isArray()) {
|
if (!var || !var->isPointer() || var->isArray()) {
|
||||||
variable2 = 0;
|
variable2 = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no pointer variable at this point, there is
|
// If there are no pointer variable at this point, there is
|
||||||
// no need to continue
|
// no need to continue
|
||||||
if (variable == 0 && variable2 == 0) {
|
if (variable == nullptr && variable2 == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ private:
|
||||||
c.string_c_strReturn(nullptr);
|
c.string_c_strReturn(nullptr);
|
||||||
c.string_c_strParam(nullptr, 0);
|
c.string_c_strParam(nullptr, 0);
|
||||||
c.sizeError(nullptr);
|
c.sizeError(nullptr);
|
||||||
c.missingComparisonError(nullptr, 0);
|
c.missingComparisonError(nullptr, nullptr);
|
||||||
c.redundantIfRemoveError(nullptr);
|
c.redundantIfRemoveError(nullptr);
|
||||||
c.autoPointerError(nullptr);
|
c.autoPointerError(nullptr);
|
||||||
c.autoPointerContainerError(nullptr);
|
c.autoPointerContainerError(nullptr);
|
||||||
|
|
|
@ -101,7 +101,7 @@ private:
|
||||||
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const {
|
||||||
CheckString c(nullptr, settings, errorLogger);
|
CheckString c(nullptr, settings, errorLogger);
|
||||||
|
|
||||||
c.stringLiteralWriteError(nullptr,0);
|
c.stringLiteralWriteError(nullptr, nullptr);
|
||||||
c.sprintfOverlappingDataError(nullptr, "varname");
|
c.sprintfOverlappingDataError(nullptr, "varname");
|
||||||
c.strPlusCharError(nullptr);
|
c.strPlusCharError(nullptr);
|
||||||
c.incorrectStringCompareError(nullptr, "substr", "\"Hello World\"");
|
c.incorrectStringCompareError(nullptr, "substr", "\"Hello World\"");
|
||||||
|
|
|
@ -127,7 +127,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doMarkup // only check source files
|
if (!doMarkup // only check source files
|
||||||
&& settings->library.isexporter(tok->str()) && tok->next() != 0) {
|
&& settings->library.isexporter(tok->str()) && tok->next() != nullptr) {
|
||||||
const Token * propToken = tok->next();
|
const Token * propToken = tok->next();
|
||||||
while (propToken && propToken->str() != ")") {
|
while (propToken && propToken->str() != ")") {
|
||||||
if (settings->library.isexportedprefix(tok->str(), propToken->str())) {
|
if (settings->library.isexportedprefix(tok->str(), propToken->str())) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public:
|
||||||
bool modified = false,
|
bool modified = false,
|
||||||
bool allocateMemory = false) :
|
bool allocateMemory = false) :
|
||||||
_var(var),
|
_var(var),
|
||||||
_lastAccess(var?var->nameToken():0),
|
_lastAccess(var ? var->nameToken() : nullptr),
|
||||||
_type(type),
|
_type(type),
|
||||||
_read(read),
|
_read(read),
|
||||||
_write(write),
|
_write(write),
|
||||||
|
@ -387,7 +387,7 @@ Variables::VariableUsage *Variables::find(unsigned int varid)
|
||||||
if (i != _varUsage.end())
|
if (i != _varUsage.end())
|
||||||
return &i->second;
|
return &i->second;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Variables::enterScope()
|
void Variables::enterScope()
|
||||||
|
|
|
@ -134,7 +134,7 @@ unsigned int CppCheck::processFile(const std::string& filename, const std::strin
|
||||||
plistFile.close();
|
plistFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckUnusedFunctions checkUnusedFunctions(0,0,0);
|
CheckUnusedFunctions checkUnusedFunctions(nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
bool internalErrorFound(false);
|
bool internalErrorFound(false);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -235,7 +235,7 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem != 5)
|
if (elem != 5)
|
||||||
throw InternalError(0, "Internal Error: Deserialization of error message failed");
|
throw InternalError(nullptr, "Internal Error: Deserialization of error message failed");
|
||||||
|
|
||||||
_id = results[0];
|
_id = results[0];
|
||||||
_severity = Severity::fromString(results[1]);
|
_severity = Severity::fromString(results[1]);
|
||||||
|
@ -262,10 +262,10 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
|
||||||
|
|
||||||
const std::string::size_type colonPos = temp.find(':');
|
const std::string::size_type colonPos = temp.find(':');
|
||||||
if (colonPos == std::string::npos)
|
if (colonPos == std::string::npos)
|
||||||
throw InternalError(0, "Internal Error: No colon found in <filename:line> pattern");
|
throw InternalError(nullptr, "Internal Error: No colon found in <filename:line> pattern");
|
||||||
const std::string::size_type tabPos = temp.find('\t');
|
const std::string::size_type tabPos = temp.find('\t');
|
||||||
if (tabPos == std::string::npos)
|
if (tabPos == std::string::npos)
|
||||||
throw InternalError(0, "Internal Error: No tab found in <filename:line> pattern");
|
throw InternalError(nullptr, "Internal Error: No tab found in <filename:line> pattern");
|
||||||
|
|
||||||
const std::string tempinfo = temp.substr(tabPos + 1);
|
const std::string tempinfo = temp.substr(tabPos + 1);
|
||||||
temp.erase(tabPos);
|
temp.erase(tabPos);
|
||||||
|
@ -337,7 +337,7 @@ std::string ErrorLogger::ErrorMessage::fixInvalidChars(const std::string& raw)
|
||||||
|
|
||||||
std::string ErrorLogger::ErrorMessage::toXML() const
|
std::string ErrorLogger::ErrorMessage::toXML() const
|
||||||
{
|
{
|
||||||
tinyxml2::XMLPrinter printer(0, false, 2);
|
tinyxml2::XMLPrinter printer(nullptr, false, 2);
|
||||||
printer.OpenElement("error", false);
|
printer.OpenElement("error", false);
|
||||||
printer.PushAttribute("id", _id.c_str());
|
printer.PushAttribute("id", _id.c_str());
|
||||||
printer.PushAttribute("severity", Severity::toString(_severity).c_str());
|
printer.PushAttribute("severity", Severity::toString(_severity).c_str());
|
||||||
|
|
|
@ -711,7 +711,7 @@ bool Library::isargvalid(const Token *ftok, int argnr, const MathLib::bigint arg
|
||||||
const ArgumentChecks *ac = getarg(ftok, argnr);
|
const ArgumentChecks *ac = getarg(ftok, argnr);
|
||||||
if (!ac || ac->valid.empty())
|
if (!ac || ac->valid.empty())
|
||||||
return true;
|
return true;
|
||||||
TokenList tokenList(0);
|
TokenList tokenList(nullptr);
|
||||||
std::istringstream istr(ac->valid + ',');
|
std::istringstream istr(ac->valid + ',');
|
||||||
tokenList.createTokens(istr);
|
tokenList.createTokens(istr);
|
||||||
for (Token *tok = tokenList.front(); tok; tok = tok->next()) {
|
for (Token *tok = tokenList.front(); tok; tok = tok->next()) {
|
||||||
|
@ -827,14 +827,14 @@ bool Library::isuninitargbad(const Token *ftok, int argnr) const
|
||||||
const Library::AllocFunc* Library::alloc(const Token *tok) const
|
const Library::AllocFunc* Library::alloc(const Token *tok) const
|
||||||
{
|
{
|
||||||
const std::string funcname = getFunctionName(tok);
|
const std::string funcname = getFunctionName(tok);
|
||||||
return isNotLibraryFunction(tok) && functions.find(funcname) != functions.end() ? 0 : getAllocDealloc(_alloc, funcname);
|
return isNotLibraryFunction(tok) && functions.find(funcname) != functions.end() ? nullptr : getAllocDealloc(_alloc, funcname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** get deallocation info for function */
|
/** get deallocation info for function */
|
||||||
const Library::AllocFunc* Library::dealloc(const Token *tok) const
|
const Library::AllocFunc* Library::dealloc(const Token *tok) const
|
||||||
{
|
{
|
||||||
const std::string funcname = getFunctionName(tok);
|
const std::string funcname = getFunctionName(tok);
|
||||||
return isNotLibraryFunction(tok) && functions.find(funcname) != functions.end() ? 0 : getAllocDealloc(_dealloc, funcname);
|
return isNotLibraryFunction(tok) && functions.find(funcname) != functions.end() ? nullptr : getAllocDealloc(_dealloc, funcname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** get allocation id for function */
|
/** get allocation id for function */
|
||||||
|
|
|
@ -49,7 +49,7 @@ MathLib::value::value(const std::string &s) :
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MathLib::isInt(s))
|
if (!MathLib::isInt(s))
|
||||||
throw InternalError(0, "Invalid value: " + s);
|
throw InternalError(nullptr, "Invalid value: " + s);
|
||||||
|
|
||||||
type = MathLib::value::INT;
|
type = MathLib::value::INT;
|
||||||
intValue = MathLib::toLongNumber(s);
|
intValue = MathLib::toLongNumber(s);
|
||||||
|
@ -147,9 +147,9 @@ MathLib::value MathLib::value::calc(char op, const MathLib::value &v1, const Mat
|
||||||
case '&':
|
case '&':
|
||||||
case '|':
|
case '|':
|
||||||
case '^':
|
case '^':
|
||||||
throw InternalError(0, "Invalid calculation");
|
throw InternalError(nullptr, "Invalid calculation");
|
||||||
default:
|
default:
|
||||||
throw InternalError(0, "Unhandled calculation");
|
throw InternalError(nullptr, "Unhandled calculation");
|
||||||
}
|
}
|
||||||
} else if (temp.isUnsigned) {
|
} else if (temp.isUnsigned) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -164,14 +164,14 @@ MathLib::value MathLib::value::calc(char op, const MathLib::value &v1, const Mat
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
if (v2.intValue == 0)
|
if (v2.intValue == 0)
|
||||||
throw InternalError(0, "Internal Error: Division by zero");
|
throw InternalError(nullptr, "Internal Error: Division by zero");
|
||||||
if (v1.intValue == std::numeric_limits<bigint>::min() && std::abs(v2.intValue)<=1)
|
if (v1.intValue == std::numeric_limits<bigint>::min() && std::abs(v2.intValue)<=1)
|
||||||
throw InternalError(0, "Internal Error: Division overflow");
|
throw InternalError(nullptr, "Internal Error: Division overflow");
|
||||||
temp.intValue /= (unsigned long long)v2.intValue;
|
temp.intValue /= (unsigned long long)v2.intValue;
|
||||||
break;
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
if (v2.intValue == 0)
|
if (v2.intValue == 0)
|
||||||
throw InternalError(0, "Internal Error: Division by zero");
|
throw InternalError(nullptr, "Internal Error: Division by zero");
|
||||||
temp.intValue %= (unsigned long long)v2.intValue;
|
temp.intValue %= (unsigned long long)v2.intValue;
|
||||||
break;
|
break;
|
||||||
case '&':
|
case '&':
|
||||||
|
@ -184,7 +184,7 @@ MathLib::value MathLib::value::calc(char op, const MathLib::value &v1, const Mat
|
||||||
temp.intValue ^= (unsigned long long)v2.intValue;
|
temp.intValue ^= (unsigned long long)v2.intValue;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw InternalError(0, "Unhandled calculation");
|
throw InternalError(nullptr, "Unhandled calculation");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
|
@ -199,14 +199,14 @@ MathLib::value MathLib::value::calc(char op, const MathLib::value &v1, const Mat
|
||||||
break;
|
break;
|
||||||
case '/':
|
case '/':
|
||||||
if (v2.intValue == 0)
|
if (v2.intValue == 0)
|
||||||
throw InternalError(0, "Internal Error: Division by zero");
|
throw InternalError(nullptr, "Internal Error: Division by zero");
|
||||||
if (v1.intValue == std::numeric_limits<bigint>::min() && std::abs(v2.intValue)<=1)
|
if (v1.intValue == std::numeric_limits<bigint>::min() && std::abs(v2.intValue)<=1)
|
||||||
throw InternalError(0, "Internal Error: Division overflow");
|
throw InternalError(nullptr, "Internal Error: Division overflow");
|
||||||
temp.intValue /= v2.intValue;
|
temp.intValue /= v2.intValue;
|
||||||
break;
|
break;
|
||||||
case '%':
|
case '%':
|
||||||
if (v2.intValue == 0)
|
if (v2.intValue == 0)
|
||||||
throw InternalError(0, "Internal Error: Division by zero");
|
throw InternalError(nullptr, "Internal Error: Division by zero");
|
||||||
temp.intValue %= v2.intValue;
|
temp.intValue %= v2.intValue;
|
||||||
break;
|
break;
|
||||||
case '&':
|
case '&':
|
||||||
|
@ -219,7 +219,7 @@ MathLib::value MathLib::value::calc(char op, const MathLib::value &v1, const Mat
|
||||||
temp.intValue ^= v2.intValue;
|
temp.intValue ^= v2.intValue;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw InternalError(0, "Unhandled calculation");
|
throw InternalError(nullptr, "Unhandled calculation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return temp;
|
return temp;
|
||||||
|
@ -267,7 +267,7 @@ MathLib::value MathLib::value::add(int v) const
|
||||||
MathLib::value MathLib::value::shiftLeft(const MathLib::value &v) const
|
MathLib::value MathLib::value::shiftLeft(const MathLib::value &v) const
|
||||||
{
|
{
|
||||||
if (!isInt() || !v.isInt())
|
if (!isInt() || !v.isInt())
|
||||||
throw InternalError(0, "Shift operand is not integer");
|
throw InternalError(nullptr, "Shift operand is not integer");
|
||||||
MathLib::value ret(*this);
|
MathLib::value ret(*this);
|
||||||
ret.intValue <<= v.intValue;
|
ret.intValue <<= v.intValue;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -276,7 +276,7 @@ MathLib::value MathLib::value::shiftLeft(const MathLib::value &v) const
|
||||||
MathLib::value MathLib::value::shiftRight(const MathLib::value &v) const
|
MathLib::value MathLib::value::shiftRight(const MathLib::value &v) const
|
||||||
{
|
{
|
||||||
if (!isInt() || !v.isInt())
|
if (!isInt() || !v.isInt())
|
||||||
throw InternalError(0, "Shift operand is not integer");
|
throw InternalError(nullptr, "Shift operand is not integer");
|
||||||
MathLib::value ret(*this);
|
MathLib::value ret(*this);
|
||||||
ret.intValue >>= v.intValue;
|
ret.intValue >>= v.intValue;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -358,7 +358,7 @@ MathLib::bigint MathLib::characterLiteralToLongNumber(const std::string& str)
|
||||||
|
|
||||||
// '\xF6'
|
// '\xF6'
|
||||||
if (str.size() == 4 && str.compare(0,2,"\\x")==0 && std::isxdigit(str[2]) && std::isxdigit(str[3])) {
|
if (str.size() == 4 && str.compare(0,2,"\\x")==0 && std::isxdigit(str[2]) && std::isxdigit(str[3])) {
|
||||||
return std::strtoul(str.substr(2).c_str(), NULL, 16);
|
return std::strtoul(str.substr(2).c_str(), nullptr, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
// '\123'
|
// '\123'
|
||||||
|
@ -386,14 +386,14 @@ std::string MathLib::normalizeCharacterLiteral(const std::string& iLiteral)
|
||||||
}
|
}
|
||||||
++idx;
|
++idx;
|
||||||
if (idx == iLiteralLen) {
|
if (idx == iLiteralLen) {
|
||||||
throw InternalError(0, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
throw InternalError(nullptr, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
||||||
}
|
}
|
||||||
switch (iLiteral[idx]) {
|
switch (iLiteral[idx]) {
|
||||||
case 'x':
|
case 'x':
|
||||||
// Hexa-decimal number: skip \x and interpret the next two characters
|
// Hexa-decimal number: skip \x and interpret the next two characters
|
||||||
{
|
{
|
||||||
if (++idx == iLiteralLen)
|
if (++idx == iLiteralLen)
|
||||||
throw InternalError(0, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
throw InternalError(nullptr, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
||||||
std::string tempBuf;
|
std::string tempBuf;
|
||||||
tempBuf.push_back(iLiteral[idx]);
|
tempBuf.push_back(iLiteral[idx]);
|
||||||
if (++idx != iLiteralLen)
|
if (++idx != iLiteralLen)
|
||||||
|
@ -405,7 +405,7 @@ std::string MathLib::normalizeCharacterLiteral(const std::string& iLiteral)
|
||||||
case 'U':
|
case 'U':
|
||||||
// Unicode string; just skip the \u or \U
|
// Unicode string; just skip the \u or \U
|
||||||
if (idx + 1 == iLiteralLen)
|
if (idx + 1 == iLiteralLen)
|
||||||
throw InternalError(0, "Internal Error. MathLib::characterLiteralToLongNumber: Unhandled char constant '" + iLiteral + "'.");
|
throw InternalError(nullptr, "Internal Error. MathLib::characterLiteralToLongNumber: Unhandled char constant '" + iLiteral + "'.");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Single digit octal number
|
// Single digit octal number
|
||||||
|
@ -452,13 +452,13 @@ std::string MathLib::normalizeCharacterLiteral(const std::string& iLiteral)
|
||||||
normalizedLiteral.push_back(iLiteral[idx]);
|
normalizedLiteral.push_back(iLiteral[idx]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw InternalError(0, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
throw InternalError(nullptr, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 2-3 digit octal number
|
// 2-3 digit octal number
|
||||||
if (!MathLib::isOctalDigit(iLiteral[idx]))
|
if (!MathLib::isOctalDigit(iLiteral[idx]))
|
||||||
throw InternalError(0, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
throw InternalError(nullptr, "Internal Error. MathLib::normalizeCharacterLiteral: Unhandled char constant '" + iLiteral + "'.");
|
||||||
std::string tempBuf;
|
std::string tempBuf;
|
||||||
tempBuf.push_back(iLiteral[idx]);
|
tempBuf.push_back(iLiteral[idx]);
|
||||||
++idx;
|
++idx;
|
||||||
|
@ -554,7 +554,7 @@ double MathLib::toDoubleNumber(const std::string &str)
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
if (isFloat(str)) // Workaround libc++ bug at http://llvm.org/bugs/show_bug.cgi?id=17782
|
if (isFloat(str)) // Workaround libc++ bug at http://llvm.org/bugs/show_bug.cgi?id=17782
|
||||||
// TODO : handle locale
|
// TODO : handle locale
|
||||||
return std::strtod(str.c_str(), 0);
|
return std::strtod(str.c_str(), nullptr);
|
||||||
#endif
|
#endif
|
||||||
// otherwise, convert to double
|
// otherwise, convert to double
|
||||||
std::istringstream istr(str);
|
std::istringstream istr(str);
|
||||||
|
@ -1136,7 +1136,7 @@ std::string MathLib::incdec(const std::string & var, const std::string & op)
|
||||||
return MathLib::subtract(var, "1");
|
return MathLib::subtract(var, "1");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
throw InternalError(0, std::string("Unexpected operation '") + op + "' in MathLib::incdec(). Please report this to Cppcheck developers.");
|
throw InternalError(nullptr, std::string("Unexpected operation '") + op + "' in MathLib::incdec(). Please report this to Cppcheck developers.");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MathLib::divide(const std::string &first, const std::string &second)
|
std::string MathLib::divide(const std::string &first, const std::string &second)
|
||||||
|
@ -1148,9 +1148,9 @@ std::string MathLib::divide(const std::string &first, const std::string &second)
|
||||||
const bigint a = toLongNumber(first);
|
const bigint a = toLongNumber(first);
|
||||||
const bigint b = toLongNumber(second);
|
const bigint b = toLongNumber(second);
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
throw InternalError(0, "Internal Error: Division by zero");
|
throw InternalError(nullptr, "Internal Error: Division by zero");
|
||||||
if (a == std::numeric_limits<bigint>::min() && std::abs(b)<=1)
|
if (a == std::numeric_limits<bigint>::min() && std::abs(b)<=1)
|
||||||
throw InternalError(0, "Internal Error: Division overflow");
|
throw InternalError(nullptr, "Internal Error: Division overflow");
|
||||||
return toString(toLongNumber(first) / b) + intsuffix(first, second);
|
return toString(toLongNumber(first) / b) + intsuffix(first, second);
|
||||||
} else if (isNullValue(second)) {
|
} else if (isNullValue(second)) {
|
||||||
if (isNullValue(first))
|
if (isNullValue(first))
|
||||||
|
@ -1181,7 +1181,7 @@ std::string MathLib::mod(const std::string &first, const std::string &second)
|
||||||
if (MathLib::isInt(first) && MathLib::isInt(second)) {
|
if (MathLib::isInt(first) && MathLib::isInt(second)) {
|
||||||
const bigint b = toLongNumber(second);
|
const bigint b = toLongNumber(second);
|
||||||
if (b == 0)
|
if (b == 0)
|
||||||
throw InternalError(0, "Internal Error: Division by zero");
|
throw InternalError(nullptr, "Internal Error: Division by zero");
|
||||||
return toString(toLongNumber(first) % b) + intsuffix(first, second);
|
return toString(toLongNumber(first) % b) + intsuffix(first, second);
|
||||||
}
|
}
|
||||||
return toString(std::fmod(toDoubleNumber(first),toDoubleNumber(second)));
|
return toString(std::fmod(toDoubleNumber(first),toDoubleNumber(second)));
|
||||||
|
@ -1216,7 +1216,7 @@ std::string MathLib::calculate(const std::string &first, const std::string &seco
|
||||||
return MathLib::toString(MathLib::toLongNumber(first) ^ MathLib::toLongNumber(second)) + intsuffix(first,second);
|
return MathLib::toString(MathLib::toLongNumber(first) ^ MathLib::toLongNumber(second)) + intsuffix(first,second);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw InternalError(0, std::string("Unexpected action '") + action + "' in MathLib::calculate(). Please report this to Cppcheck developers.");
|
throw InternalError(nullptr, std::string("Unexpected action '") + action + "' in MathLib::calculate(). Please report this to Cppcheck developers.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ const std::string Path::getCurrentPath()
|
||||||
char currentPath[4096];
|
char currentPath[4096];
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (getcwd(currentPath, 4096) != 0)
|
if (getcwd(currentPath, 4096) != nullptr)
|
||||||
#else
|
#else
|
||||||
if (_getcwd(currentPath, 4096) != 0)
|
if (_getcwd(currentPath, 4096) != 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -909,7 +909,7 @@ void Preprocessor::simplifyPragmaAsmPrivate(simplecpp::TokenList *tokenList)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const simplecpp::Token *endasm = tok3;
|
const simplecpp::Token *endasm = tok3;
|
||||||
while ((endasm = endasm->next) != 0) {
|
while ((endasm = endasm->next) != nullptr) {
|
||||||
if (endasm->op != '#' || sameline(endasm,endasm->previousSkipComments()))
|
if (endasm->op != '#' || sameline(endasm,endasm->previousSkipComments()))
|
||||||
continue;
|
continue;
|
||||||
const simplecpp::Token * const endasm2 = endasm->nextSkipComments();
|
const simplecpp::Token * const endasm2 = endasm->nextSkipComments();
|
||||||
|
|
|
@ -243,7 +243,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
tok->strAt(-1) != "friend") {
|
tok->strAt(-1) != "friend") {
|
||||||
if (!findType(tok->next(), scope)) {
|
if (!findType(tok->next(), scope)) {
|
||||||
// fill typeList..
|
// fill typeList..
|
||||||
typeList.push_back(Type(tok, 0, scope));
|
typeList.push_back(Type(tok, nullptr, scope));
|
||||||
scope->definedTypes.push_back(&typeList.back());
|
scope->definedTypes.push_back(&typeList.back());
|
||||||
}
|
}
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
|
@ -341,7 +341,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
|
|
||||||
// forward declared enum
|
// forward declared enum
|
||||||
else if (Token::Match(tok, "enum class| %name% ;") || Token::Match(tok, "enum class| %name% : %name% ;")) {
|
else if (Token::Match(tok, "enum class| %name% ;") || Token::Match(tok, "enum class| %name% : %name% ;")) {
|
||||||
typeList.push_back(Type(tok, 0, scope));
|
typeList.push_back(Type(tok, nullptr, scope));
|
||||||
scope->definedTypes.push_back(&typeList.back());
|
scope->definedTypes.push_back(&typeList.back());
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
}
|
}
|
||||||
|
@ -645,7 +645,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
friendInfo.name = friendInfo.nameEnd->str();
|
friendInfo.name = friendInfo.nameEnd->str();
|
||||||
|
|
||||||
// fill this in after parsing is complete
|
// fill this in after parsing is complete
|
||||||
friendInfo.type = 0;
|
friendInfo.type = nullptr;
|
||||||
|
|
||||||
if (!scope->definedType)
|
if (!scope->definedType)
|
||||||
_tokenizer->syntaxError(tok);
|
_tokenizer->syntaxError(tok);
|
||||||
|
@ -1477,12 +1477,12 @@ SymbolDatabase::~SymbolDatabase()
|
||||||
{
|
{
|
||||||
// Clear scope, type, function and variable pointers
|
// Clear scope, type, function and variable pointers
|
||||||
for (const Token* tok = _tokenizer->list.front(); tok; tok = tok->next()) {
|
for (const Token* tok = _tokenizer->list.front(); tok; tok = tok->next()) {
|
||||||
const_cast<Token *>(tok)->scope(0);
|
const_cast<Token *>(tok)->scope(nullptr);
|
||||||
const_cast<Token *>(tok)->type(0);
|
const_cast<Token *>(tok)->type(nullptr);
|
||||||
const_cast<Token *>(tok)->function(0);
|
const_cast<Token *>(tok)->function(nullptr);
|
||||||
const_cast<Token *>(tok)->variable(0);
|
const_cast<Token *>(tok)->variable(nullptr);
|
||||||
const_cast<Token *>(tok)->enumerator(0);
|
const_cast<Token *>(tok)->enumerator(nullptr);
|
||||||
const_cast<Token *>(tok)->setValueType(0);
|
const_cast<Token *>(tok)->setValueType(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2379,7 +2379,7 @@ const Function* Type::getFunction(const std::string& funcName) const
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Type::hasCircularDependencies(std::set<BaseInfo>* ancestors) const
|
bool Type::hasCircularDependencies(std::set<BaseInfo>* ancestors) const
|
||||||
|
@ -3173,9 +3173,9 @@ const Variable* Function::getArgumentVar(std::size_t num) const
|
||||||
if (i->index() == num)
|
if (i->index() == num)
|
||||||
return (&*i);
|
return (&*i);
|
||||||
else if (i->index() > num)
|
else if (i->index() > num)
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4275,7 +4275,7 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const
|
||||||
currScope = currScope->nestedIn;
|
currScope = currScope->nestedIn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4286,7 +4286,7 @@ const Scope *SymbolDatabase::findScopeByName(const std::string& name) const
|
||||||
if (it->className == name)
|
if (it->className == name)
|
||||||
return &*it;
|
return &*it;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4299,7 +4299,7 @@ Scope *Scope::findInNestedList(const std::string & name)
|
||||||
if ((*it)->className == name)
|
if ((*it)->className == name)
|
||||||
return (*it);
|
return (*it);
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4312,7 +4312,7 @@ const Scope *Scope::findRecordInNestedList(const std::string & name) const
|
||||||
if ((*it)->className == name && (*it)->type != eFunction)
|
if ((*it)->className == name && (*it)->type != eFunction)
|
||||||
return (*it);
|
return (*it);
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4325,7 +4325,7 @@ const Type* Scope::findType(const std::string & name) const
|
||||||
if ((*it)->name() == name)
|
if ((*it)->name() == name)
|
||||||
return (*it);
|
return (*it);
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4344,7 +4344,7 @@ Scope *Scope::findInNestedListRecursive(const std::string & name)
|
||||||
if (child)
|
if (child)
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4356,7 +4356,7 @@ const Function *Scope::getDestructor() const
|
||||||
if (it->type == Function::eDestructor)
|
if (it->type == Function::eDestructor)
|
||||||
return &(*it);
|
return &(*it);
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4390,7 +4390,7 @@ const Scope *SymbolDatabase::findScope(const Token *tok, const Scope *startScope
|
||||||
}
|
}
|
||||||
|
|
||||||
// not a valid path
|
// not a valid path
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4470,7 +4470,7 @@ const Type* SymbolDatabase::findType(const Token *startTok, const Scope *startSc
|
||||||
}
|
}
|
||||||
|
|
||||||
// not a valid path
|
// not a valid path
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4523,7 +4523,7 @@ const Type* SymbolDatabase::findTypeInNested(const Token *startTok, const Scope
|
||||||
}
|
}
|
||||||
|
|
||||||
// not a valid path
|
// not a valid path
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -4537,7 +4537,7 @@ const Scope * SymbolDatabase::findNamespace(const Token * tok, const Scope * sco
|
||||||
else if (scope->nestedIn)
|
else if (scope->nestedIn)
|
||||||
return findNamespace(tok, scope->nestedIn);
|
return findNamespace(tok, scope->nestedIn);
|
||||||
|
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
std::vector<BaseInfo> derivedFrom;
|
std::vector<BaseInfo> derivedFrom;
|
||||||
std::list<FriendInfo> friendList;
|
std::list<FriendInfo> friendList;
|
||||||
|
|
||||||
Type(const Token* classDef_ = 0, const Scope* classScope_ = 0, const Scope* enclosingScope_ = 0) :
|
Type(const Token* classDef_ = nullptr, const Scope* classScope_ = nullptr, const Scope* enclosingScope_ = nullptr) :
|
||||||
classDef(classDef_),
|
classDef(classDef_),
|
||||||
classScope(classScope_),
|
classScope(classScope_),
|
||||||
enclosingScope(enclosingScope_),
|
enclosingScope(enclosingScope_),
|
||||||
|
@ -479,7 +479,7 @@ public:
|
||||||
* @return pointer to type scope if known, NULL if not known
|
* @return pointer to type scope if known, NULL if not known
|
||||||
*/
|
*/
|
||||||
const Scope *typeScope() const {
|
const Scope *typeScope() const {
|
||||||
return _type ? _type->classScope : 0;
|
return _type ? _type->classScope : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1381,7 +1381,7 @@ void TemplateSimplifier::replaceTemplateUsage(Token * const instantiationToken,
|
||||||
// match parameters
|
// match parameters
|
||||||
Token * tok2 = nameTok->tokAt(2);
|
Token * tok2 = nameTok->tokAt(2);
|
||||||
unsigned int typeCountInInstantiation = 1U; // There is always at least one type
|
unsigned int typeCountInInstantiation = 1U; // There is always at least one type
|
||||||
const Token *typetok = (!typesUsedInTemplateInstantiation.empty()) ? typesUsedInTemplateInstantiation[0] : 0;
|
const Token *typetok = (!typesUsedInTemplateInstantiation.empty()) ? typesUsedInTemplateInstantiation[0] : nullptr;
|
||||||
unsigned int indentlevel2 = 0; // indentlevel for tokgt
|
unsigned int indentlevel2 = 0; // indentlevel for tokgt
|
||||||
while (tok2 && (indentlevel2 > 0 || tok2->str() != ">")) {
|
while (tok2 && (indentlevel2 > 0 || tok2->str() != ">")) {
|
||||||
if (tok2->str() == "<" && templateParameters(tok2) > 0)
|
if (tok2->str() == "<" && templateParameters(tok2) > 0)
|
||||||
|
|
|
@ -35,11 +35,11 @@
|
||||||
|
|
||||||
Token::Token(Token **tokens) :
|
Token::Token(Token **tokens) :
|
||||||
tokensBack(tokens),
|
tokensBack(tokens),
|
||||||
_next(0),
|
_next(nullptr),
|
||||||
_previous(0),
|
_previous(nullptr),
|
||||||
_link(0),
|
_link(nullptr),
|
||||||
_scope(0),
|
_scope(nullptr),
|
||||||
_function(0), // Initialize whole union
|
_function(nullptr), // Initialize whole union
|
||||||
_varId(0),
|
_varId(0),
|
||||||
_fileIndex(0),
|
_fileIndex(0),
|
||||||
_linenr(0),
|
_linenr(0),
|
||||||
|
@ -591,7 +591,7 @@ const char *Token::chrInFirstWord(const char *str, char c)
|
||||||
{
|
{
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (*str == ' ' || *str == 0)
|
if (*str == ' ' || *str == 0)
|
||||||
return 0;
|
return nullptr;
|
||||||
|
|
||||||
if (*str == c)
|
if (*str == c)
|
||||||
return str;
|
return str;
|
||||||
|
@ -868,7 +868,7 @@ const Token *Token::findsimplematch(const Token * const startTok, const char pat
|
||||||
if (Token::simpleMatch(tok, pattern))
|
if (Token::simpleMatch(tok, pattern))
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Token *Token::findsimplematch(const Token * const startTok, const char pattern[], const Token * const end)
|
const Token *Token::findsimplematch(const Token * const startTok, const char pattern[], const Token * const end)
|
||||||
|
@ -962,14 +962,14 @@ void Token::printOut(const char *title) const
|
||||||
{
|
{
|
||||||
if (title && title[0])
|
if (title && title[0])
|
||||||
std::cout << "\n### " << title << " ###\n";
|
std::cout << "\n### " << title << " ###\n";
|
||||||
std::cout << stringifyList(true, true, true, true, true, 0, 0) << std::endl;
|
std::cout << stringifyList(true, true, true, true, true, nullptr, nullptr) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::printOut(const char *title, const std::vector<std::string> &fileNames) const
|
void Token::printOut(const char *title, const std::vector<std::string> &fileNames) const
|
||||||
{
|
{
|
||||||
if (title && title[0])
|
if (title && title[0])
|
||||||
std::cout << "\n### " << title << " ###\n";
|
std::cout << "\n### " << title << " ###\n";
|
||||||
std::cout << stringifyList(true, true, true, true, true, &fileNames, 0) << std::endl;
|
std::cout << stringifyList(true, true, true, true, true, &fileNames, nullptr) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) const
|
void Token::stringify(std::ostream& os, bool varid, bool attributes, bool macro) const
|
||||||
|
@ -1067,12 +1067,12 @@ std::string Token::stringifyList(bool varid, bool attributes, bool linenumbers,
|
||||||
|
|
||||||
std::string Token::stringifyList(const Token* end, bool attributes) const
|
std::string Token::stringifyList(const Token* end, bool attributes) const
|
||||||
{
|
{
|
||||||
return stringifyList(false, attributes, false, false, false, 0, end);
|
return stringifyList(false, attributes, false, false, false, nullptr, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Token::stringifyList(bool varid) const
|
std::string Token::stringifyList(bool varid) const
|
||||||
{
|
{
|
||||||
return stringifyList(varid, false, true, true, true, 0, 0);
|
return stringifyList(varid, false, true, true, true, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Token::astOperand1(Token *tok)
|
void Token::astOperand1(Token *tok)
|
||||||
|
|
10
lib/token.h
10
lib/token.h
|
@ -556,7 +556,7 @@ public:
|
||||||
* @param end Stringification ends before this token is reached. 0 to stringify until end of list.
|
* @param end Stringification ends before this token is reached. 0 to stringify until end of list.
|
||||||
* @return Stringified token list as a string
|
* @return Stringified token list as a string
|
||||||
*/
|
*/
|
||||||
std::string stringifyList(bool varid, bool attributes, bool linenumbers, bool linebreaks, bool files, const std::vector<std::string>* fileNames = 0, const Token* end = 0) const;
|
std::string stringifyList(bool varid, bool attributes, bool linenumbers, bool linebreaks, bool files, const std::vector<std::string>* fileNames = nullptr, const Token* end = nullptr) const;
|
||||||
std::string stringifyList(const Token* end, bool attributes = true) const;
|
std::string stringifyList(const Token* end, bool attributes = true) const;
|
||||||
std::string stringifyList(bool varid = false) const;
|
std::string stringifyList(bool varid = false) const;
|
||||||
|
|
||||||
|
@ -625,7 +625,7 @@ public:
|
||||||
* @return a pointer to the Function associated with this token.
|
* @return a pointer to the Function associated with this token.
|
||||||
*/
|
*/
|
||||||
const Function *function() const {
|
const Function *function() const {
|
||||||
return _tokType == eFunction ? _function : 0;
|
return _tokType == eFunction ? _function : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -644,7 +644,7 @@ public:
|
||||||
* @return a pointer to the variable associated with this token.
|
* @return a pointer to the variable associated with this token.
|
||||||
*/
|
*/
|
||||||
const Variable *variable() const {
|
const Variable *variable() const {
|
||||||
return _tokType == eVariable ? _variable : 0;
|
return _tokType == eVariable ? _variable : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -657,14 +657,14 @@ public:
|
||||||
* @return a pointer to the type associated with this token.
|
* @return a pointer to the type associated with this token.
|
||||||
*/
|
*/
|
||||||
const ::Type *type() const {
|
const ::Type *type() const {
|
||||||
return _tokType == eType ? _type : 0;
|
return _tokType == eType ? _type : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a pointer to the Enumerator associated with this token.
|
* @return a pointer to the Enumerator associated with this token.
|
||||||
*/
|
*/
|
||||||
const Enumerator *enumerator() const {
|
const Enumerator *enumerator() const {
|
||||||
return _tokType == eEnumerator ? _enumerator : 0;
|
return _tokType == eEnumerator ? _enumerator : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -134,10 +134,10 @@ static bool isClassStructUnionEnumStart(const Token * tok)
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
Tokenizer::Tokenizer() :
|
Tokenizer::Tokenizer() :
|
||||||
list(0),
|
list(nullptr),
|
||||||
_settings(0),
|
_settings(nullptr),
|
||||||
_errorLogger(0),
|
_errorLogger(nullptr),
|
||||||
_symbolDatabase(0),
|
_symbolDatabase(nullptr),
|
||||||
_varId(0),
|
_varId(0),
|
||||||
_codeWithTemplates(false), //is there any templates?
|
_codeWithTemplates(false), //is there any templates?
|
||||||
m_timerResults(nullptr)
|
m_timerResults(nullptr)
|
||||||
|
@ -151,7 +151,7 @@ Tokenizer::Tokenizer(const Settings *settings, ErrorLogger *errorLogger) :
|
||||||
list(settings),
|
list(settings),
|
||||||
_settings(settings),
|
_settings(settings),
|
||||||
_errorLogger(errorLogger),
|
_errorLogger(errorLogger),
|
||||||
_symbolDatabase(0),
|
_symbolDatabase(nullptr),
|
||||||
_varId(0),
|
_varId(0),
|
||||||
_codeWithTemplates(false), //is there any templates?
|
_codeWithTemplates(false), //is there any templates?
|
||||||
m_timerResults(nullptr)
|
m_timerResults(nullptr)
|
||||||
|
@ -2146,7 +2146,7 @@ static Token *skipTernaryOp(Token *tok)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (colonlevel) // Ticket #5214: Make sure the ':' matches the proper '?'
|
if (colonlevel) // Ticket #5214: Make sure the ':' matches the proper '?'
|
||||||
return 0;
|
return nullptr;
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3019,7 +3019,7 @@ void Tokenizer::createLinks()
|
||||||
std::stack<Token*> links3;
|
std::stack<Token*> links3;
|
||||||
for (Token *token = list.front(); token; token = token->next()) {
|
for (Token *token = list.front(); token; token = token->next()) {
|
||||||
if (token->link()) {
|
if (token->link()) {
|
||||||
token->link(0);
|
token->link(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
linkBrackets(this, type, links1, token, '{', '}');
|
linkBrackets(this, type, links1, token, '{', '}');
|
||||||
|
@ -3069,7 +3069,7 @@ void Tokenizer::createLinks2()
|
||||||
type.pop();
|
type.pop();
|
||||||
templateToken = nullptr;
|
templateToken = nullptr;
|
||||||
} else
|
} else
|
||||||
token->link(0);
|
token->link(nullptr);
|
||||||
} else if (!templateToken && !isStruct && Token::Match(token, "%oror%|&&|;")) {
|
} else if (!templateToken && !isStruct && Token::Match(token, "%oror%|&&|;")) {
|
||||||
if (Token::Match(token, "&& [,>]"))
|
if (Token::Match(token, "&& [,>]"))
|
||||||
continue;
|
continue;
|
||||||
|
@ -3180,7 +3180,7 @@ bool Tokenizer::simplifySizeof()
|
||||||
|
|
||||||
else if (Token::Match(tok->previous(), "%type% %name% [ %num% ] [,)]") ||
|
else if (Token::Match(tok->previous(), "%type% %name% [ %num% ] [,)]") ||
|
||||||
Token::Match(tok->tokAt(-2), "%type% * %name% [ %num% ] [,)]")) {
|
Token::Match(tok->tokAt(-2), "%type% * %name% [ %num% ] [,)]")) {
|
||||||
Token tempTok(0);
|
Token tempTok(nullptr);
|
||||||
tempTok.str("*");
|
tempTok.str("*");
|
||||||
sizeOfVar[varId] = sizeOfType(&tempTok);
|
sizeOfVar[varId] = sizeOfType(&tempTok);
|
||||||
declTokOfVar[varId] = tok;
|
declTokOfVar[varId] = tok;
|
||||||
|
@ -3841,7 +3841,7 @@ void Tokenizer::printDebugOutput(unsigned int simplification) const
|
||||||
(simplification != 2U && _settings->debugnormal);
|
(simplification != 2U && _settings->debugnormal);
|
||||||
|
|
||||||
if (debug && list.front()) {
|
if (debug && list.front()) {
|
||||||
list.front()->printOut(0, list.getFiles());
|
list.front()->printOut(nullptr, list.getFiles());
|
||||||
|
|
||||||
if (_settings->xml)
|
if (_settings->xml)
|
||||||
std::cout << "<debug>" << std::endl;
|
std::cout << "<debug>" << std::endl;
|
||||||
|
@ -4233,7 +4233,7 @@ void Tokenizer::simplifyFlowControl()
|
||||||
break;
|
break;
|
||||||
--indentlevel;
|
--indentlevel;
|
||||||
if (stilldead) {
|
if (stilldead) {
|
||||||
eraseDeadCode(tok, 0);
|
eraseDeadCode(tok, nullptr);
|
||||||
if (indentlevel == 1 || tok->next()->str() != "}" || !Token::Match(tok->next()->link()->previous(), ";|{|}|do {"))
|
if (indentlevel == 1 || tok->next()->str() != "}" || !Token::Match(tok->next()->link()->previous(), ";|{|}|do {"))
|
||||||
stilldead = false;
|
stilldead = false;
|
||||||
continue;
|
continue;
|
||||||
|
@ -4245,7 +4245,7 @@ void Tokenizer::simplifyFlowControl()
|
||||||
|
|
||||||
if (Token::Match(tok,"continue|break ;")) {
|
if (Token::Match(tok,"continue|break ;")) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
eraseDeadCode(tok, 0);
|
eraseDeadCode(tok, nullptr);
|
||||||
|
|
||||||
} else if (Token::Match(tok,"return|goto") ||
|
} else if (Token::Match(tok,"return|goto") ||
|
||||||
(Token::Match(tok->previous(), "[;{}] %name% (") &&
|
(Token::Match(tok->previous(), "[;{}] %name% (") &&
|
||||||
|
@ -4260,7 +4260,7 @@ void Tokenizer::simplifyFlowControl()
|
||||||
tok2 = tok2->link();
|
tok2 = tok2->link();
|
||||||
} else if (tok2->str() == ";") {
|
} else if (tok2->str() == ";") {
|
||||||
tok = tok2;
|
tok = tok2;
|
||||||
eraseDeadCode(tok, 0);
|
eraseDeadCode(tok, nullptr);
|
||||||
break;
|
break;
|
||||||
} else if (Token::Match(tok2, "[{}]"))
|
} else if (Token::Match(tok2, "[{}]"))
|
||||||
break;
|
break;
|
||||||
|
@ -4608,7 +4608,7 @@ void Tokenizer::simplifyCompoundAssignment()
|
||||||
tok = tok->link();
|
tok = tok->link();
|
||||||
|
|
||||||
// goto next token..
|
// goto next token..
|
||||||
tok = tok ? tok->next() : 0;
|
tok = tok ? tok->next() : nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4857,7 +4857,7 @@ bool Tokenizer::simplifyConstTernaryOp()
|
||||||
if (tok->str() == "<" && TemplateSimplifier::templateParameters(tok))
|
if (tok->str() == "<" && TemplateSimplifier::templateParameters(tok))
|
||||||
templateParameterEnd = tok->findClosingBracket();
|
templateParameterEnd = tok->findClosingBracket();
|
||||||
if (tok == templateParameterEnd)
|
if (tok == templateParameterEnd)
|
||||||
templateParameterEnd = 0; // End of the current template parameter list
|
templateParameterEnd = nullptr; // End of the current template parameter list
|
||||||
if (tok->str() != "?")
|
if (tok->str() != "?")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -7543,7 +7543,7 @@ void Tokenizer::eraseDeadCode(Token *begin, const Token *end)
|
||||||
tok = tok->link()->tokAt(-2); //remove also 'switch ( ... )'
|
tok = tok->link()->tokAt(-2); //remove also 'switch ( ... )'
|
||||||
Token::eraseTokens(tok, end2->next());
|
Token::eraseTokens(tok, end2->next());
|
||||||
checklabel = false;
|
checklabel = false;
|
||||||
tokcheck = 0;
|
tokcheck = nullptr;
|
||||||
indentcheck = 0;
|
indentcheck = 0;
|
||||||
} else {
|
} else {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
|
@ -38,8 +38,8 @@ static const unsigned int AST_MAX_DEPTH = 50U;
|
||||||
|
|
||||||
|
|
||||||
TokenList::TokenList(const Settings* settings) :
|
TokenList::TokenList(const Settings* settings) :
|
||||||
_front(0),
|
_front(nullptr),
|
||||||
_back(0),
|
_back(nullptr),
|
||||||
_settings(settings),
|
_settings(settings),
|
||||||
_isC(false),
|
_isC(false),
|
||||||
_isCPP(false)
|
_isCPP(false)
|
||||||
|
@ -67,8 +67,8 @@ const std::string& TokenList::getSourceFilePath() const
|
||||||
void TokenList::deallocateTokens()
|
void TokenList::deallocateTokens()
|
||||||
{
|
{
|
||||||
deleteTokens(_front);
|
deleteTokens(_front);
|
||||||
_front = 0;
|
_front = nullptr;
|
||||||
_back = 0;
|
_back = nullptr;
|
||||||
_files.clear();
|
_files.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -892,7 +892,7 @@ static void compileAssignTernary(Token *&tok, AST_state& state)
|
||||||
// "The expression in the middle of the conditional operator (between ? and :) is parsed as if parenthesized: its precedence relative to ?: is ignored."
|
// "The expression in the middle of the conditional operator (between ? and :) is parsed as if parenthesized: its precedence relative to ?: is ignored."
|
||||||
// Hence, we rely on Tokenizer::prepareTernaryOpForAST() to add such parentheses where necessary.
|
// Hence, we rely on Tokenizer::prepareTernaryOpForAST() to add such parentheses where necessary.
|
||||||
if (tok->strAt(1) == ":") {
|
if (tok->strAt(1) == ":") {
|
||||||
state.op.push(0);
|
state.op.push(nullptr);
|
||||||
}
|
}
|
||||||
const unsigned int assign = state.assign;
|
const unsigned int assign = state.assign;
|
||||||
state.assign = 0U;
|
state.assign = 0U;
|
||||||
|
|
|
@ -2379,7 +2379,7 @@ static bool valueFlowForLoop1(const Token *tok, unsigned int * const varid, Math
|
||||||
if (num2tok && num2tok->str() == "(" && !num2tok->astOperand2())
|
if (num2tok && num2tok->str() == "(" && !num2tok->astOperand2())
|
||||||
num2tok = num2tok->astOperand1();
|
num2tok = num2tok->astOperand1();
|
||||||
if (!Token::Match(num2tok, "%num% ;|%oror%")) // TODO: || enlarges the scope of the condition, so it should not cause FP, but it should no lnger be part of this pattern as soon as valueFlowForLoop2 can handle an unknown RHS of || better
|
if (!Token::Match(num2tok, "%num% ;|%oror%")) // TODO: || enlarges the scope of the condition, so it should not cause FP, but it should no lnger be part of this pattern as soon as valueFlowForLoop2 can handle an unknown RHS of || better
|
||||||
num2tok = 0;
|
num2tok = nullptr;
|
||||||
}
|
}
|
||||||
if (!num2tok)
|
if (!num2tok)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace ValueFlow {
|
||||||
typedef std::pair<const Token *, std::string> ErrorPathItem;
|
typedef std::pair<const Token *, std::string> ErrorPathItem;
|
||||||
typedef std::list<ErrorPathItem> ErrorPath;
|
typedef std::list<ErrorPathItem> ErrorPath;
|
||||||
|
|
||||||
explicit Value(long long val = 0) : valueType(INT), intvalue(val), tokvalue(nullptr), floatValue(0.0), moveKind(NonMovedVariable), varvalue(val), condition(0), varId(0U), conditional(false), inconclusive(false), defaultArg(false), valueKind(ValueKind::Possible) {}
|
explicit Value(long long val = 0) : valueType(INT), intvalue(val), tokvalue(nullptr), floatValue(0.0), moveKind(NonMovedVariable), varvalue(val), condition(nullptr), varId(0U), conditional(false), inconclusive(false), defaultArg(false), valueKind(ValueKind::Possible) {}
|
||||||
Value(const Token *c, long long val);
|
Value(const Token *c, long long val);
|
||||||
|
|
||||||
bool operator==(const Value &rhs) const {
|
bool operator==(const Value &rhs) const {
|
||||||
|
|
Loading…
Reference in New Issue