mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-17 10:20:33 +08:00
Example of converting global state to per-pass state.
gcc/testsuite 2013-08-13 David Malcolm <dmalcolm@redhat.com> Example of converting global state to per-pass state. * gcc.dg/plugin/one_time_plugin.c (one_pass::execute): Convert global state "static int counter" to... (one_pass::counter): ...this instance data. From-SVN: r201681
This commit is contained in:
parent
b338b23f88
commit
3944d88d35
@ -1,3 +1,11 @@
|
||||
2013-08-13 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
Example of converting global state to per-pass state.
|
||||
|
||||
* gcc.dg/plugin/one_time_plugin.c (one_pass::execute): Convert
|
||||
global state "static int counter" to...
|
||||
(one_pass::counter): ...this instance data.
|
||||
|
||||
2013-08-13 David Malcolm <dmalcolm@redhat.com>
|
||||
|
||||
* gcc.dg/plugin/one_time_plugin.c: (one_pass_gate): Convert
|
||||
|
@ -33,13 +33,16 @@ class one_pass : public gimple_opt_pass
|
||||
{
|
||||
public:
|
||||
one_pass(gcc::context *ctxt)
|
||||
: gimple_opt_pass(pass_data_one_pass, ctxt)
|
||||
: gimple_opt_pass(pass_data_one_pass, ctxt),
|
||||
counter(0)
|
||||
{}
|
||||
|
||||
/* opt_pass methods: */
|
||||
bool gate ();
|
||||
unsigned int execute ();
|
||||
|
||||
private:
|
||||
int counter;
|
||||
}; // class one_pass
|
||||
|
||||
} // anon namespace
|
||||
@ -51,8 +54,6 @@ bool one_pass::gate (void)
|
||||
|
||||
unsigned int one_pass::execute ()
|
||||
{
|
||||
static int counter = 0;
|
||||
|
||||
if (counter > 0) {
|
||||
printf ("Executed more than once \n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user