The result of getBufferForFile() must be freed.
(Should we change functions that expect the caller to assume ownership so
that they return unique_ptrs instead? Then the type system makes sure we get
this right.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207074
91177308-0d34-0410-b5e6-
96231b3b80d8
// descriptor, which might not see the changes made.
// FIXME: Figure out whether there is a way to get the SourceManger to
// reopen the file.
- return Context.Files.getBufferForFile(Path, NULL)->getBuffer();
+ std::unique_ptr<const llvm::MemoryBuffer> FileBuffer(
+ Context.Files.getBufferForFile(Path, NULL));
+ return FileBuffer->getBuffer();
}
llvm::StringMap<std::string> TemporaryFiles;
// descriptor, which might not see the changes made.
// FIXME: Figure out whether there is a way to get the SourceManger to
// reopen the file.
- return Files.getBufferForFile(Path, NULL)->getBuffer();
+ std::unique_ptr<const llvm::MemoryBuffer> FileBuffer(
+ Files.getBufferForFile(Path, NULL));
+ return FileBuffer->getBuffer();
}
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;