From 590872b0c2ef0efa4460d859160bbb05f67c020e Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Thu, 17 Mar 2016 00:33:58 +0000 Subject: [PATCH] Always pass an allocator to YAMLTraits. The YAML traits new's when not passed an allocator to parse data. For atom types, this is a leak as we don't destruct atoms. For the File here, we do actually destruct File's so that single case of not using an allocator will be fine. Should fix a bunch more leaks. llvm-svn: 263680 --- lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp index dae8fd3159ad..091da9ca82be 100644 --- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -669,8 +669,9 @@ template <> struct MappingTraits { } static void mappingAtoms(IO &io, const lld::File *&file) { - MappingNormalizationHeap keys(io, file); YamlContext *info = reinterpret_cast(io.getContext()); + MappingNormalizationHeap + keys(io, file, nullptr); assert(info != nullptr); info->_file = keys.operator->(); @@ -682,7 +683,9 @@ template <> struct MappingTraits { } static void mappingArchive(IO &io, const lld::File *&file) { - MappingNormalizationHeap keys(io, file); + YamlContext *info = reinterpret_cast(io.getContext()); + MappingNormalizationHeap + keys(io, file, &info->_file->allocator()); io.mapOptional("path", keys->_path); io.mapOptional("members", keys->_members); @@ -1046,8 +1049,9 @@ template <> struct MappingTraits { static void mapping(IO &io, const lld::SharedLibraryAtom *&atom) { + YamlContext *info = reinterpret_cast(io.getContext()); MappingNormalizationHeap - keys(io, atom); + keys(io, atom, &info->_file->allocator()); io.mapRequired("name", keys->_name); io.mapOptional("load-name", keys->_loadName); @@ -1102,8 +1106,9 @@ template <> struct MappingTraits { }; static void mapping(IO &io, const lld::AbsoluteAtom *&atom) { + YamlContext *info = reinterpret_cast(io.getContext()); MappingNormalizationHeap keys( - io, atom); + io, atom, &info->_file->allocator()); if (io.outputting()) { typedef MappingTraits::NormalizedFile NormalizedFile;