Hello Manuel,<div><br></div><div>Sadly, no. I'm struggling with some problems now:</div><div><br></div><div>1 - How do I detect and generate the class name for nested classes? I'm using CXXConstructorDecl getNameAsString() but it only returns to me the name of the enclosing class.</div>
<div><br></div><div>2 - I would like to not replace constructor initializers that were set up with macros with their values:</div><div><br></div><div>#define MACRO 10</div><div><br></div><div>Class::Class() : myval(MACRO)</div>
<div><br></div><div>after I rewrite the outputted code is:</div><div><br></div><div>Class::Class() : mvyal(10)</div><div><br></div><div>Is there a way to avoid this? I've tried to use Compiler.getPreprocessor().SetMacroExpansionOnlyInDirectives() but this simply removes the myval definition from the generated AST</div>
<div><br></div><div>3 - Variables that are default initialized on the header are stored with it. This is a problem as the compiler complains when I rewrite the source file with the initialization on the source but it was previously defined on the header. Is there to detect if the default initializer is on the method definition or in the method declaration?</div>
<div><br></div><div>4 - I've found a bug on the DeclPrinter class, and fixed it. The attachment is the patch.</div><div><br></div><div>5 - The current way i'm using to replace the old constructor declaration with the new declaration is with a new range:</div>
<div><br></div><div>SourceRange rng(d->getSourceRange().getBegin(), d->getBody()->getSourceRange().getBegin().getLocWithOffset(-1));</div><div><br></div><div>This was the only way I've managed to get the correct end of the end of the initializer list. This is an inconvenience as I would like to not process the body and hence make the tool faster, but if I disable body parsing I can't get its SourceRange.</div>
<div><br></div><div><br><div class="gmail_quote">2012/8/17 Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Victor,<br>
<br>
if I remember correctly we've been talking in IRC - have all your<br>
issues been resolved?<br>
<br>
Cheers,<br>
/Manuel<br>
<div><div class="h5"><br>
On Thu, Aug 9, 2012 at 5:22 AM, Victor Vicente de Carvalho<br>
<<a href="mailto:victor.v.carvalho@gmail.com">victor.v.carvalho@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> In the past month I've been working in a clang tool to refactor the fields<br>
> which are declared on a class constructor to match the order declared on the<br>
> header file, hence resolving the annoying Wreorder warning. After a series<br>
> of difficulties finally I have something that is close to the ideal, and<br>
> would like to someone more acquainted with clang internals to check if it's<br>
> the best form to implement this.<br>
><br>
> Also, I've got some problems that are still remaining:<br>
><br>
> 1 - I've been following the samples I've managed to find through the<br>
> internet, but every time I try to run the tool using the following command<br>
> line (I'm intentionally not providing any include paths as I don't want to<br>
> std to be parsed):<br>
><br>
> ../cpp-fixya <SOURCE.CPP> --<br>
><br>
> I get the following errros:<br>
><br>
> <premain>: CommandLine Error: Argument 'version' defined more than once!<br>
> <premain>: CommandLine Error: Argument 'print-all-options' defined more than<br>
> once!<br>
> <premain>: CommandLine Error: Argument 'print-options' defined more than<br>
> once!<br>
> <premain>: CommandLine Error: Argument 'help-hidden' defined more than once!<br>
> <premain>: CommandLine Error: Argument 'help' defined more than once!<br>
> <premain>: CommandLine Error: Argument 'debug-only' defined more than once!<br>
> <premain>: CommandLine Error: Argument 'debug-buffer-size' defined more than<br>
> once!<br>
> <premain>: CommandLine Error: Argument 'debug' defined more than once!<br>
> cpp-fixya: CommandLine Error: Argument 'version' defined more than once!<br>
> cpp-fixya: CommandLine Error: Argument 'print-all-options' defined more than<br>
> once!<br>
> cpp-fixya: CommandLine Error: Argument 'print-options' defined more than<br>
> once!<br>
> cpp-fixya: CommandLine Error: Argument 'help-hidden' defined more than once!<br>
> cpp-fixya: CommandLine Error: Argument 'help' defined more than once!<br>
> cpp-fixya: CommandLine Error: Argument 'debug-only' defined more than once!<br>
> cpp-fixya: CommandLine Error: Argument 'debug-buffer-size' defined more than<br>
> once!<br>
> cpp-fixya: CommandLine Error: Argument 'debug' defined more than once!<br>
><br>
><br>
> 2 - I haven't found a way to determine the class name for nested classes.<br>
> How would be the best way to detect and generate the correct naming to a<br>
> nested class? I've been using:<br>
><br>
> d->getNameAsString()<br>
><br>
> but it only returns the enclosing class<br>
><br>
><br>
> 3 - How do I determine if a class declaration is on a header or a source<br>
> file? I mean that because if it's a source-only declaration (i.e. private<br>
> classes) the c++ compiler wont accept constructors in the form:<br>
><br>
> Constructor::Constructor() : <init_declrs> {<br>
> }<br>
><br>
> only in the form:<br>
><br>
> Constructor() : <init_declrs> {<br>
> }<br>
><br>
><br>
> Here is the code:<br>
><br>
> <a href="https://gist.github.com/3300494" target="_blank">https://gist.github.com/3300494</a><br>
><br>
><br>
> Thanks in advance,<br>
><br>
><br>
> Victor<br>
><br>
><br>
><br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
><br>
</blockquote></div><br></div>