Fix two test-only leaks found by LSan.

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.)

llvm-svn: 207074
This commit is contained in:
Nico Weber 2014-04-24 04:26:18 +00:00
parent 82098cb6df
commit 4fcf0c7b29
2 changed files with 6 additions and 2 deletions

View File

@ -252,7 +252,9 @@ public:
// 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;

View File

@ -102,7 +102,9 @@ class RewriterTestContext {
// 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;