From 89cb5d558895706e053bc3af972aa5b15aa82863 Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Thu, 23 Apr 2020 16:09:23 +0200 Subject: [PATCH] [clangd] Delete remapped buffers in tests These buffers normally get freed after being used in a CompilerInstance. but tests don't make use of those, so we need to free them explicitly. --- clang-tools-extra/clangd/unittests/PreambleTests.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang-tools-extra/clangd/unittests/PreambleTests.cpp b/clang-tools-extra/clangd/unittests/PreambleTests.cpp index 6382285..5ff7ebc 100644 --- a/clang-tools-extra/clangd/unittests/PreambleTests.cpp +++ b/clang-tools-extra/clangd/unittests/PreambleTests.cpp @@ -91,6 +91,8 @@ TEST(PreamblePatchTest, IncludeParsing) { PreamblePatch::create(FileName, PI, *EmptyPreamble).apply(*CI); EXPECT_THAT(CI->getPreprocessorOpts().RemappedFileBuffers, Contains(Pair(_, HasContents(ExpectedBuffer)))); + for (const auto &RB : CI->getPreprocessorOpts().RemappedFileBuffers) + delete RB.second; } } @@ -120,6 +122,8 @@ TEST(PreamblePatchTest, ContainsNewIncludes) { PreamblePatch::create(FileName, PI, *FullPreamble).apply(*CI); EXPECT_THAT(CI->getPreprocessorOpts().RemappedFileBuffers, Contains(Pair(_, HasContents(Patch)))); + for (const auto &RB : CI->getPreprocessorOpts().RemappedFileBuffers) + delete RB.second; } } // namespace -- 2.7.4