[clang] 45067f8 - [test] Don't leak DerivedArgList in test
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 16 14:03:46 PDT 2022
Author: Vitaly Buka
Date: 2022-07-16T14:03:38-07:00
New Revision: 45067f8fbf61284839c739807c2da2e2505661eb
URL: https://github.com/llvm/llvm-project/commit/45067f8fbf61284839c739807c2da2e2505661eb
DIFF: https://github.com/llvm/llvm-project/commit/45067f8fbf61284839c739807c2da2e2505661eb.diff
LOG: [test] Don't leak DerivedArgList in test
Added:
Modified:
clang/unittests/Driver/ToolChainTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp
index 3637b10cdd667..02ab9e743ebe6 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -486,8 +486,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
for (auto *A : Args)
DAL->append(A);
- auto *TranslatedArgs =
- TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+ std::unique_ptr<llvm::opt::DerivedArgList> TranslatedArgs{
+ TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None)};
EXPECT_NE(TranslatedArgs, nullptr);
if (TranslatedArgs) {
auto *A = TranslatedArgs->getLastArg(
@@ -506,7 +506,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
for (auto *A : Args)
DAL->append(A);
- TranslatedArgs = TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+ TranslatedArgs.reset(
+ TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None));
EXPECT_EQ(Diags.getNumErrors(), 1u);
EXPECT_STREQ(DiagConsumer->Errors.back().c_str(),
"invalid validator version : 0.1\nIf validator major version is "
@@ -521,7 +522,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
for (auto *A : Args)
DAL->append(A);
- TranslatedArgs = TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+ TranslatedArgs.reset(
+ TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None));
EXPECT_EQ(Diags.getNumErrors(), 2u);
EXPECT_STREQ(DiagConsumer->Errors.back().c_str(),
"invalid validator version : 1\nFormat of validator version is "
@@ -536,7 +538,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
for (auto *A : Args)
DAL->append(A);
- TranslatedArgs = TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+ TranslatedArgs.reset(
+ TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None));
EXPECT_EQ(Diags.getNumErrors(), 3u);
EXPECT_STREQ(
DiagConsumer->Errors.back().c_str(),
@@ -552,7 +555,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
for (auto *A : Args)
DAL->append(A);
- TranslatedArgs = TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None);
+ TranslatedArgs.reset(
+ TC.TranslateArgs(*DAL, "0", Action::OffloadKind::OFK_None));
EXPECT_EQ(Diags.getNumErrors(), 4u);
EXPECT_STREQ(
DiagConsumer->Errors.back().c_str(),
More information about the cfe-commits
mailing list