diff options
author | Tim King <taking@google.com> | 2017-03-16 14:06:17 -0700 |
---|---|---|
committer | Tim King <taking@google.com> | 2017-03-16 14:06:17 -0700 |
commit | afe84522b87b6fc0ad5d0e9a396b61f7b523f674 (patch) | |
tree | aaeef8f32b64b37438b227af5cf6706910862c27 /src/expr | |
parent | e4fde716f0b8266412cb6dc6326642c718839b71 (diff) |
Fixes bug 781. Copy constructor for Expr needed to set the NodeManagerScope.
Diffstat (limited to 'src/expr')
-rw-r--r-- | src/expr/expr_template.cpp | 8 | ||||
-rw-r--r-- | src/expr/type.cpp | 25 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/expr/expr_template.cpp b/src/expr/expr_template.cpp index dad437bc6..4fbb0cd33 100644 --- a/src/expr/expr_template.cpp +++ b/src/expr/expr_template.cpp @@ -82,16 +82,22 @@ Expr TypeCheckingException::getExpression() const throw() { Expr::Expr() : d_node(new Node), d_exprManager(NULL) { + // We do not need to wrap this in an ExprManagerScope as `new Node` is backed + // by NodeValue::null which is a static outside of a NodeManager. } Expr::Expr(ExprManager* em, Node* node) : d_node(node), d_exprManager(em) { + // We do not need to wrap this in an ExprManagerScope as this only initializes + // pointers } Expr::Expr(const Expr& e) : - d_node(new Node(*e.d_node)), + d_node(NULL), d_exprManager(e.d_exprManager) { + ExprManagerScope ems(*this); + d_node = new Node(*e.d_node); } Expr::~Expr() { diff --git a/src/expr/type.cpp b/src/expr/type.cpp index 5f62317ee..6ce7b0a18 100644 --- a/src/expr/type.cpp +++ b/src/expr/type.cpp @@ -37,24 +37,25 @@ Type Type::makeType(const TypeNode& typeNode) const { return Type(d_nodeManager, new TypeNode(typeNode)); } -Type::Type(NodeManager* nm, TypeNode* node) : - d_typeNode(node), - d_nodeManager(nm) { +Type::Type(NodeManager* nm, TypeNode* node) + : d_typeNode(node), d_nodeManager(nm) { + // This does not require a NodeManagerScope as this is restricted to be an + // internal only pointer initialization call. } -Type::~Type() { - NodeManagerScope nms(d_nodeManager); - delete d_typeNode; +Type::Type() : d_typeNode(new TypeNode), d_nodeManager(NULL) { + // This does not require a NodeManagerScope as `new TypeNode` is backed by a + // static expr::NodeValue::null(). } -Type::Type() : - d_typeNode(new TypeNode), - d_nodeManager(NULL) { +Type::Type(const Type& t) : d_typeNode(NULL), d_nodeManager(t.d_nodeManager) { + NodeManagerScope nms(d_nodeManager); + d_typeNode = new TypeNode(*t.d_typeNode); } -Type::Type(const Type& t) : - d_typeNode(new TypeNode(*t.d_typeNode)), - d_nodeManager(t.d_nodeManager) { +Type::~Type() { + NodeManagerScope nms(d_nodeManager); + delete d_typeNode; } bool Type::isNull() const { |