cmMakefile: Create a unified raii for function scopes.
This commit is contained in:
parent
91cd014d64
commit
d5dc4169ac
|
@ -73,7 +73,6 @@ public:
|
|||
cmPolicies::PolicyMap Policies;
|
||||
};
|
||||
|
||||
|
||||
bool cmFunctionHelperCommand::InvokeInitialPass
|
||||
(const std::vector<cmListFileArgument>& args,
|
||||
cmExecutionStatus & inStatus)
|
||||
|
@ -93,14 +92,8 @@ bool cmFunctionHelperCommand::InvokeInitialPass
|
|||
return false;
|
||||
}
|
||||
|
||||
// we push a scope on the makefile
|
||||
cmMakefile::ScopePushPop varScope(this->Makefile);
|
||||
cmMakefile::LexicalPushPop lexScope(this->Makefile);
|
||||
static_cast<void>(varScope);
|
||||
|
||||
// Push a weak policy scope which restores the policies recorded at
|
||||
// function creation.
|
||||
cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
|
||||
cmMakefile::FunctionPushPop functionScope(this->Makefile,
|
||||
this->Policies);
|
||||
|
||||
// set the value of argc
|
||||
std::ostringstream strStream;
|
||||
|
@ -145,8 +138,7 @@ bool cmFunctionHelperCommand::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();
|
||||
functionScope.Quiet();
|
||||
inStatus.SetNestedError(true);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1562,6 +1562,26 @@ void cmMakefile::InitializeFromParent()
|
|||
this->ImportedTargets = parent->ImportedTargets;
|
||||
}
|
||||
|
||||
void cmMakefile::PushFunctionScope(const cmPolicies::PolicyMap& pm)
|
||||
{
|
||||
this->PushScope();
|
||||
|
||||
this->PushFunctionBlockerBarrier();
|
||||
|
||||
this->PushPolicy(true, pm);
|
||||
this->PushPolicyBarrier();
|
||||
}
|
||||
|
||||
void cmMakefile::PopFunctionScope(bool reportError)
|
||||
{
|
||||
this->PopPolicyBarrier(reportError);
|
||||
this->PopPolicy();
|
||||
|
||||
this->PopFunctionBlockerBarrier(reportError);
|
||||
|
||||
this->PopScope();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class cmMakefileCurrent
|
||||
{
|
||||
|
@ -5418,3 +5438,16 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf,
|
||||
cmPolicies::PolicyMap const& pm)
|
||||
: Makefile(mf), ReportError(true)
|
||||
{
|
||||
this->Makefile->PushFunctionScope(pm);
|
||||
}
|
||||
|
||||
cmMakefile::FunctionPushPop::~FunctionPushPop()
|
||||
{
|
||||
this->Makefile->PopFunctionScope(this->ReportError);
|
||||
}
|
||||
|
|
|
@ -746,7 +746,21 @@ public:
|
|||
const std::vector<cmTestGenerator*>& GetTestGenerators() const
|
||||
{ return this->TestGenerators; }
|
||||
|
||||
// push and pop variable scopes
|
||||
class FunctionPushPop
|
||||
{
|
||||
public:
|
||||
FunctionPushPop(cmMakefile* mf,
|
||||
cmPolicies::PolicyMap const& pm);
|
||||
~FunctionPushPop();
|
||||
|
||||
void Quiet() { this->ReportError = false; }
|
||||
private:
|
||||
cmMakefile* Makefile;
|
||||
bool ReportError;
|
||||
};
|
||||
|
||||
void PushFunctionScope(cmPolicies::PolicyMap const& pm);
|
||||
void PopFunctionScope(bool reportError);
|
||||
void PushScope();
|
||||
void PopScope();
|
||||
void RaiseScope(const std::string& var, const char *value);
|
||||
|
|
Loading…
Reference in New Issue