[clang] [clang][unittests] Fix a leak in SearchPathTest (PR #139335)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 9 16:13:54 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Ian Anderson (ian-twilightcoder)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/139335.diff
1 Files Affected:
- (modified) clang/unittests/Frontend/SearchPathTest.cpp (+3-3)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/139335
More information about the cfe-commits
mailing list