Refactoring: Rename member functions to follow naming guidelines.
This commit is contained in:
parent
f676deb208
commit
8b0e481d46
|
@ -60,6 +60,8 @@
|
|||
<Unit filename="gui/threadhandler.h" />
|
||||
<Unit filename="gui/threadresult.cpp" />
|
||||
<Unit filename="gui/threadresult.h" />
|
||||
<Unit filename="gui/translationhandler.cpp" />
|
||||
<Unit filename="gui/translationhandler.h" />
|
||||
<Unit filename="gui/txtreport.cpp" />
|
||||
<Unit filename="gui/txtreport.h" />
|
||||
<Unit filename="gui/xmlreport.cpp" />
|
||||
|
|
|
@ -349,7 +349,7 @@ QStringList MainWindow::RemoveUnacceptedFiles(const QStringList &list)
|
|||
QString str;
|
||||
foreach(str, list)
|
||||
{
|
||||
if (FileLister::AcceptFile(str.toStdString()))
|
||||
if (FileLister::acceptFile(str.toStdString()))
|
||||
{
|
||||
result << str;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ void CheckBufferOverrunClass::sizeArgumentAsChar(const Token *tok)
|
|||
// Check array usage..
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope(const Token *tok, const char *varname[], const int size, const int total_size, unsigned int varid)
|
||||
void CheckBufferOverrunClass::checkScope(const Token *tok, const char *varname[], const int size, const int total_size, unsigned int varid)
|
||||
{
|
||||
unsigned int varc = 0;
|
||||
|
||||
|
@ -390,7 +390,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope(const Token *tok, co
|
|||
continue;
|
||||
|
||||
// Find function..
|
||||
const Token *ftok = _tokenizer->GetFunctionTokenByName(tok->str().c_str());
|
||||
const Token *ftok = _tokenizer->getFunctionTokenByName(tok->str().c_str());
|
||||
if (!ftok)
|
||||
continue;
|
||||
|
||||
|
@ -422,7 +422,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope(const Token *tok, co
|
|||
|
||||
// Check variable usage in the function..
|
||||
_callStack.push_back(tok);
|
||||
CheckBufferOverrun_CheckScope(ftok, parname, size, total_size, 0);
|
||||
checkScope(ftok, parname, size, total_size, 0);
|
||||
_callStack.pop_back();
|
||||
|
||||
// break out..
|
||||
|
@ -440,7 +440,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_CheckScope(const Token *tok, co
|
|||
// Checking local variables in a scope
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckBufferOverrunClass::CheckBufferOverrun_GlobalAndLocalVariable()
|
||||
void CheckBufferOverrunClass::checkGlobalAndLocalVariable()
|
||||
{
|
||||
int indentlevel = 0;
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
|
@ -493,13 +493,13 @@ void CheckBufferOverrunClass::CheckBufferOverrun_GlobalAndLocalVariable()
|
|||
continue;
|
||||
}
|
||||
|
||||
int total_size = size * ((*type == '*') ? 4 : _tokenizer->SizeOfType(type));
|
||||
int total_size = size * ((*type == '*') ? 4 : _tokenizer->sizeOfType(type));
|
||||
if (total_size == 0)
|
||||
continue;
|
||||
|
||||
// The callstack is empty
|
||||
_callStack.clear();
|
||||
CheckBufferOverrun_CheckScope(tok->tokAt(nextTok), varname, size, total_size, varid);
|
||||
checkScope(tok->tokAt(nextTok), varname, size, total_size, varid);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -509,7 +509,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_GlobalAndLocalVariable()
|
|||
// Checking member variables of structs..
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
|
||||
void CheckBufferOverrunClass::checkStructVariable()
|
||||
{
|
||||
const char declstruct[] = "struct|class %var% {";
|
||||
for (const Token *tok = Token::findmatch(_tokenizer->tokens(), declstruct);
|
||||
|
@ -538,7 +538,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
|
|||
const char *varname[3] = {0, 0, 0};
|
||||
varname[1] = tok2->strAt(ivar);
|
||||
int arrsize = std::atoi(tok2->strAt(ivar + 2));
|
||||
int total_size = arrsize * _tokenizer->SizeOfType(tok2->strAt(1));
|
||||
int total_size = arrsize * _tokenizer->sizeOfType(tok2->strAt(1));
|
||||
if (total_size == 0)
|
||||
continue;
|
||||
|
||||
|
@ -558,7 +558,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
|
|||
if (Token::simpleMatch(tok4, ") {"))
|
||||
{
|
||||
const char *names[2] = {varname[1], 0};
|
||||
CheckBufferOverrun_CheckScope(tok4->tokAt(2), names, arrsize, total_size, 0);
|
||||
checkScope(tok4->tokAt(2), names, arrsize, total_size, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +615,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
|
|||
continue;
|
||||
|
||||
// Check variable usage..
|
||||
CheckBufferOverrun_CheckScope(CheckTok, varname, arrsize, total_size, 0);
|
||||
checkScope(CheckTok, varname, arrsize, total_size, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,8 +624,8 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
|
|||
|
||||
void CheckBufferOverrunClass::bufferOverrun()
|
||||
{
|
||||
CheckBufferOverrun_GlobalAndLocalVariable();
|
||||
CheckBufferOverrun_StructVariable();
|
||||
checkGlobalAndLocalVariable();
|
||||
checkStructVariable();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -55,13 +55,13 @@ public:
|
|||
private:
|
||||
|
||||
/** Check for buffer overruns - locate struct variables and check them with the .._CheckScope function */
|
||||
void CheckBufferOverrun_StructVariable();
|
||||
void checkStructVariable();
|
||||
|
||||
/** Check for buffer overruns - locate global variables and local function variables and check them with the .._CheckScope function */
|
||||
void CheckBufferOverrun_GlobalAndLocalVariable();
|
||||
/** Check for buffer overruns - locate global variables and local function variables and check them with the checkScope function */
|
||||
void checkGlobalAndLocalVariable();
|
||||
|
||||
/** Check for buffer overruns - this is the function that performs the actual checking */
|
||||
void CheckBufferOverrun_CheckScope(const Token *tok, const char *varname[], const int size, const int total_size, unsigned int varid);
|
||||
void checkScope(const Token *tok, const char *varname[], const int size, const int total_size, unsigned int varid);
|
||||
|
||||
/** callstack - used during intra-function checking */
|
||||
std::list<const Token *> _callStack;
|
||||
|
|
|
@ -41,7 +41,7 @@ CheckClass instance;
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1, bool withClasses)
|
||||
struct CheckClass::VAR *CheckClass::getVarList(const Token *tok1, bool withClasses)
|
||||
{
|
||||
// Get variable list..
|
||||
struct VAR *varlist = NULL;
|
||||
|
@ -136,7 +136,7 @@ struct CheckClass::VAR *CheckClass::ClassChecking_GetVarList(const Token *tok1,
|
|||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckClass::InitVar(struct VAR *varlist, const char varname[])
|
||||
void CheckClass::initVar(struct VAR *varlist, const char varname[])
|
||||
{
|
||||
for (struct VAR *var = varlist; var; var = var->next)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ void CheckClass::InitVar(struct VAR *varlist, const char varname[])
|
|||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckClass::ClassChecking_VarList_Initialize(const Token *tok1, const Token *ftok, struct VAR *varlist, const char classname[], std::list<std::string> &callstack)
|
||||
void CheckClass::initializeVarList(const Token *tok1, const Token *ftok, struct VAR *varlist, const char classname[], std::list<std::string> &callstack)
|
||||
{
|
||||
bool Assign = false;
|
||||
unsigned int indentlevel = 0;
|
||||
|
@ -165,7 +165,7 @@ void CheckClass::ClassChecking_VarList_Initialize(const Token *tok1, const Token
|
|||
{
|
||||
if (Assign && Token::Match(ftok, "%var% ("))
|
||||
{
|
||||
InitVar(varlist, ftok->str().c_str());
|
||||
initVar(varlist, ftok->str().c_str());
|
||||
}
|
||||
|
||||
Assign |= (ftok->str() == ":");
|
||||
|
@ -191,7 +191,7 @@ void CheckClass::ClassChecking_VarList_Initialize(const Token *tok1, const Token
|
|||
// Variable getting value from stream?
|
||||
if (Token::Match(ftok, ">> %var%"))
|
||||
{
|
||||
InitVar(varlist, ftok->next()->str().c_str());
|
||||
initVar(varlist, ftok->next()->str().c_str());
|
||||
}
|
||||
|
||||
// Before a new statement there is "[{};)=]" or "else"
|
||||
|
@ -232,21 +232,21 @@ void CheckClass::ClassChecking_VarList_Initialize(const Token *tok1, const Token
|
|||
{
|
||||
callstack.push_back(ftok->str());
|
||||
int i = 0;
|
||||
const Token *ftok2 = Tokenizer::FindClassFunction(tok1, classname, ftok->str().c_str(), i);
|
||||
ClassChecking_VarList_Initialize(tok1, ftok2, varlist, classname, callstack);
|
||||
const Token *ftok2 = Tokenizer::findClassFunction(tok1, classname, ftok->str().c_str(), i);
|
||||
initializeVarList(tok1, ftok2, varlist, classname, callstack);
|
||||
}
|
||||
}
|
||||
|
||||
// Assignment of member variable?
|
||||
else if (Token::Match(ftok, "%var% ="))
|
||||
{
|
||||
InitVar(varlist, ftok->str().c_str());
|
||||
initVar(varlist, ftok->str().c_str());
|
||||
}
|
||||
|
||||
// The functions 'clear' and 'Clear' are supposed to initialize variable.
|
||||
if (Token::Match(ftok, "%var% . clear|Clear ("))
|
||||
{
|
||||
InitVar(varlist, ftok->str().c_str());
|
||||
initVar(varlist, ftok->str().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ void CheckClass::constructors()
|
|||
if (ErrorLogger::noConstructor(*_settings))
|
||||
{
|
||||
// If the class has member variables there should be an constructor
|
||||
struct VAR *varlist = ClassChecking_GetVarList(tok1, false);
|
||||
struct VAR *varlist = getVarList(tok1, false);
|
||||
if (varlist)
|
||||
{
|
||||
noConstructorError(tok1, classNameToken->str());
|
||||
|
@ -350,27 +350,27 @@ void CheckClass::constructors()
|
|||
}
|
||||
|
||||
// Check constructors
|
||||
CheckConstructors(tok1, className[0]);
|
||||
checkConstructors(tok1, className[0]);
|
||||
|
||||
// Check assignment operators
|
||||
CheckConstructors(tok1, "operator =");
|
||||
checkConstructors(tok1, "operator =");
|
||||
|
||||
tok1 = Token::findmatch(tok1->next(), pattern_class);
|
||||
}
|
||||
}
|
||||
|
||||
void CheckClass::CheckConstructors(const Token *tok1, const char funcname[])
|
||||
void CheckClass::checkConstructors(const Token *tok1, const char funcname[])
|
||||
{
|
||||
const char * const className = tok1->strAt(1);
|
||||
|
||||
// Check that all member variables are initialized..
|
||||
bool withClasses = bool(_settings->_showAll && std::string(funcname) == "operator =");
|
||||
struct VAR *varlist = ClassChecking_GetVarList(tok1, withClasses);
|
||||
struct VAR *varlist = getVarList(tok1, withClasses);
|
||||
|
||||
int indentlevel = 0;
|
||||
const Token *constructor_token = Tokenizer::FindClassFunction(tok1, className, funcname, indentlevel);
|
||||
const Token *constructor_token = Tokenizer::findClassFunction(tok1, className, funcname, indentlevel);
|
||||
std::list<std::string> callstack;
|
||||
ClassChecking_VarList_Initialize(tok1, constructor_token, varlist, className, callstack);
|
||||
initializeVarList(tok1, constructor_token, varlist, className, callstack);
|
||||
while (constructor_token)
|
||||
{
|
||||
// Check if any variables are uninitialized
|
||||
|
@ -415,9 +415,9 @@ void CheckClass::CheckConstructors(const Token *tok1, const char funcname[])
|
|||
for (struct VAR *var = varlist; var; var = var->next)
|
||||
var->init = false;
|
||||
|
||||
constructor_token = Tokenizer::FindClassFunction(constructor_token->next(), className, funcname, indentlevel);
|
||||
constructor_token = Tokenizer::findClassFunction(constructor_token->next(), className, funcname, indentlevel);
|
||||
callstack.clear();
|
||||
ClassChecking_VarList_Initialize(tok1, constructor_token, varlist, className, callstack);
|
||||
initializeVarList(tok1, constructor_token, varlist, className, callstack);
|
||||
}
|
||||
|
||||
// Delete the varlist..
|
||||
|
|
|
@ -90,12 +90,12 @@ private:
|
|||
struct VAR *next;
|
||||
};
|
||||
|
||||
void ClassChecking_VarList_Initialize(const Token *tok1, const Token *ftok, struct VAR *varlist, const char classname[], std::list<std::string> &callstack);
|
||||
void InitVar(struct VAR *varlist, const char varname[]);
|
||||
struct VAR *ClassChecking_GetVarList(const Token *tok1, bool withClasses);
|
||||
void initializeVarList(const Token *tok1, const Token *ftok, struct VAR *varlist, const char classname[], std::list<std::string> &callstack);
|
||||
void initVar(struct VAR *varlist, const char varname[]);
|
||||
struct VAR *getVarList(const Token *tok1, bool withClasses);
|
||||
|
||||
// Check constructors for a specified class
|
||||
void CheckConstructors(const Token *tok1, const char funcname[]);
|
||||
void checkConstructors(const Token *tok1, const char funcname[]);
|
||||
|
||||
// Reporting errors..
|
||||
void noConstructorError(const Token *tok, const std::string &classname);
|
||||
|
|
|
@ -47,7 +47,7 @@ CheckHeaders::~CheckHeaders()
|
|||
|
||||
}
|
||||
|
||||
void CheckHeaders::WarningHeaderWithImplementation()
|
||||
void CheckHeaders::warningHeaderWithImplementation()
|
||||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ void CheckHeaders::WarningHeaderWithImplementation()
|
|||
// HEADERS - Unneeded include
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckHeaders::WarningIncludeHeader()
|
||||
void CheckHeaders::warningIncludeHeader()
|
||||
{
|
||||
// Including..
|
||||
for (const Token *includetok = _tokenizer->tokens(); includetok; includetok = includetok->next())
|
||||
|
@ -99,7 +99,7 @@ void CheckHeaders::WarningIncludeHeader()
|
|||
const char *includefile = includetok->strAt(1);
|
||||
while (hfile < _tokenizer->getFiles()->size())
|
||||
{
|
||||
if (FileLister::SameFileName(_tokenizer->getFiles()->at(hfile).c_str(), includefile))
|
||||
if (FileLister::sameFileName(_tokenizer->getFiles()->at(hfile).c_str(), includefile))
|
||||
break;
|
||||
++hfile;
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ class CheckHeaders
|
|||
public:
|
||||
CheckHeaders(const Tokenizer *tokenizer, ErrorLogger *errorLogger);
|
||||
~CheckHeaders();
|
||||
void WarningHeaderWithImplementation();
|
||||
void WarningIncludeHeader();
|
||||
void warningHeaderWithImplementation();
|
||||
void warningIncludeHeader();
|
||||
|
||||
private:
|
||||
const Tokenizer *_tokenizer;
|
||||
|
|
|
@ -51,7 +51,7 @@ bool CheckMemoryLeak::isclass(const Tokenizer *_tokenizer, const Token *tok) con
|
|||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
CheckMemoryLeak::AllocType CheckMemoryLeak::GetAllocationType(const Token *tok2) const
|
||||
CheckMemoryLeak::AllocType CheckMemoryLeak::getAllocationType(const Token *tok2) const
|
||||
{
|
||||
// What we may have...
|
||||
// * var = (char *)malloc(10);
|
||||
|
@ -131,7 +131,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::GetAllocationType(const Token *tok2)
|
|||
|
||||
|
||||
|
||||
CheckMemoryLeak::AllocType CheckMemoryLeak::GetReallocationType(const Token *tok2)
|
||||
CheckMemoryLeak::AllocType CheckMemoryLeak::getReallocationType(const Token *tok2)
|
||||
{
|
||||
// What we may have...
|
||||
// * var = (char *)realloc(..;
|
||||
|
@ -155,7 +155,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::GetReallocationType(const Token *tok
|
|||
}
|
||||
|
||||
|
||||
CheckMemoryLeak::AllocType CheckMemoryLeak::GetDeallocationType(const Token *tok, const char *varnames[])
|
||||
CheckMemoryLeak::AllocType CheckMemoryLeak::getDeallocationType(const Token *tok, const char *varnames[])
|
||||
{
|
||||
int i = 0;
|
||||
std::string names;
|
||||
|
@ -207,7 +207,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::GetDeallocationType(const Token *tok
|
|||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
void CheckMemoryLeak::MemoryLeak(const Token *tok, const char varname[], AllocType alloctype, bool all)
|
||||
void CheckMemoryLeak::memoryLeak(const Token *tok, const char varname[], AllocType alloctype, bool all)
|
||||
{
|
||||
if (alloctype == CheckMemoryLeak::File ||
|
||||
alloctype == CheckMemoryLeak::Pipe ||
|
||||
|
@ -308,7 +308,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Token *tok)
|
|||
if (varname.empty() && Token::Match(tok, "%var% = "))
|
||||
{
|
||||
varname = tok->str();
|
||||
allocType = GetAllocationType(tok->tokAt(2));
|
||||
allocType = getAllocationType(tok->tokAt(2));
|
||||
if (allocType == No)
|
||||
return No;
|
||||
while (tok && tok->str() != ";")
|
||||
|
@ -335,7 +335,7 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Token *tok)
|
|||
|
||||
|
||||
|
||||
bool CheckMemoryLeakInFunction::MatchFunctionsThatReturnArg(const Token *tok, const std::string &varname)
|
||||
bool CheckMemoryLeakInFunction::matchFunctionsThatReturnArg(const Token *tok, const std::string &varname)
|
||||
{
|
||||
return Token::Match(tok, std::string("; " + varname + " = strcat|memcpy|memmove|strcpy ( " + varname + " ,").c_str());
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
if (tok->str() == "delete")
|
||||
return 0;
|
||||
|
||||
if (GetAllocationType(tok) != No || GetReallocationType(tok) != No || GetDeallocationType(tok, varnames) != No)
|
||||
if (getAllocationType(tok) != No || getReallocationType(tok) != No || getDeallocationType(tok, varnames) != No)
|
||||
return 0;
|
||||
|
||||
if (callstack.size() > 2)
|
||||
|
@ -442,7 +442,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
|
||||
// Check if this is a function that allocates memory..
|
||||
{
|
||||
const Token *ftok = _tokenizer->GetFunctionTokenByName(funcname.c_str());
|
||||
const Token *ftok = _tokenizer->getFunctionTokenByName(funcname.c_str());
|
||||
AllocType a = functionReturnType(ftok);
|
||||
if (a != No)
|
||||
return "alloc";
|
||||
|
@ -485,7 +485,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
|
|||
++par;
|
||||
if (Token::Match(tok, pattern.c_str()))
|
||||
{
|
||||
const Token *ftok = _tokenizer->GetFunctionTokenByName(funcname.c_str());
|
||||
const Token *ftok = _tokenizer->getFunctionTokenByName(funcname.c_str());
|
||||
if (!ftok)
|
||||
return "use";
|
||||
|
||||
|
@ -583,7 +583,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
|
||||
if (Token::Match(tok->previous(), std::string("[(;{}] " + varnameStr + " =").c_str()))
|
||||
{
|
||||
AllocType alloc = GetAllocationType(tok->tokAt(2));
|
||||
AllocType alloc = getAllocationType(tok->tokAt(2));
|
||||
bool realloc = false;
|
||||
|
||||
if (sz > 1 &&
|
||||
|
@ -595,7 +595,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
|
||||
if (alloc == No)
|
||||
{
|
||||
alloc = GetReallocationType(tok->tokAt(2));
|
||||
alloc = getReallocationType(tok->tokAt(2));
|
||||
if (alloc != No)
|
||||
{
|
||||
addtoken("realloc");
|
||||
|
@ -649,7 +649,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
alloctype = alloc;
|
||||
}
|
||||
|
||||
else if (MatchFunctionsThatReturnArg(tok->previous(), std::string(varname)))
|
||||
else if (matchFunctionsThatReturnArg(tok->previous(), std::string(varname)))
|
||||
{
|
||||
addtoken("use");
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
|
||||
if (Token::Match(tok->previous(), "[;{})=] %var%"))
|
||||
{
|
||||
AllocType dealloc = GetDeallocationType(tok, varnames);
|
||||
AllocType dealloc = getDeallocationType(tok, varnames);
|
||||
if (dealloc != No)
|
||||
{
|
||||
addtoken("dealloc");
|
||||
|
@ -1535,23 +1535,23 @@ void CheckMemoryLeakInFunction::checkScope(const Token *Tok1, const char varname
|
|||
|
||||
if ((result = Token::findmatch(tok, "loop alloc ;")) != NULL)
|
||||
{
|
||||
MemoryLeak(result, varname, alloctype, all);
|
||||
memoryLeak(result, varname, alloctype, all);
|
||||
}
|
||||
|
||||
else if ((result = Token::findmatch(tok, "alloc ; if break|continue|return ;")) != NULL
|
||||
&& Token::findmatch(tok, "dealloc ; alloc ; if continue ;") == NULL)
|
||||
{
|
||||
MemoryLeak(result->tokAt(3), varname, alloctype, all);
|
||||
memoryLeak(result->tokAt(3), varname, alloctype, all);
|
||||
}
|
||||
|
||||
else if (_settings->_showAll && (result = Token::findmatch(tok, "alloc ; ifv break|continue|return ;")) != NULL)
|
||||
{
|
||||
MemoryLeak(result->tokAt(3), varname, alloctype, all);
|
||||
memoryLeak(result->tokAt(3), varname, alloctype, all);
|
||||
}
|
||||
|
||||
else if ((result = Token::findmatch(tok, "alloc ; alloc|assign|return callfunc| ;")) != NULL)
|
||||
{
|
||||
MemoryLeak(result->tokAt(2), varname, alloctype, all);
|
||||
memoryLeak(result->tokAt(2), varname, alloctype, all);
|
||||
}
|
||||
|
||||
else if ((result = Token::findmatch(tok, "dealloc ; dealloc ;")) != NULL)
|
||||
|
@ -1566,7 +1566,7 @@ void CheckMemoryLeakInFunction::checkScope(const Token *Tok1, const char varname
|
|||
const Token *last = tok;
|
||||
while (last->next())
|
||||
last = last->next();
|
||||
MemoryLeak(last, varname, alloctype, all);
|
||||
memoryLeak(last, varname, alloctype, all);
|
||||
}
|
||||
|
||||
// detect cases that "simplifycode" don't handle well..
|
||||
|
@ -1650,7 +1650,7 @@ void CheckMemoryLeakInFunction::check()
|
|||
// Declare a local variable => Check
|
||||
if (indentlevel > 0 && infunc)
|
||||
{
|
||||
unsigned int sz = _tokenizer->SizeOfType(tok->strAt(1));
|
||||
unsigned int sz = _tokenizer->sizeOfType(tok->strAt(1));
|
||||
if (sz < 1)
|
||||
sz = 1;
|
||||
|
||||
|
@ -1789,7 +1789,7 @@ void CheckMemoryLeakInClass::variable(const char classname[], const Token *tokVa
|
|||
|
||||
// Loop through all tokens. Inspect member functions
|
||||
int indent_ = 0;
|
||||
const Token *functionToken = Tokenizer::FindClassFunction(_tokenizer->tokens(), classname, "~| %var%", indent_);
|
||||
const Token *functionToken = Tokenizer::findClassFunction(_tokenizer->tokens(), classname, "~| %var%", indent_);
|
||||
while (functionToken)
|
||||
{
|
||||
int indent = 0;
|
||||
|
@ -1817,7 +1817,7 @@ void CheckMemoryLeakInClass::variable(const char classname[], const Token *tokVa
|
|||
// Allocate..
|
||||
if (indent == 0 || Token::Match(tok, (std::string(varname) + " =").c_str()))
|
||||
{
|
||||
AllocType alloc = GetAllocationType(tok->tokAt((indent > 0) ? 2 : 3));
|
||||
AllocType alloc = getAllocationType(tok->tokAt((indent > 0) ? 2 : 3));
|
||||
if (alloc != CheckMemoryLeak::No)
|
||||
{
|
||||
if (Alloc != No && Alloc != alloc)
|
||||
|
@ -1841,12 +1841,12 @@ void CheckMemoryLeakInClass::variable(const char classname[], const Token *tokVa
|
|||
// Deallocate..
|
||||
const char *varnames[3] = { "var", 0, 0 };
|
||||
varnames[0] = varname;
|
||||
AllocType dealloc = GetDeallocationType(tok, varnames);
|
||||
AllocType dealloc = getDeallocationType(tok, varnames);
|
||||
if (dealloc == No)
|
||||
{
|
||||
varnames[0] = "this";
|
||||
varnames[1] = varname;
|
||||
dealloc = GetDeallocationType(tok, varnames);
|
||||
dealloc = getDeallocationType(tok, varnames);
|
||||
}
|
||||
if (dealloc != CheckMemoryLeak::No)
|
||||
{
|
||||
|
@ -1867,12 +1867,12 @@ void CheckMemoryLeakInClass::variable(const char classname[], const Token *tokVa
|
|||
}
|
||||
}
|
||||
|
||||
functionToken = Tokenizer::FindClassFunction(functionToken->next(), classname, "~| %var%", indent_);
|
||||
functionToken = Tokenizer::findClassFunction(functionToken->next(), classname, "~| %var%", indent_);
|
||||
}
|
||||
|
||||
if (_settings->_showAll && Alloc != CheckMemoryLeak::No && Dealloc == CheckMemoryLeak::No)
|
||||
{
|
||||
MemoryLeak(tokVarname, (std::string(classname) + "::" + varname).c_str(), Alloc, true);
|
||||
memoryLeak(tokVarname, (std::string(classname) + "::" + varname).c_str(), Alloc, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,11 +49,10 @@ public:
|
|||
/** What type of allocation are used.. the "Many" means that several types of allocation and deallocation are used */
|
||||
enum AllocType { No, Malloc, gMalloc, New, NewArray, File, Fd, Pipe, Dir, Many };
|
||||
|
||||
void MemoryLeak(const Token *tok, const char varname[], AllocType alloctype, bool all);
|
||||
void MismatchError(const Token *Tok1, const std::list<const Token *> &callstack, const char varname[]);
|
||||
AllocType GetDeallocationType(const Token *tok, const char *varnames[]);
|
||||
AllocType GetAllocationType(const Token *tok2) const;
|
||||
AllocType GetReallocationType(const Token *tok2);
|
||||
void memoryLeak(const Token *tok, const char varname[], AllocType alloctype, bool all);
|
||||
AllocType getDeallocationType(const Token *tok, const char *varnames[]);
|
||||
AllocType getAllocationType(const Token *tok2) const;
|
||||
AllocType getReallocationType(const Token *tok2);
|
||||
bool isclass(const Tokenizer *_tokenizer, const Token *typestr) const;
|
||||
|
||||
void memleakError(const Token *tok, const std::string &varname);
|
||||
|
@ -108,7 +107,7 @@ private:
|
|||
|
||||
private:
|
||||
|
||||
bool MatchFunctionsThatReturnArg(const Token *tok, const std::string &varname);
|
||||
bool matchFunctionsThatReturnArg(const Token *tok, const std::string &varname);
|
||||
|
||||
/**
|
||||
* Check if there is a "!var" match inside a condition
|
||||
|
|
|
@ -40,7 +40,7 @@ CheckOther instance;
|
|||
|
||||
|
||||
|
||||
void CheckOther::WarningOldStylePointerCast()
|
||||
void CheckOther::warningOldStylePointerCast()
|
||||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ void CheckOther::WarningOldStylePointerCast()
|
|||
// Redundant code..
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::WarningRedundantCode()
|
||||
void CheckOther::warningRedundantCode()
|
||||
{
|
||||
|
||||
// if (p) delete p
|
||||
|
@ -188,7 +188,7 @@ void CheckOther::redundantCondition2()
|
|||
// if (condition) ....
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::WarningIf()
|
||||
void CheckOther::warningIf()
|
||||
{
|
||||
if (ErrorLogger::ifNoAction(*_settings))
|
||||
{
|
||||
|
@ -306,7 +306,7 @@ void CheckOther::WarningIf()
|
|||
// strtol(str, 0, radix) <- radix must be 0 or 2-36
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::InvalidFunctionUsage()
|
||||
void CheckOther::invalidFunctionUsage()
|
||||
{
|
||||
// strtol and strtoul..
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
|
@ -389,7 +389,7 @@ void CheckOther::InvalidFunctionUsage()
|
|||
// Check for unsigned divisions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::CheckUnsignedDivision()
|
||||
void CheckOther::checkUnsignedDivision()
|
||||
{
|
||||
// Check for "ivar / uvar" and "uvar / ivar"
|
||||
std::map<std::string, char> varsign;
|
||||
|
@ -457,7 +457,7 @@ void CheckOther::CheckUnsignedDivision()
|
|||
// Check scope of variables..
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::CheckVariableScope()
|
||||
void CheckOther::checkVariableScope()
|
||||
{
|
||||
// Walk through all tokens..
|
||||
bool func = false;
|
||||
|
@ -530,7 +530,7 @@ void CheckOther::CheckVariableScope()
|
|||
// Variable declaration?
|
||||
if (Token::Match(tok1, "%type% %var% [;=]"))
|
||||
{
|
||||
CheckVariableScope_LookupVar(tok1, tok1->strAt(1));
|
||||
lookupVar(tok1, tok1->strAt(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ void CheckOther::CheckVariableScope()
|
|||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::CheckVariableScope_LookupVar(const Token *tok1, const char varname[])
|
||||
void CheckOther::lookupVar(const Token *tok1, const char varname[])
|
||||
{
|
||||
const Token *tok = tok1;
|
||||
|
||||
|
@ -619,7 +619,7 @@ void CheckOther::CheckVariableScope_LookupVar(const Token *tok1, const char varn
|
|||
// Check for constant function parameters
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::CheckConstantFunctionParameter()
|
||||
void CheckOther::checkConstantFunctionParameter()
|
||||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ void CheckOther::CheckConstantFunctionParameter()
|
|||
// Check that all struct members are used
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::CheckStructMemberUsage()
|
||||
void CheckOther::checkStructMemberUsage()
|
||||
{
|
||||
const char *structname = 0;
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
|
@ -716,7 +716,7 @@ void CheckOther::CheckStructMemberUsage()
|
|||
// Check usage of char variables..
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::CheckCharVariable()
|
||||
void CheckOther::checkCharVariable()
|
||||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
|
@ -790,7 +790,7 @@ void CheckOther::CheckCharVariable()
|
|||
// Incomplete statement..
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckOther::CheckIncompleteStatement()
|
||||
void CheckOther::checkIncompleteStatement()
|
||||
{
|
||||
int parlevel = 0;
|
||||
|
||||
|
@ -951,7 +951,7 @@ void CheckOther::nullPointer()
|
|||
|
||||
|
||||
|
||||
void CheckOther::CheckZeroDivision()
|
||||
void CheckOther::checkZeroDivision()
|
||||
{
|
||||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
|
|
|
@ -46,9 +46,9 @@ public:
|
|||
|
||||
if (settings->_checkCodingStyle)
|
||||
{
|
||||
checkOther.WarningOldStylePointerCast();
|
||||
checkOther.CheckUnsignedDivision();
|
||||
checkOther.CheckCharVariable();
|
||||
checkOther.warningOldStylePointerCast();
|
||||
checkOther.checkUnsignedDivision();
|
||||
checkOther.checkCharVariable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,49 +58,49 @@ public:
|
|||
|
||||
if (settings->_checkCodingStyle)
|
||||
{
|
||||
checkOther.WarningRedundantCode();
|
||||
checkOther.WarningIf();
|
||||
checkOther.CheckVariableScope();
|
||||
checkOther.CheckConstantFunctionParameter();
|
||||
checkOther.CheckStructMemberUsage();
|
||||
checkOther.CheckIncompleteStatement();
|
||||
checkOther.warningRedundantCode();
|
||||
checkOther.warningIf();
|
||||
checkOther.checkVariableScope();
|
||||
checkOther.checkConstantFunctionParameter();
|
||||
checkOther.checkStructMemberUsage();
|
||||
checkOther.checkIncompleteStatement();
|
||||
}
|
||||
|
||||
checkOther.strPlusChar();
|
||||
checkOther.InvalidFunctionUsage();
|
||||
checkOther.invalidFunctionUsage();
|
||||
checkOther.nullPointer();
|
||||
checkOther.CheckZeroDivision();
|
||||
checkOther.checkZeroDivision();
|
||||
}
|
||||
|
||||
// Casting
|
||||
void WarningOldStylePointerCast();
|
||||
void warningOldStylePointerCast();
|
||||
|
||||
// Redundant code
|
||||
void WarningRedundantCode();
|
||||
void warningRedundantCode();
|
||||
|
||||
// Warning upon: if (condition);
|
||||
void WarningIf();
|
||||
void warningIf();
|
||||
|
||||
// Invalid function usage..
|
||||
void InvalidFunctionUsage();
|
||||
void invalidFunctionUsage();
|
||||
|
||||
// Check for unsigned division that might create bad results
|
||||
void CheckUnsignedDivision();
|
||||
void checkUnsignedDivision();
|
||||
|
||||
// Check scope of variables
|
||||
void CheckVariableScope();
|
||||
void checkVariableScope();
|
||||
|
||||
// Check for constant function parameter
|
||||
void CheckConstantFunctionParameter();
|
||||
void checkConstantFunctionParameter();
|
||||
|
||||
// Check that all struct members are used
|
||||
void CheckStructMemberUsage();
|
||||
void checkStructMemberUsage();
|
||||
|
||||
// Using char variable as array index / as operand in bit operation
|
||||
void CheckCharVariable();
|
||||
void checkCharVariable();
|
||||
|
||||
// Incomplete statement. A statement that only contains a constant or variable
|
||||
void CheckIncompleteStatement();
|
||||
void checkIncompleteStatement();
|
||||
|
||||
/** str plus char */
|
||||
void strPlusChar();
|
||||
|
@ -109,10 +109,10 @@ public:
|
|||
void nullPointer();
|
||||
|
||||
/** Check zero division*/
|
||||
void CheckZeroDivision();
|
||||
void checkZeroDivision();
|
||||
|
||||
protected:
|
||||
void CheckVariableScope_LookupVar(const Token *tok1, const char varname[]);
|
||||
void lookupVar(const Token *tok1, const char varname[]);
|
||||
|
||||
// Redundant condition
|
||||
// if (haystack.find(needle) != haystack.end())
|
||||
|
|
|
@ -51,7 +51,7 @@ void CppCheck::settings(const Settings &settings)
|
|||
|
||||
void CppCheck::addFile(const std::string &path)
|
||||
{
|
||||
FileLister::RecursiveAddFiles(_filenames, path.c_str(), true);
|
||||
FileLister::recursiveAddFiles(_filenames, path.c_str(), true);
|
||||
}
|
||||
|
||||
void CppCheck::addFile(const std::string &path, const std::string &content)
|
||||
|
@ -255,10 +255,10 @@ std::string CppCheck::parseFromArgs(int argc, const char* const argv[])
|
|||
|
||||
if (pathnames.size() > 0)
|
||||
{
|
||||
// Execute RecursiveAddFiles() to each given file parameter
|
||||
// Execute recursiveAddFiles() to each given file parameter
|
||||
std::vector<std::string>::const_iterator iter;
|
||||
for (iter = pathnames.begin(); iter != pathnames.end(); iter++)
|
||||
FileLister::RecursiveAddFiles(_filenames, iter->c_str(), true);
|
||||
FileLister::recursiveAddFiles(_filenames, iter->c_str(), true);
|
||||
}
|
||||
|
||||
if (argc <= 1 || showHelp)
|
||||
|
|
|
@ -88,7 +88,7 @@ std::string FileLister::simplifyPath(const char *originalPath)
|
|||
|
||||
|
||||
|
||||
bool FileLister::AcceptFile(const std::string &filename)
|
||||
bool FileLister::acceptFile(const std::string &filename)
|
||||
{
|
||||
std::string::size_type dotLocation = filename.find_last_of('.');
|
||||
if (dotLocation == std::string::npos)
|
||||
|
@ -115,7 +115,7 @@ bool FileLister::AcceptFile(const std::string &filename)
|
|||
|
||||
#if defined(__GNUC__) && !defined(__MINGW32__)
|
||||
// gcc / cygwin..
|
||||
void FileLister::RecursiveAddFiles(std::vector<std::string> &filenames, const std::string &path, bool recursive)
|
||||
void FileLister::recursiveAddFiles(std::vector<std::string> &filenames, const std::string &path, bool recursive)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << path;
|
||||
|
@ -135,13 +135,13 @@ void FileLister::RecursiveAddFiles(std::vector<std::string> &filenames, const st
|
|||
// File
|
||||
|
||||
// If recursive is not used, accept all files given by user
|
||||
if (!recursive || FileLister::AcceptFile(filename))
|
||||
if (!recursive || FileLister::acceptFile(filename))
|
||||
filenames.push_back(filename);
|
||||
}
|
||||
else if (recursive)
|
||||
{
|
||||
// Directory
|
||||
FileLister::RecursiveAddFiles(filenames, filename, recursive);
|
||||
FileLister::recursiveAddFiles(filenames, filename, recursive);
|
||||
}
|
||||
}
|
||||
globfree(&glob_results);
|
||||
|
@ -209,7 +209,7 @@ static HANDLE MyFindFirstFile(std::string path, LPWIN32_FIND_DATA findData)
|
|||
|
||||
#endif // defined(QT_CORE_LIB)
|
||||
|
||||
void FileLister::RecursiveAddFiles(std::vector<std::string> &filenames, const std::string &path, bool recursive)
|
||||
void FileLister::recursiveAddFiles(std::vector<std::string> &filenames, const std::string &path, bool recursive)
|
||||
{
|
||||
// oss is the search string passed into FindFirst and FindNext.
|
||||
// bdir is the base directory which is used to form pathnames.
|
||||
|
@ -273,13 +273,13 @@ void FileLister::RecursiveAddFiles(std::vector<std::string> &filenames, const st
|
|||
// File
|
||||
|
||||
// If recursive is not used, accept all files given by user
|
||||
if (!recursive || FileLister::AcceptFile(ansiFfd))
|
||||
if (!recursive || FileLister::acceptFile(ansiFfd))
|
||||
filenames.push_back(fname.str());
|
||||
}
|
||||
else if (recursive)
|
||||
{
|
||||
// Directory
|
||||
FileLister::RecursiveAddFiles(filenames, fname.str().c_str(), recursive);
|
||||
FileLister::recursiveAddFiles(filenames, fname.str().c_str(), recursive);
|
||||
}
|
||||
#if defined(QT_CORE_LIB)
|
||||
delete [] ansiFfd;
|
||||
|
@ -298,7 +298,7 @@ void FileLister::RecursiveAddFiles(std::vector<std::string> &filenames, const st
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool FileLister::SameFileName(const char fname1[], const char fname2[])
|
||||
bool FileLister::sameFileName(const char fname1[], const char fname2[])
|
||||
{
|
||||
#ifdef __linux__
|
||||
return bool(strcmp(fname1, fname2) == 0);
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#ifndef __GNUC__
|
||||
#ifndef __BORLANDC__
|
||||
#ifndef _MSC_VER
|
||||
#error "C++Check must be compiled by either GCC/BORLAND/MSC to work fully.\n"
|
||||
#error "Please report that you couldn't compile c++check through the web page:\n"
|
||||
#error "Cppcheck must be compiled by either GCC/BORLAND/MSC to work fully.\n"
|
||||
#error "Please report that you couldn't compile cppcheck through the web page:\n"
|
||||
#error " https://sourceforge.net/projects/cppcheck/"
|
||||
#endif
|
||||
#endif
|
||||
|
@ -38,10 +38,10 @@
|
|||
class FileLister
|
||||
{
|
||||
public:
|
||||
static void RecursiveAddFiles(std::vector<std::string> &filenames, const std::string &path, bool recursive);
|
||||
static void recursiveAddFiles(std::vector<std::string> &filenames, const std::string &path, bool recursive);
|
||||
static std::string simplifyPath(const char *originalPath);
|
||||
static bool SameFileName(const char fname1[], const char fname2[]);
|
||||
static bool AcceptFile(const std::string &filename);
|
||||
static bool sameFileName(const char fname1[], const char fname2[]);
|
||||
static bool acceptFile(const std::string &filename);
|
||||
private:
|
||||
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ Tokenizer::Tokenizer(const Settings &settings, ErrorLogger *errorLogger)
|
|||
|
||||
Tokenizer::~Tokenizer()
|
||||
{
|
||||
DeallocateTokens();
|
||||
deallocateTokens();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -118,7 +118,7 @@ void Tokenizer::addtoken(const char str[], const unsigned int lineno, const unsi
|
|||
|
||||
|
||||
|
||||
int Tokenizer::SizeOfType(const char type[]) const
|
||||
int Tokenizer::sizeOfType(const char type[]) const
|
||||
{
|
||||
if (!type)
|
||||
return 0;
|
||||
|
@ -135,7 +135,7 @@ int Tokenizer::SizeOfType(const char type[]) const
|
|||
// InsertTokens - Copy and insert tokens
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void Tokenizer::InsertTokens(Token *dest, Token *src, unsigned int n)
|
||||
void Tokenizer::insertTokens(Token *dest, Token *src, unsigned int n)
|
||||
{
|
||||
while (n > 0)
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ void Tokenizer::createTokens(std::istream &code)
|
|||
fileIndexes.push_back(FileIndex);
|
||||
for (unsigned int i = 0; i < _files.size(); i++)
|
||||
{
|
||||
if (FileLister::SameFileName(_files[i].c_str(), line.c_str()))
|
||||
if (FileLister::sameFileName(_files[i].c_str(), line.c_str()))
|
||||
{
|
||||
// Use this index
|
||||
foundOurfile = true;
|
||||
|
@ -1269,7 +1269,7 @@ void Tokenizer::simplifyTokenList()
|
|||
if (Token::Match(tok, "sizeof ( * )"))
|
||||
{
|
||||
std::ostringstream str;
|
||||
str << SizeOfType(tok->strAt(2));
|
||||
str << sizeOfType(tok->strAt(2));
|
||||
tok->str(str.str());
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
|
@ -1287,7 +1287,7 @@ void Tokenizer::simplifyTokenList()
|
|||
else if (Token::Match(tok, "sizeof ( %type% )"))
|
||||
{
|
||||
const char *type = tok->strAt(2);
|
||||
int size = SizeOfType(type);
|
||||
int size = sizeOfType(type);
|
||||
if (size > 0)
|
||||
{
|
||||
std::ostringstream str;
|
||||
|
@ -1312,7 +1312,7 @@ void Tokenizer::simplifyTokenList()
|
|||
const Token *decltok = Token::findmatch(_tokens, "%type% %varid% [", varid);
|
||||
if (decltok)
|
||||
{
|
||||
sz = SizeOfType(decltok->strAt(0));
|
||||
sz = sizeOfType(decltok->strAt(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1336,7 +1336,7 @@ void Tokenizer::simplifyTokenList()
|
|||
|
||||
const int type_tok = ((tok->next()->str() == "*") ? 1 : 0);
|
||||
|
||||
int size = SizeOfType(tok->tokAt(type_tok)->str().c_str());
|
||||
int size = sizeOfType(tok->tokAt(type_tok)->str().c_str());
|
||||
if (size <= 0)
|
||||
continue;
|
||||
|
||||
|
@ -2205,7 +2205,7 @@ bool Tokenizer::simplifyVarDecl()
|
|||
if (tok2->str() == ",")
|
||||
{
|
||||
tok2->str(";");
|
||||
InsertTokens(tok2, type0, typelen);
|
||||
insertTokens(tok2, type0, typelen);
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -2233,14 +2233,14 @@ bool Tokenizer::simplifyVarDecl()
|
|||
Token *VarTok = type0->tokAt(typelen);
|
||||
while (Token::Match(VarTok, "*|const"))
|
||||
VarTok = VarTok->next();
|
||||
InsertTokens(eq, VarTok, 2);
|
||||
insertTokens(eq, VarTok, 2);
|
||||
eq->str(";");
|
||||
|
||||
// "= x, " => "= x; type "
|
||||
if (tok2->str() == ",")
|
||||
{
|
||||
tok2->str(";");
|
||||
InsertTokens(tok2, type0, typelen);
|
||||
insertTokens(tok2, type0, typelen);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2754,7 +2754,7 @@ bool Tokenizer::simplifyCalculations()
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const Token *Tokenizer::GetFunctionTokenByName(const char funcname[]) const
|
||||
const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const
|
||||
{
|
||||
for (unsigned int i = 0; i < _functionList.size(); ++i)
|
||||
{
|
||||
|
@ -2852,7 +2852,7 @@ void Tokenizer::fillFunctionList()
|
|||
//---------------------------------------------------------------------------
|
||||
|
||||
// Deallocate lists..
|
||||
void Tokenizer::DeallocateTokens()
|
||||
void Tokenizer::deallocateTokens()
|
||||
{
|
||||
deleteTokens(_tokens);
|
||||
_tokens = 0;
|
||||
|
@ -2901,7 +2901,7 @@ std::string Tokenizer::file(const Token *tok) const
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const Token * Tokenizer::FindClassFunction(const Token *tok, const char classname[], const char funcname[], int &indentlevel)
|
||||
const Token * Tokenizer::findClassFunction(const Token *tok, const char classname[], const char funcname[], int &indentlevel)
|
||||
{
|
||||
if (indentlevel < 0 || tok == NULL)
|
||||
return NULL;
|
||||
|
|
|
@ -33,7 +33,7 @@ class Tokenizer
|
|||
{
|
||||
private:
|
||||
// Deallocate lists..
|
||||
void DeallocateTokens();
|
||||
void deallocateTokens();
|
||||
|
||||
public:
|
||||
Tokenizer();
|
||||
|
@ -81,14 +81,14 @@ public:
|
|||
std::string fileLine(const Token *tok) const;
|
||||
|
||||
// Return size.
|
||||
int SizeOfType(const char type[]) const;
|
||||
int sizeOfType(const char type[]) const;
|
||||
|
||||
void initTokens();
|
||||
|
||||
const std::vector<std::string> *getFiles() const;
|
||||
|
||||
void fillFunctionList();
|
||||
const Token *GetFunctionTokenByName(const char funcname[]) const;
|
||||
const Token *getFunctionTokenByName(const char funcname[]) const;
|
||||
const Token *tokens() const;
|
||||
|
||||
std::string file(const Token *tok) const;
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
* @param indentlevel Just an integer that you initialize to 0 before the first call.
|
||||
* @return First matching token or NULL.
|
||||
*/
|
||||
static const Token *FindClassFunction(const Token *tok, const char classname[], const char funcname[], int &indentlevel);
|
||||
static const Token *findClassFunction(const Token *tok, const char classname[], const char funcname[], int &indentlevel);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -253,7 +253,7 @@ private:
|
|||
*/
|
||||
void simplifyTemplates();
|
||||
|
||||
void InsertTokens(Token *dest, Token *src, unsigned int n);
|
||||
void insertTokens(Token *dest, Token *src, unsigned int n);
|
||||
|
||||
/**
|
||||
* Setup links for tokens so that one can call Token::link().
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
// Check char variable usage..
|
||||
Settings settings;
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.CheckCharVariable();
|
||||
checkOther.checkCharVariable();
|
||||
}
|
||||
|
||||
void array_index()
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
|
||||
// The preprocessor that c++check uses is a bit special. Instead of generating
|
||||
// The preprocessor that Cppcheck uses is a bit special. Instead of generating
|
||||
// the code for a known configuration, it generates the code for each configuration.
|
||||
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
// Check for unsigned divisions..
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.CheckUnsignedDivision();
|
||||
checkOther.checkUnsignedDivision();
|
||||
}
|
||||
|
||||
void run()
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
// Check for unused variables..
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.CheckIncompleteStatement();
|
||||
checkOther.checkIncompleteStatement();
|
||||
}
|
||||
|
||||
void run()
|
||||
|
|
|
@ -78,8 +78,8 @@ private:
|
|||
// Check for redundant code..
|
||||
Settings settings;
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.WarningRedundantCode();
|
||||
checkOther.CheckZeroDivision();
|
||||
checkOther.warningRedundantCode();
|
||||
checkOther.checkZeroDivision();
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,7 +197,7 @@ private:
|
|||
// Check for redundant code..
|
||||
Settings settings;
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.InvalidFunctionUsage();
|
||||
checkOther.invalidFunctionUsage();
|
||||
}
|
||||
|
||||
void sprintf1()
|
||||
|
@ -317,7 +317,7 @@ private:
|
|||
Settings settings;
|
||||
settings._checkCodingStyle = true;
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.CheckVariableScope();
|
||||
checkOther.checkVariableScope();
|
||||
}
|
||||
|
||||
void varScope1()
|
||||
|
@ -445,7 +445,7 @@ private:
|
|||
Settings settings;
|
||||
settings._checkCodingStyle = true;
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.WarningOldStylePointerCast();
|
||||
checkOther.warningOldStylePointerCast();
|
||||
}
|
||||
|
||||
void oldStylePointerCast()
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
|
||||
// The preprocessor that c++check uses is a bit special. Instead of generating
|
||||
// The preprocessor that Cppcheck uses is a bit special. Instead of generating
|
||||
// the code for a known configuration, it generates the code for each configuration.
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
|
||||
// The preprocessor that c++check uses is a bit special. Instead of generating
|
||||
// The preprocessor that Cppcheck uses is a bit special. Instead of generating
|
||||
// the code for a known configuration, it generates the code for each configuration.
|
||||
|
||||
|
||||
|
@ -2060,9 +2060,9 @@ private:
|
|||
int i;
|
||||
|
||||
i = 0;
|
||||
const Token *tok = Tokenizer::FindClassFunction(tokenizer.tokens(), "Fred", "%var%", i);
|
||||
const Token *tok = Tokenizer::findClassFunction(tokenizer.tokens(), "Fred", "%var%", i);
|
||||
ASSERT_EQUALS(true, Token::simpleMatch(tok, "Fred ( ) {"));
|
||||
tok = Tokenizer::FindClassFunction(tok->next(), "Fred", "%var%", i);
|
||||
tok = Tokenizer::findClassFunction(tok->next(), "Fred", "%var%", i);
|
||||
ASSERT_EQUALS(0, tok ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
// Check for unused variables..
|
||||
Settings settings;
|
||||
CheckOther checkOther(&tokenizer, &settings, this);
|
||||
checkOther.CheckStructMemberUsage();
|
||||
checkOther.checkStructMemberUsage();
|
||||
}
|
||||
|
||||
void run()
|
||||
|
|
|
@ -65,14 +65,14 @@ int main()
|
|||
{
|
||||
// Get files..
|
||||
std::vector<std::string> srcfiles;
|
||||
FileLister::RecursiveAddFiles(srcfiles, "src/", true);
|
||||
FileLister::recursiveAddFiles(srcfiles, "src/", true);
|
||||
if (srcfiles.empty())
|
||||
{
|
||||
std::cout << "No source files found." << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
std::vector<std::string> testfiles;
|
||||
FileLister::RecursiveAddFiles(testfiles, "test/", true);
|
||||
FileLister::recursiveAddFiles(testfiles, "test/", true);
|
||||
|
||||
std::ofstream fout("Makefile");
|
||||
|
||||
|
|
Loading…
Reference in New Issue