summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2010-02-19 17:44:44 -0800
committerJosh Stone <jistone@redhat.com>2010-02-23 16:20:35 -0800
commitf946b10fbd72dd760f04ad9475f2ba3ccb56666f (patch)
treefccc6a4d31e04f741cf0a8ebe6f44c36943b9dae
parentd945a07eecee9851173365459d196bcd22c3e636 (diff)
downloadsystemtap-steved-f946b10fbd72dd760f04ad9475f2ba3ccb56666f.tar.gz
systemtap-steved-f946b10fbd72dd760f04ad9475f2ba3ccb56666f.tar.xz
systemtap-steved-f946b10fbd72dd760f04ad9475f2ba3ccb56666f.zip
Simplify null_statement construction
It only needs a token*, so build that into the constructor.
-rw-r--r--elaborate.cxx9
-rw-r--r--parse.cxx6
-rw-r--r--staptree.cxx12
-rw-r--r--staptree.h2
4 files changed, 18 insertions, 11 deletions
diff --git a/elaborate.cxx b/elaborate.cxx
index 88a856c2..b349ff8c 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -2449,8 +2449,7 @@ dead_stmtexpr_remover::visit_for_loop (for_loop *s)
else
{
// Can't elide this whole statement; put a null in there.
- s->block = new null_statement();
- s->block->tok = s->tok;
+ s->block = new null_statement(s->tok);
}
}
provide (s);
@@ -2526,8 +2525,7 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p)
&& ! s.timing) // PR10070
s.print_warning ("side-effect-free probe '" + p->name + "'", p->tok);
- p->body = new null_statement();
- p->body->tok = p->tok;
+ p->body = new null_statement(p->tok);
// XXX: possible duplicate warnings; see below
}
@@ -2551,8 +2549,7 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p)
if (! s.suppress_warnings)
s.print_warning ("side-effect-free function '" + fn->name + "'", fn->tok);
- fn->body = new null_statement();
- fn->body->tok = fn->tok;
+ fn->body = new null_statement(fn->tok);
// XXX: the next iteration of the outer optimization loop may
// take this new null_statement away again, and thus give us a
diff --git a/parse.cxx b/parse.cxx
index f99a440b..79784490 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -1289,11 +1289,7 @@ parser::parse_statement ()
statement *ret;
const token* t = peek ();
if (t && t->type == tok_operator && t->content == ";")
- {
- null_statement* n = new null_statement ();
- n->tok = next ();
- return n;
- }
+ return new null_statement (next ());
else if (t && t->type == tok_operator && t->content == "{")
return parse_stmt_block (); // Don't squash semicolons.
else if (t && t->type == tok_keyword && t->content == "if")
diff --git a/staptree.cxx b/staptree.cxx
index 7a335fc3..a31112cb 100644
--- a/staptree.cxx
+++ b/staptree.cxx
@@ -42,6 +42,18 @@ statement::statement ():
}
+statement::statement (const token* tok):
+ tok (tok)
+{
+}
+
+
+null_statement::null_statement (const token* tok):
+ statement(tok)
+{
+}
+
+
statement::~statement ()
{
}
diff --git a/staptree.h b/staptree.h
index a654a7b4..bc5f0bfc 100644
--- a/staptree.h
+++ b/staptree.h
@@ -492,6 +492,7 @@ struct statement
virtual void visit (visitor* u) = 0;
const token* tok;
statement ();
+ statement (const token* tok);
virtual ~statement ();
};
@@ -547,6 +548,7 @@ struct null_statement: public statement
{
void print (std::ostream& o) const;
void visit (visitor* u);
+ null_statement (const token* tok);
};