[llvm] cddea67 - [llvm-debuginfo-analyzer] (07/09) - Compare elements

Carlos Alberto Enciso via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 11:25:09 PDT 2022


Author: Carlos Alberto Enciso
Date: 2022-10-24T19:23:44+01:00
New Revision: cddea67663655591b3d650d81d6546abbdc50ae5

URL: https://github.com/llvm/llvm-project/commit/cddea67663655591b3d650d81d6546abbdc50ae5
DIFF: https://github.com/llvm/llvm-project/commit/cddea67663655591b3d650d81d6546abbdc50ae5.diff

LOG: [llvm-debuginfo-analyzer] (07/09) - Compare elements

The test case 'CompareElements' caused a failure in:

  https://lab.llvm.org/buildbot#builders/5/builds/28502
  https://lab.llvm.org/buildbot#builders/168/builds/9671
  SUMMARY: AddressSanitizer: 2144 byte(s) leaked in 14 allocation(s).

The 'Insert' function conditionally adds the 'Child' logical
element to a logical scope. The not added logical elements,
caused the memory leak. Just record them to be destroyed
when the logical reader is destroyed.

Changed 'EXPECT_NE' with 'ASSERT_NE'.
Missing in the main review.

Added: 
    

Modified: 
    llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp b/llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp
index fa274ef03aa8c..06da5ebbc995d 100644
--- a/llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp
+++ b/llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp
@@ -26,6 +26,10 @@ namespace {
 //===----------------------------------------------------------------------===//
 // 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<LVElement *> OrphanElements;
+
 public:
   // Types.
   LVType *IntegerType = nullptr;
@@ -109,7 +113,7 @@ void ReaderTestCompare::createElements() {
   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, LVTypeSetFunction>(&LVType::setIsBase);
@@ -199,6 +203,8 @@ void ReaderTestCompare::addElements(bool IsReference, bool IsTarget) {
   auto Insert = [&](bool Insert, auto *Parent, auto *Child) {
     if (Insert)
       add(Parent, Child);
+    else
+      OrphanElements.push_back(Child);
   };
 
   setCompileUnit(CompileUnit);


        


More information about the llvm-commits mailing list