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

Eli Friedman eli.friedman at gmail.com
Tue Sep 3 15:23:58 PDT 2013


On Tue, Sep 3, 2013 at 2:52 PM, Richard <legalize at xmission.com> wrote:

>
> 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?
>

Maybe?  Some people might consider it more of a style choice.


> 2) how do I walk arbitrary type declarations like this without having
>    to re-invent parsing the type expressions?
>
> You walk type declarations using TypeSourceInfo: FunctionTypeLoc has
functions to retrieve the LParen and RParen locations for a function type
declaration.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130903/bbb2b96c/attachment.html>


More information about the cfe-dev mailing list