Sfoglia il codice sorgente

cmCommandArgumentParserHelper: use cmMakefile::MaybeWarnUninitialized

It removes logic duplication and need to have cached
WarnUninitialized and CheckSystemVars
Artur Ryt 6 anni fa
parent
commit
1d32a35c10

+ 1 - 20
Source/cmCommandArgumentParserHelper.cxx

@@ -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)

+ 0 - 2
Source/cmCommandArgumentParserHelper.h

@@ -75,8 +75,6 @@ private:
   long FileLine;
   int CurrentLine;
   int Verbose;
-  bool WarnUninitialized;
-  bool CheckSystemVars;
   bool EscapeQuotes;
   bool NoEscapeMode;
   bool ReplaceAtSyntax;