Rename private member variable
This commit is contained in:
parent
19cf0d1fa4
commit
e90c04cff9
|
@ -69,7 +69,7 @@ static const char * getFunctionTypeName(Function::Type type)
|
||||||
|
|
||||||
CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
CheckClass::CheckClass(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
|
||||||
: Check(myName(), tokenizer, settings, errorLogger),
|
: Check(myName(), tokenizer, settings, errorLogger),
|
||||||
symbolDatabase(tokenizer?tokenizer->getSymbolDatabase():nullptr)
|
mSymbolDatabase(tokenizer?tokenizer->getSymbolDatabase():nullptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,10 @@ void CheckClass::constructors()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const bool printInconclusive = mSettings->inconclusive;
|
const bool printInconclusive = mSettings->inconclusive;
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
|
|
||||||
bool usedInUnion = false;
|
bool usedInUnion = false;
|
||||||
for (const Scope &unionScope : symbolDatabase->scopeList) {
|
for (const Scope &unionScope : mSymbolDatabase->scopeList) {
|
||||||
if (unionScope.type != Scope::eUnion)
|
if (unionScope.type != Scope::eUnion)
|
||||||
continue;
|
continue;
|
||||||
for (const Variable &var : unionScope.varlist) {
|
for (const Variable &var : unionScope.varlist) {
|
||||||
|
@ -235,7 +235,7 @@ void CheckClass::checkExplicitConstructors()
|
||||||
if (!mSettings->isEnabled(Settings::STYLE))
|
if (!mSettings->isEnabled(Settings::STYLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
// Do not perform check, if the class/struct has not any constructors
|
// Do not perform check, if the class/struct has not any constructors
|
||||||
if (scope->numConstructors == 0)
|
if (scope->numConstructors == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -304,7 +304,7 @@ void CheckClass::copyconstructors()
|
||||||
if (!mSettings->isEnabled(Settings::STYLE))
|
if (!mSettings->isEnabled(Settings::STYLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
std::map<unsigned int, const Token*> allocatedVars;
|
std::map<unsigned int, const Token*> allocatedVars;
|
||||||
|
|
||||||
for (const Function &func : scope->functionList) {
|
for (const Function &func : scope->functionList) {
|
||||||
|
@ -917,7 +917,7 @@ void CheckClass::initializationListUsage()
|
||||||
if (!mSettings->isEnabled(Settings::PERFORMANCE))
|
if (!mSettings->isEnabled(Settings::PERFORMANCE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope *scope : symbolDatabase->functionScopes) {
|
for (const Scope *scope : mSymbolDatabase->functionScopes) {
|
||||||
// Check every constructor
|
// Check every constructor
|
||||||
if (!scope->function || (!scope->function->isConstructor()))
|
if (!scope->function || (!scope->function->isConstructor()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1030,7 +1030,7 @@ void CheckClass::privateFunctions()
|
||||||
if (!mSettings->isEnabled(Settings::STYLE))
|
if (!mSettings->isEnabled(Settings::STYLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
|
|
||||||
// do not check borland classes with properties..
|
// do not check borland classes with properties..
|
||||||
if (Token::findsimplematch(scope->bodyStart, "; __property ;", scope->bodyEnd))
|
if (Token::findsimplematch(scope->bodyStart, "; __property ;", scope->bodyEnd))
|
||||||
|
@ -1096,7 +1096,7 @@ static const Scope* findFunctionOf(const Scope* scope)
|
||||||
void CheckClass::checkMemset()
|
void CheckClass::checkMemset()
|
||||||
{
|
{
|
||||||
const bool printWarnings = mSettings->isEnabled(Settings::WARNING);
|
const bool printWarnings = mSettings->isEnabled(Settings::WARNING);
|
||||||
for (const Scope *scope : symbolDatabase->functionScopes) {
|
for (const Scope *scope : mSymbolDatabase->functionScopes) {
|
||||||
for (const Token *tok = scope->bodyStart; tok && tok != scope->bodyEnd; tok = tok->next()) {
|
for (const Token *tok = scope->bodyStart; tok && tok != scope->bodyEnd; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "memset|memcpy|memmove (")) {
|
if (Token::Match(tok, "memset|memcpy|memmove (")) {
|
||||||
const Token* arg1 = tok->tokAt(2);
|
const Token* arg1 = tok->tokAt(2);
|
||||||
|
@ -1290,7 +1290,7 @@ void CheckClass::operatorEq()
|
||||||
if (!mSettings->isEnabled(Settings::STYLE))
|
if (!mSettings->isEnabled(Settings::STYLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||||
if (func->type == Function::eOperatorEqual && func->access == Public) {
|
if (func->type == Function::eOperatorEqual && func->access == Public) {
|
||||||
// skip "deleted" functions - cannot be called anyway
|
// skip "deleted" functions - cannot be called anyway
|
||||||
|
@ -1343,7 +1343,7 @@ void CheckClass::operatorEqRetRefThis()
|
||||||
if (!mSettings->isEnabled(Settings::STYLE))
|
if (!mSettings->isEnabled(Settings::STYLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||||
if (func->type == Function::eOperatorEqual && func->hasBody()) {
|
if (func->type == Function::eOperatorEqual && func->hasBody()) {
|
||||||
// make sure return signature is correct
|
// make sure return signature is correct
|
||||||
|
@ -1474,7 +1474,7 @@ void CheckClass::operatorEqToSelf()
|
||||||
if (!mSettings->isEnabled(Settings::WARNING))
|
if (!mSettings->isEnabled(Settings::WARNING))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
// skip classes with multiple inheritance
|
// skip classes with multiple inheritance
|
||||||
if (scope->definedType->derivedFrom.size() > 1)
|
if (scope->definedType->derivedFrom.size() > 1)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1598,7 +1598,7 @@ void CheckClass::virtualDestructor()
|
||||||
|
|
||||||
std::list<const Function *> inconclusiveErrors;
|
std::list<const Function *> inconclusiveErrors;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
|
|
||||||
// Skip base classes (unless inconclusive)
|
// Skip base classes (unless inconclusive)
|
||||||
if (scope->definedType->derivedFrom.empty()) {
|
if (scope->definedType->derivedFrom.empty()) {
|
||||||
|
@ -1648,7 +1648,7 @@ void CheckClass::virtualDestructor()
|
||||||
// pointer variables of type 'Base *'
|
// pointer variables of type 'Base *'
|
||||||
std::set<unsigned int> baseClassPointers;
|
std::set<unsigned int> baseClassPointers;
|
||||||
|
|
||||||
for (const Variable* var : symbolDatabase->variableList()) {
|
for (const Variable* var : mSymbolDatabase->variableList()) {
|
||||||
if (var && var->isPointer() && var->type() == derivedFrom)
|
if (var && var->isPointer() && var->type() == derivedFrom)
|
||||||
baseClassPointers.insert(var->declarationId());
|
baseClassPointers.insert(var->declarationId());
|
||||||
}
|
}
|
||||||
|
@ -1774,7 +1774,7 @@ void CheckClass::checkConst()
|
||||||
if (!mSettings->isEnabled(Settings::STYLE))
|
if (!mSettings->isEnabled(Settings::STYLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||||
// does the function have a body?
|
// does the function have a body?
|
||||||
if (func->type != Function::eFunction || !func->hasBody())
|
if (func->type != Function::eFunction || !func->hasBody())
|
||||||
|
@ -1876,7 +1876,7 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
|
||||||
for (std::list<Variable>::const_iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
for (std::list<Variable>::const_iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
||||||
if (var->name() == tok->str()) {
|
if (var->name() == tok->str()) {
|
||||||
if (tok->varId() == 0)
|
if (tok->varId() == 0)
|
||||||
symbolDatabase->debugMessage(tok, "CheckClass::isMemberVar found used member variable \'" + tok->str() + "\' with varid 0");
|
mSymbolDatabase->debugMessage(tok, "CheckClass::isMemberVar found used member variable \'" + tok->str() + "\' with varid 0");
|
||||||
|
|
||||||
return !var->isStatic();
|
return !var->isStatic();
|
||||||
}
|
}
|
||||||
|
@ -2157,7 +2157,7 @@ void CheckClass::initializerListOrder()
|
||||||
if (!mSettings->inconclusive)
|
if (!mSettings->inconclusive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
|
|
||||||
// iterate through all member functions looking for constructors
|
// iterate through all member functions looking for constructors
|
||||||
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
for (std::list<Function>::const_iterator func = scope->functionList.begin(); func != scope->functionList.end(); ++func) {
|
||||||
|
@ -2219,7 +2219,7 @@ void CheckClass::initializerListError(const Token *tok1, const Token *tok2, cons
|
||||||
|
|
||||||
void CheckClass::checkSelfInitialization()
|
void CheckClass::checkSelfInitialization()
|
||||||
{
|
{
|
||||||
for (const Scope *scope : symbolDatabase->functionScopes) {
|
for (const Scope *scope : mSymbolDatabase->functionScopes) {
|
||||||
const Function* function = scope->function;
|
const Function* function = scope->function;
|
||||||
if (!function || !function->isConstructor())
|
if (!function || !function->isConstructor())
|
||||||
continue;
|
continue;
|
||||||
|
@ -2251,7 +2251,7 @@ void CheckClass::checkVirtualFunctionCallInConstructor()
|
||||||
if (! mSettings->isEnabled(Settings::WARNING))
|
if (! mSettings->isEnabled(Settings::WARNING))
|
||||||
return;
|
return;
|
||||||
std::map<const Function *, std::list<const Token *> > virtualFunctionCallsMap;
|
std::map<const Function *, std::list<const Token *> > virtualFunctionCallsMap;
|
||||||
for (const Scope *scope : symbolDatabase->functionScopes) {
|
for (const Scope *scope : mSymbolDatabase->functionScopes) {
|
||||||
if (scope->function == nullptr || !scope->function->hasBody() ||
|
if (scope->function == nullptr || !scope->function->hasBody() ||
|
||||||
!(scope->function->isConstructor() ||
|
!(scope->function->isConstructor() ||
|
||||||
scope->function->isDestructor()))
|
scope->function->isDestructor()))
|
||||||
|
@ -2414,8 +2414,8 @@ void CheckClass::checkDuplInheritedMembers()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Iterate over all classes
|
// Iterate over all classes
|
||||||
for (std::list<Type>::const_iterator classIt = symbolDatabase->typeList.begin();
|
for (std::list<Type>::const_iterator classIt = mSymbolDatabase->typeList.begin();
|
||||||
classIt != symbolDatabase->typeList.end();
|
classIt != mSymbolDatabase->typeList.end();
|
||||||
++classIt) {
|
++classIt) {
|
||||||
// Iterate over the parent classes
|
// Iterate over the parent classes
|
||||||
for (std::vector<Type::BaseInfo>::const_iterator parentClassIt = classIt->derivedFrom.begin();
|
for (std::vector<Type::BaseInfo>::const_iterator parentClassIt = classIt->derivedFrom.begin();
|
||||||
|
@ -2473,7 +2473,7 @@ void CheckClass::checkCopyCtorAndEqOperator()
|
||||||
if (!mSettings->isEnabled(Settings::WARNING))
|
if (!mSettings->isEnabled(Settings::WARNING))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * scope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * scope : mSymbolDatabase->classAndStructScopes) {
|
||||||
|
|
||||||
bool hasNonStaticVars = false;
|
bool hasNonStaticVars = false;
|
||||||
for (std::list<Variable>::const_iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
for (std::list<Variable>::const_iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
||||||
|
@ -2538,7 +2538,7 @@ void CheckClass::checkUnsafeClassDivZero(bool test)
|
||||||
if (!mSettings->isEnabled(Settings::STYLE))
|
if (!mSettings->isEnabled(Settings::STYLE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const Scope * classScope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * classScope : mSymbolDatabase->classAndStructScopes) {
|
||||||
if (!test && classScope->classDef->fileIndex() != 1)
|
if (!test && classScope->classDef->fileIndex() != 1)
|
||||||
continue;
|
continue;
|
||||||
for (const Function &func : classScope->functionList) {
|
for (const Function &func : classScope->functionList) {
|
||||||
|
@ -2580,7 +2580,7 @@ void CheckClass::checkOverride()
|
||||||
return;
|
return;
|
||||||
if (mSettings->standards.cpp < Standards::CPP11)
|
if (mSettings->standards.cpp < Standards::CPP11)
|
||||||
return;
|
return;
|
||||||
for (const Scope * classScope : symbolDatabase->classAndStructScopes) {
|
for (const Scope * classScope : mSymbolDatabase->classAndStructScopes) {
|
||||||
if (!classScope->definedType || classScope->definedType->derivedFrom.empty())
|
if (!classScope->definedType || classScope->definedType->derivedFrom.empty())
|
||||||
continue;
|
continue;
|
||||||
for (const Function &func : classScope->functionList) {
|
for (const Function &func : classScope->functionList) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Token;
|
||||||
class CPPCHECKLIB CheckClass : public Check {
|
class CPPCHECKLIB CheckClass : public Check {
|
||||||
public:
|
public:
|
||||||
/** @brief This constructor is used when registering the CheckClass */
|
/** @brief This constructor is used when registering the CheckClass */
|
||||||
CheckClass() : Check(myName()), symbolDatabase(nullptr) {
|
CheckClass() : Check(myName()), mSymbolDatabase(nullptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief This constructor is used when running checks. */
|
/** @brief This constructor is used when running checks. */
|
||||||
|
@ -161,7 +161,7 @@ public:
|
||||||
void checkOverride();
|
void checkOverride();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const SymbolDatabase *symbolDatabase;
|
const SymbolDatabase *mSymbolDatabase;
|
||||||
|
|
||||||
// Reporting errors..
|
// Reporting errors..
|
||||||
void noConstructorError(const Token *tok, const std::string &classname, bool isStruct);
|
void noConstructorError(const Token *tok, const std::string &classname, bool isStruct);
|
||||||
|
|
Loading…
Reference in New Issue