summaryrefslogtreecommitdiffstats
path: root/translate.cxx
diff options
context:
space:
mode:
authordsmith <dsmith>2007-08-30 20:23:50 +0000
committerdsmith <dsmith>2007-08-30 20:23:50 +0000
commite1407ce08eeafc0295200b610c995e1142d5ffe5 (patch)
tree2fbaee22130cc32e498158cfca55177da92c03ab /translate.cxx
parent8d2ea625fc11466f4477afc1e1b90f8f1b3260cc (diff)
downloadsystemtap-steved-e1407ce08eeafc0295200b610c995e1142d5ffe5.tar.gz
systemtap-steved-e1407ce08eeafc0295200b610c995e1142d5ffe5.tar.xz
systemtap-steved-e1407ce08eeafc0295200b610c995e1142d5ffe5.zip
2007-08-30 David Smith <dsmith@redhat.com>
PR 4983 * translate.cxx (c_tmpcounter::visit_print_format): Don't declare temporaries for number and string constants. (c_unparser::visit_print_format): Use numeric and string constants directly instead of copying them into temporaries.
Diffstat (limited to 'translate.cxx')
-rw-r--r--translate.cxx16
1 files changed, 14 insertions, 2 deletions
diff --git a/translate.cxx b/translate.cxx
index 4891c617..d621cf26 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -3938,7 +3938,9 @@ c_tmpcounter::visit_print_format (print_format* e)
e->args[i]->tok);
}
- t.declare (*parent);
+ if (e->args[i]->tok->type != tok_number
+ && e->args[i]->tok->type != tok_string)
+ t.declare (*parent);
e->args[i]->visit (this);
}
@@ -4004,7 +4006,17 @@ c_unparser::visit_print_format (print_format* e)
o->newline() << "c->last_stmt = "
<< lex_cast_qstring(*e->args[i]->tok) << ";";
- c_assign (t.value(), e->args[i], "print format actual argument evaluation");
+
+ // If we've got a numeric or string constant, instead of
+ // assigning the numeric or string constant to a temporary,
+ // then passing the temporary to _stp_printf/_stp_snprintf,
+ // let's just override the temporary with the constant.
+ if (e->args[i]->tok->type == tok_number
+ || e->args[i]->tok->type == tok_string)
+ tmp[i].override(c_expression(e->args[i]));
+ else
+ c_assign (t.value(), e->args[i],
+ "print format actual argument evaluation");
}
std::vector<print_format::format_component> components;