diff options
author | Tom Tromey <tromey@redhat.com> | 2014-10-15 21:26:02 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2014-10-15 21:26:02 +0000 |
commit | 1995e372a5012521ebfa709f23a2ab22c1bb99e9 (patch) | |
tree | e070829392cd6076a5fd5844a811320f6378c07c /gcc | |
parent | 37cfabb0b4263b12d84037c608bfe6e854cdda01 (diff) | |
download | gcc-1995e372a5012521ebfa709f23a2ab22c1bb99e9.zip gcc-1995e372a5012521ebfa709f23a2ab22c1bb99e9.tar.gz gcc-1995e372a5012521ebfa709f23a2ab22c1bb99e9.tar.bz2 |
timevar.h: Add an auto_timevar class
Patch authored by Tom Tromey; originally contributed by him to jit
branch on 2014-03-19.
gcc/ChangeLog:
* timevar.h (class auto_timevar): New class.
From-SVN: r216288
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/timevar.h | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 80cd255..9823522 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2014-10-15 Tom Tromey <tromey@redhat.com> + + * timevar.h (class auto_timevar): New class. + 2014-10-15 Uros Bizjak <ubizjak@gmail.com> PR go/59432 diff --git a/gcc/timevar.h b/gcc/timevar.h index 6703cc9..f018e39 100644 --- a/gcc/timevar.h +++ b/gcc/timevar.h @@ -110,6 +110,30 @@ timevar_pop (timevar_id_t tv) timevar_pop_1 (tv); } +// This is a simple timevar wrapper class that pushes a timevar in its +// constructor and pops the timevar in its destructor. +class auto_timevar +{ + public: + auto_timevar (timevar_id_t tv) + : m_tv (tv) + { + timevar_push (m_tv); + } + + ~auto_timevar () + { + timevar_pop (m_tv); + } + + private: + + // Private to disallow copies. + auto_timevar (const auto_timevar &); + + timevar_id_t m_tv; +}; + extern void print_time (const char *, long); #endif /* ! GCC_TIMEVAR_H */ |