[clang] ce9a898 - [clang][unittests] Fix a leak in SearchPathTest (#139335)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 9 16:40:36 PDT 2025
Author: Ian Anderson
Date: 2025-05-09T16:40:33-07:00
New Revision: ce9a898f3daee4622e28526e7912ca468c284767
URL: https://github.com/llvm/llvm-project/commit/ce9a898f3daee4622e28526e7912ca468c284767
DIFF: https://github.com/llvm/llvm-project/commit/ce9a898f3daee4622e28526e7912ca468c284767.diff
LOG: [clang][unittests] Fix a leak in SearchPathTest (#139335)
Added:
Modified:
clang/unittests/Frontend/SearchPathTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Frontend/SearchPathTest.cpp b/clang/unittests/Frontend/SearchPathTest.cpp
index 5d382a4ee20a8..2ebe74d47eb02 100644
--- a/clang/unittests/Frontend/SearchPathTest.cpp
+++ b/clang/unittests/Frontend/SearchPathTest.cpp
@@ -51,6 +51,7 @@ class SearchPathTest : public ::testing::Test {
FileManager FileMgr;
SourceManager SourceMgr;
std::unique_ptr<CompilerInvocation> Invocation;
+ IntrusiveRefCntPtr<TargetInfo> Target;
void addDirectories(ArrayRef<StringRef> Dirs) {
for (StringRef Dir : Dirs) {
@@ -65,10 +66,9 @@ class SearchPathTest : public ::testing::Test {
CompilerInvocation::CreateFromArgs(*Invocation, Args, Diags);
HeaderSearchOptions HSOpts = Invocation->getHeaderSearchOpts();
LangOptions LangOpts = Invocation->getLangOpts();
- TargetInfo *Target =
- TargetInfo::CreateTargetInfo(Diags, Invocation->getTargetOpts());
+ Target = TargetInfo::CreateTargetInfo(Diags, Invocation->getTargetOpts());
auto HeaderInfo = std::make_unique<HeaderSearch>(HSOpts, SourceMgr, Diags,
- LangOpts, Target);
+ LangOpts, Target.get());
ApplyHeaderSearchOptions(*HeaderInfo, HSOpts, LangOpts,
Target->getTriple());
return HeaderInfo;
More information about the cfe-commits
mailing list