[cfe-dev] Criticism over a clang tool to reorder fields on constructor declarations

Victor Vicente de Carvalho victor.v.carvalho at gmail.com
Mon Aug 20 19:36:44 PDT 2012


Hello,

thanks for everyone that have helped me to sort out the problems. Finally
I've managed to make it work correctly to all cases (at least the ones I've
found), and I'm glad to share it here if someone is interested:

https://github.com/scooterman/clang-tools

There are some minor things that could improve the tool. It would be
desirable to not change all constructors, but as while parsing I'm
receiving the initializers on the declared order already this would require
me to get the original source as string, strip all spaces and newlines, and
compare the resulting string with the newly ordered one. I don't know if
its worth to do that anyway.

Now the next one I'm thinking to implement is a tool to automatically add
default values to variables.


Thanks again!



2012/8/19 Philip Craig <philipjcraig at gmail.com>

> On Mon, Aug 20, 2012 at 11:08 AM, Philip Craig <philipjcraig at gmail.com>
> wrote:
> > On Mon, Aug 20, 2012 at 10:31 AM, Victor Vicente de Carvalho
> > <victor.v.carvalho at gmail.com> wrote:
> >> I've just tried to dump the construct xml using clang -dump-ast-xml, and
> >> that's what I've got:
> >
> > That uses DumpXML.cpp, which only has a stub for CXXCtorInitializer,
> > so it won't show them. I'm using a tool based on RecursiveASTVisitor
> > to dump it instead.
>
> Try clang -ast-dump instead. It does show all of the
> CXXCtorInitializer (in a partially pretty-printed form). And you can
> see by changing the member order that the initializer order also
> changes.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120820/7f6674a3/attachment.html>


More information about the cfe-dev mailing list