Index: llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp =================================================================== --- llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp +++ llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp @@ -26,6 +26,10 @@ //===----------------------------------------------------------------------===// // Basic Reader functionality. class ReaderTestCompare : public LVReader { + // Elements created but not added to any logical scope. They are + // deleted when the logical Reader is destroyed. + LVAutoSmallVector OrphanElements; + public: // Types. LVType *IntegerType = nullptr; @@ -109,7 +113,7 @@ Error Err = createScopes(); ASSERT_THAT_ERROR(std::move(Err), Succeeded()); Root = getScopesRoot(); - EXPECT_NE(Root, nullptr); + ASSERT_NE(Root, nullptr); // Create the logical types. IntegerType = create(&LVType::setIsBase); @@ -199,6 +203,8 @@ auto Insert = [&](bool Insert, auto *Parent, auto *Child) { if (Insert) add(Parent, Child); + else + OrphanElements.push_back(Child); }; setCompileUnit(CompileUnit);