summaryrefslogtreecommitdiffstats
path: root/elaborate.cxx
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-08-03 15:16:09 -0700
committerJosh Stone <jistone@redhat.com>2009-08-03 15:16:09 -0700
commit0164a29cfb80344dced2e1683df05f6b62fe6cb3 (patch)
treef1135402bc2f45e03718733eb8490cd1f9df52f6 /elaborate.cxx
parent28ad563d57d03e0d21936e394061e3380607d83b (diff)
parent6fda2dff51c667a8c73545dd397b844108715310 (diff)
downloadsystemtap-steved-0164a29cfb80344dced2e1683df05f6b62fe6cb3.tar.gz
systemtap-steved-0164a29cfb80344dced2e1683df05f6b62fe6cb3.tar.xz
systemtap-steved-0164a29cfb80344dced2e1683df05f6b62fe6cb3.zip
Merge branch 'array_index'
Diffstat (limited to 'elaborate.cxx')
-rw-r--r--elaborate.cxx62
1 files changed, 60 insertions, 2 deletions
diff --git a/elaborate.cxx b/elaborate.cxx
index fafc5e63..d1ebe326 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -2534,6 +2534,7 @@ struct void_statement_reducer: public update_visitor
void visit_concatenation (concatenation* e);
void visit_functioncall (functioncall* e);
void visit_print_format (print_format* e);
+ void visit_target_symbol (target_symbol* e);
void visit_cast_op (cast_op* e);
// these are a bit hairy to grok due to the intricacies of indexables and
@@ -2803,16 +2804,73 @@ void_statement_reducer::visit_print_format (print_format* e)
}
void
+void_statement_reducer::visit_target_symbol (target_symbol* e)
+{
+ // When target_symbol isn't needed, it's just as good to
+ // evaluate any array indexes directly
+
+ block *b = new block;
+ b->tok = e->tok;
+
+ for (unsigned i=0; i<e->components.size(); i++ )
+ {
+ if (e->components[i].type != target_symbol::comp_expression_array_index)
+ continue;
+
+ expr_statement *es = new expr_statement;
+ es->value = e->components[i].expr_index;
+ es->tok = es->value->tok;
+ b->statements.push_back(es);
+ }
+
+ if (b->statements.empty())
+ {
+ delete b;
+ provide (e);
+ return;
+ }
+
+ if (session.verbose>2)
+ clog << "Eliding unused target symbol " << *e->tok << endl;
+
+ b->visit(this);
+ relaxed_p = false;
+ e = 0;
+ provide (e);
+}
+
+void
void_statement_reducer::visit_cast_op (cast_op* e)
{
// When the result of a cast operation isn't needed, it's just as good to
- // evaluate the operand directly
+ // evaluate the operand and any array indexes directly
+
+ block *b = new block;
+ b->tok = e->tok;
+
+ expr_statement *es = new expr_statement;
+ es->value = e->operand;
+ es->tok = es->value->tok;
+ b->statements.push_back(es);
+
+ for (unsigned i=0; i<e->components.size(); i++ )
+ {
+ if (e->components[i].type != target_symbol::comp_expression_array_index)
+ continue;
+
+ es = new expr_statement;
+ es->value = e->components[i].expr_index;
+ es->tok = es->value->tok;
+ b->statements.push_back(es);
+ }
if (session.verbose>2)
clog << "Eliding unused typecast " << *e->tok << endl;
+ b->visit(this);
relaxed_p = false;
- e->operand->visit(this);
+ e = 0;
+ provide (e);
}