From 07aa87612b01a9672e7703a99819c23416780a30 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 24 Apr 2014 04:26:18 +0000 Subject: [PATCH] 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.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207074 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Tooling/RefactoringTest.cpp | 4 +++- unittests/Tooling/RewriterTestContext.h | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/unittests/Tooling/RefactoringTest.cpp b/unittests/Tooling/RefactoringTest.cpp index 8c7bfa1c76..b1ed3c72be 100644 --- a/unittests/Tooling/RefactoringTest.cpp +++ b/unittests/Tooling/RefactoringTest.cpp @@ -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 FileBuffer( + Context.Files.getBufferForFile(Path, NULL)); + return FileBuffer->getBuffer(); } llvm::StringMap TemporaryFiles; diff --git a/unittests/Tooling/RewriterTestContext.h b/unittests/Tooling/RewriterTestContext.h index 841cd0f909..a1bb2311c5 100644 --- a/unittests/Tooling/RewriterTestContext.h +++ b/unittests/Tooling/RewriterTestContext.h @@ -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 FileBuffer( + Files.getBufferForFile(Path, NULL)); + return FileBuffer->getBuffer(); } IntrusiveRefCntPtr DiagOpts; -- 2.40.0