[clang] Fix memory leak in HeaderSearchTest (PR #95927)
Danial Klimkin via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 18 06:53:48 PDT 2024
https://github.com/dklimkin created https://github.com/llvm/llvm-project/pull/95927
AddressSanitizer: 56 byte(s) leaked in 1 allocation(s). (clang/unittests:lex_tests)
>From f61a19058d3b7256702320fd4e94fb523615ccc9 Mon Sep 17 00:00:00 2001
From: Danial Klimkin <dklimkin at google.com>
Date: Tue, 18 Jun 2024 15:52:50 +0200
Subject: [PATCH] Fix memory leak in HeaderSearchTest
---
clang/unittests/Lex/HeaderSearchTest.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp
index 38ce3812c204f..b0375d5985f2e 100644
--- a/clang/unittests/Lex/HeaderSearchTest.cpp
+++ b/clang/unittests/Lex/HeaderSearchTest.cpp
@@ -19,6 +19,8 @@
#include "clang/Serialization/InMemoryModuleCache.h"
#include "llvm/Support/MemoryBuffer.h"
#include "gtest/gtest.h"
+#include <memory>
+#include <string>
namespace clang {
namespace {
@@ -350,8 +352,8 @@ TEST_F(HeaderSearchTest, HeaderFileInfoMerge) {
std::string TextualPath = "/textual.h";
};
- auto ExternalSource = new MockExternalHeaderFileInfoSource();
- Search.SetExternalSource(ExternalSource);
+ auto ExternalSource = std::make_unique<MockExternalHeaderFileInfoSource>();
+ Search.SetExternalSource(ExternalSource.get());
// Everything should start out external.
auto ModularFE = AddHeader(ExternalSource->ModularPath);
More information about the cfe-commits
mailing list