On Sat, Nov 17, 2018 at 12:05 AM Martin Sebor <mse...@gmail.com> wrote:
>
> To encourage and simplify the adoption of iterator classes in
> GCC the attached patch turns the function_args_iterator struct
> into an (almost) proper C++ iterator class that can be used
> the same way as traditional forward iterators.
>
> The patch also replaces all of the 26 uses of the legacy
> FOREACH_FUNCTION_ARGS macro with ordinary for loops that use
> function_args_iterator directly, and also poisons both
> FOREACH_FUNCTION_ARGS and the unused FOREACH_FUNCTION_ARGS_PTR
> macros.
>
> The few dozen (hundred?) existing uses of for loops that iterate
> over function parameter types using the TREE_CHAIN() macro can
> be relatively easily modified to adopt the iterator approach over
> time.  (The patch stops of short of making this change.)
>
> Eventually, when GCC moves to more a recent C++ revision, it will
> become possible to simplify the for loops to make use of the range
> based for loop syntax along the lines of:
>
>    for (auto argtype: function_args (functype))
>      {
>        ...
>      }
>
> Tested on x86_64-linux, and (lightly) on powerpc64le-linux using
> a cross-compiler.  I'll test the changes to the other back ends
> before committing.

This isn't stage3 material.

Richard.

>
> Martin
>
> PS For some additional background on this change see:
>    https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00493.html

Reply via email to