Commit 9551cafd authored by Brad King's avatar Brad King

BUG: Pop a function scope even on error

This uses an automatic variable to push and pop variable scope inside a
function call.  Previously if the function failed its scope would not be
popped.  This approach guarantees a balanced push/pop.
parent 046449e2
......@@ -104,7 +104,8 @@ bool cmFunctionHelperCommand::InvokeInitialPass
// we push a scope on the makefile
cmMakefile::ScopePushPop varScope(this->Makefile);
// set the value of argc
cmOStringStream strStream;
......@@ -167,13 +168,11 @@ bool cmFunctionHelperCommand::InvokeInitialPass
if (status.GetReturnInvoked())
return true;
// pop scope on the makefile
return true;
......@@ -780,6 +780,16 @@ public:
void PopScope();
void RaiseScope(const char *var, const char *value);
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
ScopePushPop(cmMakefile* m): Makefile(m) { this->Makefile->PushScope(); }
~ScopePushPop() { this->Makefile->PopScope(); }
cmMakefile* Makefile;
void IssueMessage(cmake::MessageType t,
std::string const& text) const;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment