[lld] r263680 - Always pass an allocator to YAMLTraits.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 16 17:33:58 PDT 2016
Author: pete
Date: Wed Mar 16 19:33:58 2016
New Revision: 263680
URL: http://llvm.org/viewvc/llvm-project?rev=263680&view=rev
Log:
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.
Modified:
lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
Modified: lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp?rev=263680&r1=263679&r2=263680&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp (original)
+++ lld/trunk/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp Wed Mar 16 19:33:58 2016
@@ -669,8 +669,9 @@ template <> struct MappingTraits<const l
}
static void mappingAtoms(IO &io, const lld::File *&file) {
- MappingNormalizationHeap<NormalizedFile, const lld::File *> keys(io, file);
YamlContext *info = reinterpret_cast<YamlContext *>(io.getContext());
+ MappingNormalizationHeap<NormalizedFile, const lld::File *>
+ keys(io, file, nullptr);
assert(info != nullptr);
info->_file = keys.operator->();
@@ -682,7 +683,9 @@ template <> struct MappingTraits<const l
}
static void mappingArchive(IO &io, const lld::File *&file) {
- MappingNormalizationHeap<NormArchiveFile, const lld::File *> keys(io, file);
+ YamlContext *info = reinterpret_cast<YamlContext *>(io.getContext());
+ MappingNormalizationHeap<NormArchiveFile, const lld::File *>
+ keys(io, file, &info->_file->allocator());
io.mapOptional("path", keys->_path);
io.mapOptional("members", keys->_members);
@@ -1046,8 +1049,9 @@ template <> struct MappingTraits<const l
static void mapping(IO &io, const lld::SharedLibraryAtom *&atom) {
+ YamlContext *info = reinterpret_cast<YamlContext *>(io.getContext());
MappingNormalizationHeap<NormalizedAtom, const lld::SharedLibraryAtom *>
- 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<const l
};
static void mapping(IO &io, const lld::AbsoluteAtom *&atom) {
+ YamlContext *info = reinterpret_cast<YamlContext *>(io.getContext());
MappingNormalizationHeap<NormalizedAtom, const lld::AbsoluteAtom *> keys(
- io, atom);
+ io, atom, &info->_file->allocator());
if (io.outputting()) {
typedef MappingTraits<const lld::File *>::NormalizedFile NormalizedFile;
More information about the llvm-commits
mailing list