[clang] Fix memory leak in HeaderSearchTest (PR #95927)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 18 06:54:22 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Danial Klimkin (dklimkin)
<details>
<summary>Changes</summary>
AddressSanitizer: 56 byte(s) leaked in 1 allocation(s). (clang/unittests:lex_tests)
---
Full diff: https://github.com/llvm/llvm-project/pull/95927.diff
1 Files Affected:
- (modified) clang/unittests/Lex/HeaderSearchTest.cpp (+4-2)
``````````diff
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);
``````````
</details>
https://github.com/llvm/llvm-project/pull/95927
More information about the cfe-commits
mailing list