1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

Plug another leak in the DWARF unittests, DIEInlineStrings are never destroyed.

llvm-svn: 289208
This commit is contained in:
Benjamin Kramer 2016-12-09 13:33:41 +00:00
parent 87d6393262
commit 11e0ca31fc
3 changed files with 7 additions and 5 deletions

View File

@ -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;

View File

@ -606,7 +606,7 @@ unsigned DIEInlineString::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
LLVM_DUMP_METHOD
void DIEInlineString::print(raw_ostream &O) const {
O << "InlineString: " << S.c_str();
O << "InlineString: " << S;
}
//===----------------------------------------------------------------------===//

View File

@ -61,7 +61,8 @@ void dwarfgen::DIE::addAttribute(uint16_t A, dwarf::Form Form,
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,