cmCommandArgumentParserHelper: use cmMakefile::MaybeWarnUninitialized

It removes logic duplication and need to have cached
WarnUninitialized and CheckSystemVars
This commit is contained in:
Artur Ryt
2018-12-13 20:45:15 +01:00
committed by Craig Scott
parent 67ac4ed1dc
commit 1d32a35c10
2 changed files with 1 additions and 22 deletions

View File

@@ -6,7 +6,6 @@
#include "cmMakefile.h"
#include "cmState.h"
#include "cmSystemTools.h"
#include "cmake.h"
#include <iostream>
#include <sstream>
@@ -16,8 +15,6 @@ int cmCommandArgument_yyparse(yyscan_t yyscanner);
//
cmCommandArgumentParserHelper::cmCommandArgumentParserHelper()
{
this->WarnUninitialized = false;
this->CheckSystemVars = false;
this->FileLine = -1;
this->FileName = nullptr;
this->RemoveEmpty = true;
@@ -96,21 +93,7 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
}
const char* value = this->Makefile->GetDefinition(var);
if (!value && !this->RemoveEmpty) {
// 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->WarnUninitialized && !this->Makefile->VariableInitialized(var)) {
if (this->CheckSystemVars ||
(this->FileName &&
(cmSystemTools::IsSubDirectory(
this->FileName, this->Makefile->GetHomeDirectory()) ||
cmSystemTools::IsSubDirectory(
this->FileName, this->Makefile->GetHomeOutputDirectory())))) {
std::ostringstream msg;
msg << "uninitialized variable \'" << var << "\'";
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
}
}
this->Makefile->MaybeWarnUninitialized(var, this->FileName);
return nullptr;
}
if (this->EscapeQuotes && value) {
@@ -286,8 +269,6 @@ void cmCommandArgumentParserHelper::Error(const char* str)
void cmCommandArgumentParserHelper::SetMakefile(const cmMakefile* mf)
{
this->Makefile = mf;
this->WarnUninitialized = mf->GetCMakeInstance()->GetWarnUninitialized();
this->CheckSystemVars = mf->GetCMakeInstance()->GetCheckSystemVars();
}
void cmCommandArgumentParserHelper::SetResult(const char* value)