diff options
| author | David Blaikie <dblaikie@gmail.com> | 2014-09-15 18:39:24 +0000 |
|---|---|---|
| committer | David Blaikie <dblaikie@gmail.com> | 2014-09-15 18:39:24 +0000 |
| commit | d759fe57643ed07e3b4cec9683be9cfca2641db9 (patch) | |
| tree | 986eb2f7f3a9ae5bff32777a41ff02ad591dafe6 /llvm/include | |
| parent | 0fe35dd08827feb8c7d708ce4ca8407142e06fcb (diff) | |
| download | bcm5719-llvm-d759fe57643ed07e3b4cec9683be9cfca2641db9.tar.gz bcm5719-llvm-d759fe57643ed07e3b4cec9683be9cfca2641db9.zip | |
Fix memory leak in error paths in YAMLTraits by using unique_ptr
There's some other cleanup that could happen here, but this is at least
the mechanical transformation to unique_ptr.
Derived from a patch by Anton Yartsev.
llvm-svn: 217803
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/Support/YAMLTraits.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h index a23faf65bb5..023dcee7d54 100644 --- a/llvm/include/llvm/Support/YAMLTraits.h +++ b/llvm/include/llvm/Support/YAMLTraits.h @@ -943,16 +943,17 @@ private: }; class MapHNode : public HNode { + virtual void anchor(); + public: MapHNode(Node *n) : HNode(n) { } - virtual ~MapHNode(); static inline bool classof(const HNode *n) { return MappingNode::classof(n->_node); } static inline bool classof(const MapHNode *) { return true; } - typedef llvm::StringMap<HNode*> NameToNode; + typedef llvm::StringMap<std::unique_ptr<HNode>> NameToNode; bool isValidKey(StringRef key); @@ -961,19 +962,20 @@ private: }; class SequenceHNode : public HNode { + virtual void anchor(); + public: SequenceHNode(Node *n) : HNode(n) { } - virtual ~SequenceHNode(); static inline bool classof(const HNode *n) { return SequenceNode::classof(n->_node); } static inline bool classof(const SequenceHNode *) { return true; } - std::vector<HNode*> Entries; + std::vector<std::unique_ptr<HNode>> Entries; }; - Input::HNode *createHNodes(Node *node); + std::unique_ptr<Input::HNode> createHNodes(Node *node); void setError(HNode *hnode, const Twine &message); void setError(Node *node, const Twine &message); |

