diff options
author | Cyndy Ishida <cyndy_ishida@apple.com> | 2019-08-16 15:30:48 +0000 |
---|---|---|
committer | Cyndy Ishida <cyndy_ishida@apple.com> | 2019-08-16 15:30:48 +0000 |
commit | 5f865ecf06cb8b0d2193d66379d828f94866de82 (patch) | |
tree | 7e8fb5ff2c817b958d136b946ed73f1c0f22978f /llvm/lib/TextAPI/MachO/TextStub.cpp | |
parent | b782e61e471f858fcf8d67ea0efad1b2783b6632 (diff) | |
download | bcm5719-llvm-5f865ecf06cb8b0d2193d66379d828f94866de82.tar.gz bcm5719-llvm-5f865ecf06cb8b0d2193d66379d828f94866de82.zip |
[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
Diffstat (limited to 'llvm/lib/TextAPI/MachO/TextStub.cpp')
-rw-r--r-- | llvm/lib/TextAPI/MachO/TextStub.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
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<std::unique_ptr<InterfaceFile>> -TextAPIReader::get(std::unique_ptr<MemoryBuffer> 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<const InterfaceFile *> 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<InterfaceFile>( const_cast<InterfaceFile *>(Files.front())); |