From cef167f8d467201ec40a7817397c18fc264d0b54 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 29 Mar 2021 23:31:14 -0700 Subject: [PATCH] [DebugInfo][unittest] Fix heap-use-after-free after D76115 --- llvm/unittests/IR/DebugInfoTest.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp index d3e025a..060a5c2 100644 --- a/llvm/unittests/IR/DebugInfoTest.cpp +++ b/llvm/unittests/IR/DebugInfoTest.cpp @@ -230,18 +230,13 @@ TEST(DIBuilder, CreateFortranArrayTypeWithAttributes) { DIVariable::deleteTemporary(DataLocation); } -DISubprogram *getSubprogram() { - LLVMContext Context; - return DISubprogram::getDistinct(Context, nullptr, "", "", nullptr, 0, - nullptr, 0, nullptr, 0, 0, DINode::FlagZero, - DISubprogram::SPFlagZero, nullptr); -} - TEST(DIBuilder, CreateSetType) { LLVMContext Ctx; std::unique_ptr M(new Module("MyModule", Ctx)); DIBuilder DIB(*M); - DIScope *Scope = getSubprogram(); + DIScope *Scope = DISubprogram::getDistinct( + Ctx, nullptr, "", "", nullptr, 0, nullptr, 0, nullptr, 0, 0, + DINode::FlagZero, DISubprogram::SPFlagZero, nullptr); DIType *Type = DIB.createBasicType("Int", 64, dwarf::DW_ATE_signed); DIFile *F = DIB.createFile("main.c", "/"); -- 2.7.4