Class checking : Renamed the check functions
This commit is contained in:
parent
fe94c577bc
commit
6b06df766b
|
@ -311,7 +311,7 @@ void CheckClass::ClassChecking_VarList_Initialize(const TOKEN *tok1, const TOKEN
|
||||||
// ClassCheck: Check that all class constructors are ok.
|
// ClassCheck: Check that all class constructors are ok.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void CheckClass::CheckConstructors()
|
void CheckClass::constructors()
|
||||||
{
|
{
|
||||||
const char pattern_class[] = "class %var% {";
|
const char pattern_class[] = "class %var% {";
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ void CheckClass::CheckConstructors(const TOKEN *tok1, struct VAR *varlist, const
|
||||||
// ClassCheck: Unused private functions
|
// ClassCheck: Unused private functions
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void CheckClass::CheckUnusedPrivateFunctions()
|
void CheckClass::privateFunctions()
|
||||||
{
|
{
|
||||||
// Locate some class
|
// Locate some class
|
||||||
const char *pattern_class[] = {"class","","{",NULL};
|
const char *pattern_class[] = {"class","","{",NULL};
|
||||||
|
@ -601,7 +601,7 @@ void CheckClass::CheckUnusedPrivateFunctions()
|
||||||
// ClassCheck: Check that memset is not used on classes
|
// ClassCheck: Check that memset is not used on classes
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void CheckClass::CheckMemset()
|
void CheckClass::noMemset()
|
||||||
{
|
{
|
||||||
// Locate all 'memset' tokens..
|
// Locate all 'memset' tokens..
|
||||||
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||||
|
@ -664,7 +664,7 @@ void CheckClass::CheckMemset()
|
||||||
// ClassCheck: "void operator=("
|
// ClassCheck: "void operator=("
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
void CheckClass::CheckOperatorEq1()
|
void CheckClass::operatorEq()
|
||||||
{
|
{
|
||||||
if (const TOKEN *tok = TOKEN::findmatch(_tokenizer->tokens(), "void operator = ("))
|
if (const TOKEN *tok = TOKEN::findmatch(_tokenizer->tokens(), "void operator = ("))
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,13 +31,13 @@ public:
|
||||||
CheckClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger );
|
CheckClass( const Tokenizer *tokenizer, const Settings &settings, ErrorLogger *errorLogger );
|
||||||
~CheckClass();
|
~CheckClass();
|
||||||
|
|
||||||
void CheckConstructors();
|
void constructors();
|
||||||
|
|
||||||
void CheckUnusedPrivateFunctions();
|
void privateFunctions();
|
||||||
|
|
||||||
void CheckMemset();
|
void noMemset();
|
||||||
|
|
||||||
void CheckOperatorEq1(); // Warning upon "void operator=(.."
|
void operatorEq(); // Warning upon "void operator=(.."
|
||||||
|
|
||||||
// The destructor in a base class should be virtual
|
// The destructor in a base class should be virtual
|
||||||
void virtualDestructor();
|
void virtualDestructor();
|
||||||
|
|
|
@ -211,7 +211,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
// The 'memset' function can do dangerous things if used wrong.
|
// The 'memset' function can do dangerous things if used wrong.
|
||||||
// Important: The checking doesn't work on simplified tokens list.
|
// Important: The checking doesn't work on simplified tokens list.
|
||||||
CheckClass checkClass( &_tokenizer, _settings, this );
|
CheckClass checkClass( &_tokenizer, _settings, this );
|
||||||
checkClass.CheckMemset();
|
checkClass.noMemset();
|
||||||
|
|
||||||
|
|
||||||
// Check for unsigned divisions where one operand is signed
|
// Check for unsigned divisions where one operand is signed
|
||||||
|
@ -249,7 +249,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
checkBufferOverrun.CheckBufferOverrun();
|
checkBufferOverrun.CheckBufferOverrun();
|
||||||
|
|
||||||
// Check that all class constructors are ok.
|
// Check that all class constructors are ok.
|
||||||
checkClass.CheckConstructors();
|
checkClass.constructors();
|
||||||
|
|
||||||
// Check that all base classes have virtual destructors
|
// Check that all base classes have virtual destructors
|
||||||
checkClass.virtualDestructor();
|
checkClass.virtualDestructor();
|
||||||
|
@ -281,14 +281,14 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
||||||
if (_settings._checkCodingStyle)
|
if (_settings._checkCodingStyle)
|
||||||
{
|
{
|
||||||
// Check that all private functions are called.
|
// Check that all private functions are called.
|
||||||
checkClass.CheckUnusedPrivateFunctions();
|
checkClass.privateFunctions();
|
||||||
|
|
||||||
// Warning upon c-style pointer casts
|
// Warning upon c-style pointer casts
|
||||||
const char *ext = strrchr(FileName, '.');
|
const char *ext = strrchr(FileName, '.');
|
||||||
if (ext && strcmp(ext,".cpp")==0)
|
if (ext && strcmp(ext,".cpp")==0)
|
||||||
checkOther.WarningOldStylePointerCast();
|
checkOther.WarningOldStylePointerCast();
|
||||||
|
|
||||||
checkClass.CheckOperatorEq1();
|
checkClass.operatorEq();
|
||||||
|
|
||||||
// if (a) delete a;
|
// if (a) delete a;
|
||||||
checkOther.WarningRedundantCode();
|
checkOther.WarningRedundantCode();
|
||||||
|
|
|
@ -50,7 +50,7 @@ private:
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings._checkCodingStyle = true;
|
settings._checkCodingStyle = true;
|
||||||
CheckClass checkClass( &tokenizer, settings, this );
|
CheckClass checkClass( &tokenizer, settings, this );
|
||||||
checkClass.CheckConstructors();
|
checkClass.constructors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
|
|
|
@ -56,7 +56,7 @@ private:
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings._checkCodingStyle = true;
|
settings._checkCodingStyle = true;
|
||||||
CheckClass checkClass( &tokenizer, settings, this );
|
CheckClass checkClass( &tokenizer, settings, this );
|
||||||
checkClass.CheckUnusedPrivateFunctions();
|
checkClass.privateFunctions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue