From 5f865ecf06cb8b0d2193d66379d828f94866de82 Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Fri, 16 Aug 2019 15:30:48 +0000 Subject: [TextAPI] Update reader to be supported by lib/Object Summary: To be able to use the TextAPI/Reader for tbd file consumption (by libObject) it gets passed a MemoryBufferRef which isn't castable to MemoryBuffer. Updated the tests to expect that input as well. Reviewers: ributzka, steven_wu Reviewed By: steven_wu Subscribers: hiraditya, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D66147 llvm-svn: 369119 --- llvm/lib/TextAPI/MachO/TextStub.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/lib/TextAPI/MachO/TextStub.cpp') diff --git a/llvm/lib/TextAPI/MachO/TextStub.cpp b/llvm/lib/TextAPI/MachO/TextStub.cpp index d333024e698..371866736c0 100644 --- a/llvm/lib/TextAPI/MachO/TextStub.cpp +++ b/llvm/lib/TextAPI/MachO/TextStub.cpp @@ -623,15 +623,17 @@ static void DiagHandler(const SMDiagnostic &Diag, void *Context) { } Expected> -TextAPIReader::get(std::unique_ptr InputBuffer) { +TextAPIReader::get(MemoryBufferRef InputBuffer) { TextAPIContext Ctx; - Ctx.Path = InputBuffer->getBufferIdentifier(); - yaml::Input YAMLIn(InputBuffer->getBuffer(), &Ctx, DiagHandler, &Ctx); + Ctx.Path = InputBuffer.getBufferIdentifier(); + yaml::Input YAMLIn(InputBuffer.getBuffer(), &Ctx, DiagHandler, &Ctx); // Fill vector with interface file objects created by parsing the YAML file. std::vector Files; YAMLIn >> Files; + // YAMLIn dynamically allocates for Interface file and in case of error, + // memory leak will occur unless wrapped around unique_ptr auto File = std::unique_ptr( const_cast(Files.front())); -- cgit v1.2.3