///
/// 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;
LLVM_DUMP_METHOD
void DIEInlineString::print(raw_ostream &O) const {
- O << "InlineString: " << S.c_str();
+ O << "InlineString: " << S;
}
//===----------------------------------------------------------------------===//
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,