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

Eli Friedman eli.friedman at gmail.com
Wed Sep 4 13:11:11 PDT 2013


On Wed, Sep 4, 2013 at 12:33 PM, Richard <legalize at xmission.com> wrote:

>
> In article <
> CAJdarcHpLLjcXUgQzOpOQB0cuzTJQtehT+aggH_niAJFtRekQw at mail.gmail.com>,
>     Eli Friedman <eli.friedman at gmail.com> writes:
>
> > On Tue, Sep 3, 2013 at 2:52 PM, Richard <legalize at xmission.com> wrote:
> > > 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.
>
> It is my understanding that the syntax "(void)" is for compatibility
> with C, where (void) is needed to explicitly say that a function takes
> no arguments and () is the legacy syntax used by older C code before
> function prototypes.
>
> Am I wrong?
>

No, you're not wrong, but some people might consider it a style choice
anyway, given that C++ has always worked that way.


>
> > > 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.
>
> The problem is that source locations just give me a position within
> the text, they don't give me smaller units of semantic structure that
> I can walk.  Finding the start and end positions in the source text is
> easy -- what I'm stumbling with is finding the corresponding parsed
> structure from that text.
>
>
You can walk TypeSourceInfo: given a FunctionTypeLoc, you can get TypeLocs
for the arguments, which you can then convert to FunctionTypeLocs, etc.

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


More information about the cfe-dev mailing list