[llvm] r289208 - Plug another leak in the DWARF unittests, DIEInlineStrings are never destroyed.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 05:33:42 PST 2016


Author: d0k
Date: Fri Dec  9 07:33:41 2016
New Revision: 289208

URL: http://llvm.org/viewvc/llvm-project?rev=289208&view=rev
Log:
Plug another leak in the DWARF unittests, DIEInlineStrings are never destroyed.

Modified:
    llvm/trunk/include/llvm/CodeGen/DIE.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
    llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Modified: llvm/trunk/include/llvm/CodeGen/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DIE.h?rev=289208&r1=289207&r2=289208&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DIE.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DIE.h Fri Dec  9 07:33:41 2016
@@ -256,15 +256,16 @@ public:
 ///
 /// This class is used with the DW_FORM_string form.
 class DIEInlineString {
-  std::string S;
+  StringRef S;
 
 public:
-  explicit DIEInlineString(StringRef Str) : S(Str.str()) {}
+  template <typename Allocator>
+  explicit DIEInlineString(StringRef Str, Allocator &A) : S(Str.copy(A)) {}
 
   ~DIEInlineString() = default;
 
   /// Grab the string out of the object.
-  StringRef getString() const { return StringRef(S); }
+  StringRef getString() const { return S; }
 
   void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
   unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=289208&r1=289207&r2=289208&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Fri Dec  9 07:33:41 2016
@@ -606,7 +606,7 @@ unsigned DIEInlineString::SizeOf(const A
 
 LLVM_DUMP_METHOD
 void DIEInlineString::print(raw_ostream &O) const {
-  O << "InlineString: " << S.c_str();
+  O << "InlineString: " << S;
 }
 
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp?rev=289208&r1=289207&r2=289208&view=diff
==============================================================================
--- llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp (original)
+++ llvm/trunk/unittests/DebugInfo/DWARF/DwarfGenerator.cpp Fri Dec  9 07:33:41 2016
@@ -61,7 +61,8 @@ void dwarfgen::DIE::addAttribute(uint16_
   auto &DG = CU->getGenerator();
   if (Form == DW_FORM_string) {
     Die->addValue(DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,
-                  new (DG.getAllocator()) DIEInlineString(String));
+                  new (DG.getAllocator())
+                      DIEInlineString(String, DG.getAllocator()));
   } else {
     Die->addValue(
         DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,




More information about the llvm-commits mailing list