Check constructors: Minor optimisation
This commit is contained in:
parent
f8087b1f3f
commit
f01cb905f7
|
@ -409,20 +409,21 @@ void CheckClass::CheckConstructors()
|
||||||
// Check if any variables are uninitialized
|
// Check if any variables are uninitialized
|
||||||
for (struct VAR *var = varlist; var; var = var->next)
|
for (struct VAR *var = varlist; var; var = var->next)
|
||||||
{
|
{
|
||||||
|
if ( var->init )
|
||||||
|
continue;
|
||||||
|
|
||||||
// Is it a static member variable?
|
// Is it a static member variable?
|
||||||
std::ostringstream pattern;
|
std::ostringstream pattern;
|
||||||
pattern << className[0] << "::" << var->name << "=";
|
pattern << className[0] << "::" << var->name << "=";
|
||||||
if (TOKEN::findmatch(_tokenizer->tokens(), pattern.str().c_str()))
|
if (TOKEN::findmatch(_tokenizer->tokens(), pattern.str().c_str()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!var->init)
|
// It's non-static and it's not initialized => error
|
||||||
{
|
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
ostr << _tokenizer->fileLine(constructor_token);
|
ostr << _tokenizer->fileLine(constructor_token);
|
||||||
ostr << " Uninitialized member variable '" << className[0] << "::" << var->name << "'";
|
ostr << " Uninitialized member variable '" << className[0] << "::" << var->name << "'";
|
||||||
_errorLogger->reportErr(ostr.str());
|
_errorLogger->reportErr(ostr.str());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for ( struct VAR *var = varlist; var; var = var->next )
|
for ( struct VAR *var = varlist; var; var = var->next )
|
||||||
var->init = false;
|
var->init = false;
|
||||||
|
|
Loading…
Reference in New Issue