Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 366c08a

Browse files
committed
Plug another leak in the DWARF unittests, DIEInlineStrings are never destroyed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289208 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent eae8838 commit 366c08a

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

include/llvm/CodeGen/DIE.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,16 @@ class DIEString {
256256
///
257257
/// This class is used with the DW_FORM_string form.
258258
class DIEInlineString {
259-
std::string S;
259+
StringRef S;
260260

261261
public:
262-
explicit DIEInlineString(StringRef Str) : S(Str.str()) {}
262+
template <typename Allocator>
263+
explicit DIEInlineString(StringRef Str, Allocator &A) : S(Str.copy(A)) {}
263264

264265
~DIEInlineString() = default;
265266

266267
/// Grab the string out of the object.
267-
StringRef getString() const { return StringRef(S); }
268+
StringRef getString() const { return S; }
268269

269270
void EmitValue(const AsmPrinter *AP, dwarf::Form Form) const;
270271
unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const;

lib/CodeGen/AsmPrinter/DIE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
606606

607607
LLVM_DUMP_METHOD
608608
void DIEInlineString::print(raw_ostream &O) const {
609-
O << "InlineString: " << S.c_str();
609+
O << "InlineString: " << S;
610610
}
611611

612612
//===----------------------------------------------------------------------===//

unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ void dwarfgen::DIE::addAttribute(uint16_t A, dwarf::Form Form,
6161
auto &DG = CU->getGenerator();
6262
if (Form == DW_FORM_string) {
6363
Die->addValue(DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,
64-
new (DG.getAllocator()) DIEInlineString(String));
64+
new (DG.getAllocator())
65+
DIEInlineString(String, DG.getAllocator()));
6566
} else {
6667
Die->addValue(
6768
DG.getAllocator(), static_cast<dwarf::Attribute>(A), Form,

0 commit comments

Comments
 (0)