summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-05-31 16:32:01 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-06-04 20:08:23 (GMT)
commitca140c2e898ca74a7daa305449b136b1294a41f0 (patch)
tree7b174ae4abdb9a7e9d95bfdbe6232daa00751014 /Source
parentd5dc4169ac1c4dd5abd385b1e8499119df88c657 (diff)
downloadCMake-ca140c2e898ca74a7daa305449b136b1294a41f0.zip
CMake-ca140c2e898ca74a7daa305449b136b1294a41f0.tar.gz
CMake-ca140c2e898ca74a7daa305449b136b1294a41f0.tar.bz2
cmMakefile: Create a unified raii for macro scopes.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMacroCommand.cxx11
-rw-r--r--Source/cmMakefile.cxx29
-rw-r--r--Source/cmMakefile.h15
3 files changed, 47 insertions, 8 deletions
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 7ac4432..028ab62 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -96,12 +96,8 @@ bool cmMacroHelperCommand::InvokeInitialPass
return false;
}
- // Enforce matching logical blocks inside the macro.
- cmMakefile::LexicalPushPop lexScope(this->Makefile);
-
- // Push a weak policy scope which restores the policies recorded at
- // macro creation.
- cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
+ cmMakefile::MacroPushPop macroScope(this->Makefile,
+ this->Policies);
// set the value of argc
std::ostringstream argcDefStream;
@@ -191,8 +187,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
{
// The error message should have already included the call stack
// so we do not need to report an error here.
- lexScope.Quiet();
- polScope.Quiet();
+ macroScope.Quiet();
inStatus.SetNestedError(true);
return false;
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 7012701..d3a8121 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1582,6 +1582,22 @@ void cmMakefile::PopFunctionScope(bool reportError)
this->PopScope();
}
+void cmMakefile::PushMacroScope(const cmPolicies::PolicyMap& pm)
+{
+ this->PushFunctionBlockerBarrier();
+
+ this->PushPolicy(true, pm);
+ this->PushPolicyBarrier();
+}
+
+void cmMakefile::PopMacroScope(bool reportError)
+{
+ this->PopPolicyBarrier(reportError);
+ this->PopPolicy();
+
+ this->PopFunctionBlockerBarrier(reportError);
+}
+
//----------------------------------------------------------------------------
class cmMakefileCurrent
{
@@ -5451,3 +5467,16 @@ cmMakefile::FunctionPushPop::~FunctionPushPop()
{
this->Makefile->PopFunctionScope(this->ReportError);
}
+
+
+cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf,
+ const cmPolicies::PolicyMap& pm)
+ : Makefile(mf), ReportError(true)
+{
+ this->Makefile->PushMacroScope(pm);
+}
+
+cmMakefile::MacroPushPop::~MacroPushPop()
+{
+ this->Makefile->PopMacroScope(this->ReportError);
+}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index ed9bc70..0914a99 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -759,8 +759,23 @@ public:
bool ReportError;
};
+ class MacroPushPop
+ {
+ public:
+ MacroPushPop(cmMakefile* mf,
+ cmPolicies::PolicyMap const& pm);
+ ~MacroPushPop();
+
+ void Quiet() { this->ReportError = false; }
+ private:
+ cmMakefile* Makefile;
+ bool ReportError;
+ };
+
void PushFunctionScope(cmPolicies::PolicyMap const& pm);
void PopFunctionScope(bool reportError);
+ void PushMacroScope(cmPolicies::PolicyMap const& pm);
+ void PopMacroScope(bool reportError);
void PushScope();
void PopScope();
void RaiseScope(const std::string& var, const char *value);