[lld] r263680 - Always pass an allocator to YAMLTraits.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 16 18:17:49 PDT 2016


Thanks!

On 16 March 2016 at 17:33, Pete Cooper via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> 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;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list