diff options
author | Artur Ryt <artur.ryt@gmail.com> | 2018-12-13 19:45:11 (GMT) |
---|---|---|
committer | Artur Ryt <artur.ryt@gmail.com> | 2018-12-28 14:16:37 (GMT) |
commit | 67ac4ed1dc5ad049ab443ce76a3f93b207703cec (patch) | |
tree | 0c2f9df7ca7cb25c256eb329243b97fbde751333 /Source | |
parent | 5257af363442aa4168776b70db1fc58d218a20c8 (diff) | |
download | CMake-67ac4ed1dc5ad049ab443ce76a3f93b207703cec.zip CMake-67ac4ed1dc5ad049ab443ce76a3f93b207703cec.tar.gz CMake-67ac4ed1dc5ad049ab443ce76a3f93b207703cec.tar.bz2 |
cmMakefile: Move uninitialized vars logic into MaybeWarnUninitialized()
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmMakefile.cxx | 30 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 |
2 files changed, 20 insertions, 12 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index bbbe300..256202c 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1837,6 +1837,23 @@ bool cmMakefile::VariableInitialized(const std::string& var) const return this->StateSnapshot.IsInitialized(var); } +void cmMakefile::MaybeWarnUninitialized(std::string const& variable, + const char* sourceFilename) const +{ + // check to see if we need to print a warning + // if strict mode is on and the variable has + // not been "cleared"/initialized with a set(foo ) call + if (this->GetCMakeInstance()->GetWarnUninitialized() && + !this->VariableInitialized(variable)) { + if (this->CheckSystemVars || + (sourceFilename && this->IsProjectFile(sourceFilename))) { + std::ostringstream msg; + msg << "uninitialized variable \'" << variable << "\'"; + this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); + } + } +} + void cmMakefile::LogUnused(const char* reason, const std::string& name) const { if (this->WarnUnused) { @@ -2767,18 +2784,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( varresult = value; } } else if (!removeEmpty && !this->SuppressSideEffects) { - // check to see if we need to print a warning - // if strict mode is on and the variable has - // not been "cleared"/initialized with a set(foo ) call - if (this->GetCMakeInstance()->GetWarnUninitialized() && - !this->VariableInitialized(lookup)) { - if (this->CheckSystemVars || - (filename && this->IsProjectFile(filename))) { - std::ostringstream msg; - msg << "uninitialized variable \'" << lookup << "\'"; - this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); - } - } + this->MaybeWarnUninitialized(lookup, filename); } result.replace(var.loc, result.size() - var.loc, varresult); // Start looking from here on out. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index be1e6a1..1a2a0e7 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -866,6 +866,8 @@ public: std::deque<std::vector<std::string>> FindPackageRootPathStack; void MaybeWarnCMP0074(std::string const& pkg); + void MaybeWarnUninitialized(std::string const& variable, + const char* sourceFilename) const; bool IsProjectFile(const char* filename) const; protected: |