cmMakefile: Create a unified raii for macro scopes.
This commit is contained in:
parent
d5dc4169ac
commit
ca140c2e89
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue