* [PATCH] Add operator* to gimple_stmt_iterator and gphi_iterator
@ 2023-04-21 13:51 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-04-21 13:51 UTC (permalink / raw)
To: gcc-patches
This allows STL style iterator dereference. It's the same
as gsi_stmt () or .phi ().
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
* gimple-iterator.h (gimple_stmt_iterator::operator*): Add.
(gphi_iterator::operator*): Likewise.
---
gcc/gimple-iterator.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gcc/gimple-iterator.h b/gcc/gimple-iterator.h
index 38352aa95af..b709923f00d 100644
--- a/gcc/gimple-iterator.h
+++ b/gcc/gimple-iterator.h
@@ -24,6 +24,8 @@ along with GCC; see the file COPYING3. If not see
struct gimple_stmt_iterator
{
+ gimple *operator * () const { return ptr; }
+
/* Sequence node holding the current statement. */
gimple_seq_node ptr;
@@ -38,6 +40,8 @@ struct gimple_stmt_iterator
/* Iterator over GIMPLE_PHI statements. */
struct gphi_iterator : public gimple_stmt_iterator
{
+ gphi *operator * () const { return as_a <gphi *> (ptr); }
+
gphi *phi () const
{
return as_a <gphi *> (ptr);
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-21 13:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-21 13:51 [PATCH] Add operator* to gimple_stmt_iterator and gphi_iterator Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).