[clang] f1eae81 - [NFC]Fix memory leak in HeaderSearchTest (#95927)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 18 06:55:21 PDT 2024


Author: Danial Klimkin
Date: 2024-06-18T15:55:17+02:00
New Revision: f1eae81c0738a2b05d8ba4039a04af6959a13d3b

URL: https://github.com/llvm/llvm-project/commit/f1eae81c0738a2b05d8ba4039a04af6959a13d3b
DIFF: https://github.com/llvm/llvm-project/commit/f1eae81c0738a2b05d8ba4039a04af6959a13d3b.diff

LOG: [NFC]Fix memory leak in HeaderSearchTest (#95927)

AddressSanitizer: 56 byte(s) leaked in 1 allocation(s).
(clang/unittests:lex_tests)

Added: 
    

Modified: 
    clang/unittests/Lex/HeaderSearchTest.cpp

Removed: 
    


################################################################################
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