Factor out the checks for unused variables
This commit is contained in:
parent
5e41ba8e4a
commit
c6e7fabc0f
@ -178,15 +178,9 @@ bool cmMakefile::NeedCacheCompatibility(int major, int minor)
|
|||||||
|
|
||||||
cmMakefile::~cmMakefile()
|
cmMakefile::~cmMakefile()
|
||||||
{
|
{
|
||||||
std::set<cmStdString> usage = this->Internal->VarUsageStack.top();
|
// Check for unused variables
|
||||||
std::set<cmStdString>::const_iterator it = usage.begin();
|
this->CheckForUnusedVariables();
|
||||||
for (; it != usage.end(); ++it)
|
|
||||||
{
|
|
||||||
if (!this->VariableUsed(it->c_str()))
|
|
||||||
{
|
|
||||||
this->CheckForUnused("out of scope", it->c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(std::vector<cmInstallGenerator*>::iterator
|
for(std::vector<cmInstallGenerator*>::iterator
|
||||||
i = this->InstallGenerators.begin();
|
i = this->InstallGenerators.begin();
|
||||||
i != this->InstallGenerators.end(); ++i)
|
i != this->InstallGenerators.end(); ++i)
|
||||||
@ -713,6 +707,9 @@ bool cmMakefile::ReadListFile(const char* filename_in,
|
|||||||
// pop the listfile off the stack
|
// pop the listfile off the stack
|
||||||
this->ListFileStack.pop_back();
|
this->ListFileStack.pop_back();
|
||||||
|
|
||||||
|
// Check for unused variables
|
||||||
|
this->CheckForUnusedVariables();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1751,6 +1748,17 @@ void cmMakefile::AddDefinition(const char* name, bool value)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmMakefile::CheckForUnusedVariables() const
|
||||||
|
{
|
||||||
|
const cmDefinitions& defs = this->Internal->VarStack.top();
|
||||||
|
const std::set<cmStdString>& locals = defs.LocalKeys();
|
||||||
|
std::set<cmStdString>::const_iterator it = locals.begin();
|
||||||
|
for (; it != locals.end(); ++it)
|
||||||
|
{
|
||||||
|
this->CheckForUnused("out of scope", it->c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmMakefile::MarkVariableAsUsed(const char* var)
|
void cmMakefile::MarkVariableAsUsed(const char* var)
|
||||||
{
|
{
|
||||||
this->Internal->VarUsageStack.top().insert(var);
|
this->Internal->VarUsageStack.top().insert(var);
|
||||||
|
@ -61,6 +61,8 @@ public:
|
|||||||
unsigned int GetCacheMajorVersion();
|
unsigned int GetCacheMajorVersion();
|
||||||
unsigned int GetCacheMinorVersion();
|
unsigned int GetCacheMinorVersion();
|
||||||
|
|
||||||
|
/* Check for unused variables in this scope */
|
||||||
|
void CheckForUnusedVariables() const;
|
||||||
/* Mark a variable as used */
|
/* Mark a variable as used */
|
||||||
void MarkVariableAsUsed(const char* var);
|
void MarkVariableAsUsed(const char* var);
|
||||||
/* return true if a variable has been initialized */
|
/* return true if a variable has been initialized */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user