[cfe-dev] clang-modernize feature (was: Rename cpp11-migrate to be something more general?)

Richard legalize at xmission.com
Tue Sep 3 14:52:22 PDT 2013


In article <CAGCO0KgQ5wdA9-8ZZ7kvijTbpBkbLLPmbxCSdNWdaEsZq=P6XA at mail.gmail.com>,
    Chandler Carruth <chandlerc at google.com> writes:

> Awesome. Thanks for everyone replying. I'll plan to do the rename tonight
> so beware the outstanding patches. =D

I recently did some playing around with libtooling to understand how
to create an automated refactoring.

I could contribute it to clang-modernize if people think it's
appropriate.

The tool replaces an argument list of "(void)" with "()".

I have it drilling down into most places, but I am still a little
sketchy on how to get it to recognize that:

	void some_function_taking_fn_ptrs(
		void (*fn_ptr)(void (*fn_void_ptr)(void)));

should become

	void some_function_taking_fn_ptrs(
		void (*fn_ptr(void (*fn_void_ptr)()));

This nesting of function pointer types can obviously occur farther and
farther down into an "inline" type declaration.

My questions for this audience are:

1) is this considered a "modernizing" transform that is appropriate
   for clang-modernize?

2) how do I walk arbitrary type declarations like this without having
   to re-invent parsing the type expressions?

With knowledge of 2), I think I can make this transformation complete
across everywhere that fn(void) is acceptable and replace it with
fn().
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://computergraphicsmuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>



More information about the cfe-dev mailing list