Skip to content

Commit

Permalink
[CodeGen] Fix ponential memory leak in CodeGenPassBuilderTest (llvm#7…
Browse files Browse the repository at this point in the history
  • Loading branch information
paperchalice authored and justinfargnoli committed Jan 28, 2024
1 parent 7589617 commit 5efcfd4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/unittests/CodeGen/CodeGenPassBuilderTest.cpp
Expand Up @@ -46,7 +46,7 @@ class DummyCodeGenPassBuilder

class CodeGenPassBuilderTest : public testing::Test {
public:
LLVMTargetMachine *TM;
std::unique_ptr<LLVMTargetMachine> TM;

static void SetUpTestCase() {
InitializeAllTargets();
Expand All @@ -69,8 +69,8 @@ class CodeGenPassBuilderTest : public testing::Test {
GTEST_SKIP();

TargetOptions Options;
TM = static_cast<LLVMTargetMachine *>(
TheTarget->createTargetMachine("", "", "", Options, std::nullopt));
TM = std::unique_ptr<LLVMTargetMachine>(static_cast<LLVMTargetMachine *>(
TheTarget->createTargetMachine("", "", "", Options, std::nullopt)));
if (!TM)
GTEST_SKIP();
}
Expand All @@ -85,7 +85,7 @@ TEST_F(CodeGenPassBuilderTest, basic) {
PassInstrumentationCallbacks PIC;
DummyCodeGenPassBuilder CGPB(*TM, getCGPassBuilderOption(), &PIC);
PipelineTuningOptions PTO;
PassBuilder PB(TM, PTO, std::nullopt, &PIC);
PassBuilder PB(TM.get(), PTO, std::nullopt, &PIC);

PB.registerModuleAnalyses(MAM);
PB.registerCGSCCAnalyses(CGAM);
Expand Down

0 comments on commit 5efcfd4

Please sign in to comment.