From 0288a5884c3c7c41f1b9bbcd9e6b7c2255957c3f Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Mon, 15 May 2017 17:18:38 -0700 Subject: [PATCH] Handle target_deref as lvalue --- dwflpp.cxx | 4 +--- elaborate.cxx | 5 +++++ tapsets.cxx | 25 +++++++++++++++++++++++-- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/dwflpp.cxx b/dwflpp.cxx index 6fb1bcd29..7b6d528b3 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -3512,6 +3512,7 @@ dwflpp::translate_base_ref (location_context &ctx, Dwarf_Word byte_size, bool si case loc_address: { target_deref *d = new target_deref; + d->tok = ctx.e->tok; d->addr = loc->program; d->size = byte_size; d->signed_p = signed_p; @@ -3650,9 +3651,6 @@ dwflpp::translate_final_fetch_or_store (location_context &ctx, dwarf_errmsg (-1)), e->tok); bool signed_p = encoding == DW_ATE_signed || encoding == DW_ATE_signed_char; - - // ??? where might the bare value be converted to an assignment? - assert(!lvalue); translate_base_ref (ctx, byte_size, signed_p); } break; diff --git a/elaborate.cxx b/elaborate.cxx index 418eeca29..53b760195 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -3184,6 +3184,11 @@ struct assignment_symbol_fetcher sym = NULL; } + void visit_target_deref (target_deref*) + { + sym = NULL; + } + void throwone (const token* t) { if (t->type == tok_operator && t->content == ".") diff --git a/tapsets.cxx b/tapsets.cxx index 0ded766b4..8b057535b 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -3693,11 +3693,32 @@ synthetic_embedded_deref_call(dwflpp& dw, location_context &ctx, // If this code snippet is assigning to an lvalue, // add a final argument for the rvalue. + expression *ref_exp = ctx.locations.back()->program; if (lvalue_p) { // NB: We don't know the value for fcall argument yet. // (see target_symbol_setter_functioncalls) - // fdecl->formal_args.push_back(...); + + vardecl *rvalue = new vardecl; + rvalue->type = pe_long; + rvalue->name = "rvalue"; + rvalue->tok = tok; + + fdecl->formal_args.push_back(rvalue); + + symbol *sym = new symbol; + sym->name = rvalue->name; + sym->tok = rvalue->tok; + sym->type = pe_long; + sym->referent = rvalue; + + assignment *a = new assignment; + a->tok = tok; + a->op = "="; + a->left = ref_exp; + a->right = sym; + + ref_exp = a; } fdecl->locals = ctx.locals; @@ -3716,7 +3737,7 @@ synthetic_embedded_deref_call(dwflpp& dw, location_context &ctx, return_statement *ret = new return_statement; ret->tok = tok; - ret->value = ctx.locations.back()->program; + ret->value = ref_exp; blk->statements.push_back(ret); // Add the synthesized decl to the session now. -- 2.43.5