summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-04-18 15:07:04 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-04-18 15:07:04 (GMT)
commitef713503c8b9b317fdbd21c75d332febd77c31a3 (patch)
tree489343dde47cd18ae91250dc628c0a32a226a8a3 /Source
parent0256ea55abe019b3a9b487e422b327722ed8935c (diff)
parent2faa8b362050c716cc5626f9bb9d8a8612b97f95 (diff)
downloadCMake-ef713503c8b9b317fdbd21c75d332febd77c31a3.zip
CMake-ef713503c8b9b317fdbd21c75d332febd77c31a3.tar.gz
CMake-ef713503c8b9b317fdbd21c75d332febd77c31a3.tar.bz2
Merge topic 'minor-cleanups'
2faa8b36 Add call stack to unused/uninitialized variable warnings da07c506 cmLocalGenerator: Simplify IssueMessage implementation cc7aed77 cmLocalGenerator: Use own IssueMessage method c50285de cmOutputConverter: Assert construction with a valid snapshot b6ed71b1 cmMakefile: Move cmMakefileCall to .cxx file a559f0f6 cmWhileCommand: Simplify context construction 7503deb2 cmIfCommand: Simplify execution context construction
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx9
-rw-r--r--Source/cmIfCommand.cxx10
-rw-r--r--Source/cmLocalGenerator.cxx16
-rw-r--r--Source/cmMakefile.cxx53
-rw-r--r--Source/cmMakefile.h13
-rw-r--r--Source/cmOutputConverter.cxx1
-rw-r--r--Source/cmWhileCommand.cxx8
7 files changed, 32 insertions, 78 deletions
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 14e9e56..15ab746 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -140,15 +140,8 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
this->Makefile->GetHomeOutputDirectory()))
{
std::ostringstream msg;
- cmListFileContext lfc;
- cmOutputConverter converter(this->Makefile->GetStateSnapshot());
- lfc.FilePath = converter.Convert(this->FileName,
- cmOutputConverter::HOME);
-
- lfc.Line = this->FileLine;
msg << "uninitialized variable \'" << var << "\'";
- this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str(), lfc);
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
}
}
return 0;
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index 9a07dde..fc54ca5 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -203,15 +203,9 @@ bool cmIfCommand
cmake::MessageType status;
- cmListFileContext execContext = this->Makefile->GetExecutionContext();
-
- cmCommandContext commandContext;
- commandContext.Line = execContext.Line;
- commandContext.Name = execContext.Name;
-
cmConditionEvaluator conditionEvaluator(
- *(this->Makefile), cmListFileContext::FromCommandContext(
- commandContext, execContext.FilePath),
+ *(this->Makefile),
+ this->Makefile->GetExecutionContext(),
this->Makefile->GetBacktrace());
bool isTrue = conditionEvaluator.IsTrue(
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 0195b9e..b93fc21 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -69,17 +69,7 @@ cmLocalGenerator::~cmLocalGenerator()
void cmLocalGenerator::IssueMessage(cmake::MessageType t,
std::string const& text) const
{
- cmListFileContext lfc;
- lfc.FilePath = this->StateSnapshot.GetDirectory().GetCurrentSource();
- lfc.FilePath += "/CMakeLists.txt";
-
- if(!this->GlobalGenerator->GetCMakeInstance()->GetIsInTryCompile())
- {
- cmOutputConverter converter(this->StateSnapshot);
- lfc.FilePath = converter.Convert(lfc.FilePath, cmLocalGenerator::HOME);
- }
- lfc.Line = 0;
- this->GlobalGenerator->GetCMakeInstance()->IssueMessage(t, text, lfc);
+ this->Makefile->IssueMessage(t, text);
}
//----------------------------------------------------------------------------
@@ -1608,7 +1598,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
"For compatibility with older versions of CMake, "
"additional flags may be added to export symbols on all "
"executables regardless of thier ENABLE_EXPORTS property.";
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->IssueMessage(cmake::AUTHOR_WARNING, w.str());
}
case cmPolicies::OLD:
// OLD behavior is to always add the flags
@@ -1616,7 +1606,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
- this->Makefile->IssueMessage(
+ this->IssueMessage(
cmake::FATAL_ERROR,
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065)
);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7be6b88..13bcdac 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -222,6 +222,26 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
cmSystemTools::Message(msg.str().c_str());
}
+// Helper class to make sure the call stack is valid.
+class cmMakefileCall
+{
+public:
+ cmMakefileCall(cmMakefile* mf, const cmCommandContext& lfc,
+ cmExecutionStatus& status): Makefile(mf)
+ {
+ this->Makefile->ContextStack.push_back(&lfc);
+ this->Makefile->ExecutionStatusStack.push_back(&status);
+ }
+
+ ~cmMakefileCall()
+ {
+ this->Makefile->ExecutionStatusStack.pop_back();
+ this->Makefile->ContextStack.pop_back();
+ }
+private:
+ cmMakefile* Makefile;
+};
+
//----------------------------------------------------------------------------
bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
cmExecutionStatus &status)
@@ -1941,21 +1961,15 @@ void cmMakefile::LogUnused(const char* reason,
if (this->WarnUnused)
{
std::string path;
- cmListFileContext lfc;
if (!this->ExecutionStatusStack.empty())
{
- lfc = this->GetExecutionContext();
- path = lfc.FilePath;
+ path = this->GetExecutionContext().FilePath;
}
else
{
path = this->GetCurrentSourceDirectory();
path += "/CMakeLists.txt";
- lfc.FilePath = path;
- lfc.Line = 0;
}
- cmOutputConverter converter(this->StateSnapshot);
- lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
if (this->CheckSystemVars ||
cmSystemTools::IsSubDirectory(path,
@@ -1967,9 +1981,7 @@ void cmMakefile::LogUnused(const char* reason,
{
std::ostringstream msg;
msg << "unused variable (" << reason << ") \'" << name << "\'";
- this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str(),
- lfc);
+ this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
}
}
}
@@ -2899,14 +2911,8 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
this->GetHomeOutputDirectory()))
{
std::ostringstream msg;
- cmListFileContext lfc;
- cmOutputConverter converter(this->StateSnapshot);
- lfc.FilePath =
- converter.Convert(filename, cmOutputConverter::HOME);
- lfc.Line = line;
msg << "uninitialized variable \'" << lookup << "\'";
- this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str(), lfc);
+ this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
}
}
}
@@ -5148,16 +5154,3 @@ cmMakefile::MacroPushPop::~MacroPushPop()
{
this->Makefile->PopMacroScope(this->ReportError);
}
-
-cmMakefileCall::cmMakefileCall(cmMakefile* mf, const cmCommandContext& lfc,
- cmExecutionStatus& status): Makefile(mf)
-{
- this->Makefile->ContextStack.push_back(&lfc);
- this->Makefile->ExecutionStatusStack.push_back(&status);
-}
-
-cmMakefileCall::~cmMakefileCall()
-{
- this->Makefile->ExecutionStatusStack.pop_back();
- this->Makefile->ContextStack.pop_back();
-}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 45f2efb..7217944 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -959,17 +959,4 @@ private:
mutable bool SuppressWatches;
};
-//----------------------------------------------------------------------------
-// Helper class to make sure the call stack is valid.
-class cmMakefileCall
-{
-public:
- cmMakefileCall(cmMakefile* mf,
- cmCommandContext const& lfc,
- cmExecutionStatus& status);
- ~cmMakefileCall();
-private:
- cmMakefile* Makefile;
-};
-
#endif
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 5acae2f..59fb2e9 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -22,6 +22,7 @@
cmOutputConverter::cmOutputConverter(cmState::Snapshot snapshot)
: StateSnapshot(snapshot), LinkScriptShell(false)
{
+ assert(this->StateSnapshot.IsValid());
}
//----------------------------------------------------------------------------
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index aabbe27..7bb78bf 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -55,13 +55,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
commandContext.Line = execContext.Line;
commandContext.Name = execContext.Name;
- cmListFileContext conditionContext =
- cmListFileContext::FromCommandContext(
- commandContext,
- this->GetStartingContext().FilePath);
-
cmConditionEvaluator conditionEvaluator(
- mf, conditionContext,
+ mf,
+ this->GetStartingContext(),
mf.GetBacktrace(commandContext));
bool isTrue = conditionEvaluator.IsTrue(