Rework CheckVariableForUnused usage

This commit is contained in:
Ben Boeckel 2010-09-16 11:50:57 -04:00
parent f117423336
commit 59463ef1a3
2 changed files with 7 additions and 5 deletions

View File

@ -1771,7 +1771,7 @@ bool cmMakefile::VariableCleared(const char* var) const
return false;
}
bool cmMakefile::CheckForUnused(const char* reason, const char* name)
void cmMakefile::CheckForUnused(const char* reason, const char* name) const
{
if (this->WarnUnused && !this->VariableUsed(name))
{
@ -1786,10 +1786,8 @@ bool cmMakefile::CheckForUnused(const char* reason, const char* name)
msg << file->FilePath << ":" << file->Line << ":" <<
" warning: (" << reason << ") unused variable \'" << name << "\'";
cmSystemTools::Message(msg.str().c_str());
return true;
}
}
return false;
}
void cmMakefile::RemoveDefinition(const char* name)
@ -3429,7 +3427,11 @@ void cmMakefile::PopScope()
for (; it != locals.end(); ++it)
{
init.erase(*it);
if (!this->CheckForUnused("out of scope", it->c_str()))
if (!this->VariableUsed(it->c_str()))
{
this->CheckForUnused("out of scope", it->c_str());
}
else
{
usage.erase(*it);
}

View File

@ -844,7 +844,7 @@ protected:
void AddGlobalLinkInformation(const char* name, cmTarget& target);
// Check for a an unused variable
bool CheckForUnused(const char* reason, const char* name);
void CheckForUnused(const char* reason, const char* name) const;
std::string Prefix;
std::vector<std::string> AuxSourceDirectories; //