[cfe-dev] Criticism over a clang tool to reorder fields on constructor declarations
Victor Vicente de Carvalho
victor.v.carvalho at gmail.com
Wed Aug 8 20:22:15 PDT 2012
Hello,
In the past month I've been working in a clang tool to refactor the fields
which are declared on a class constructor to match the order declared on
the header file, hence resolving the annoying Wreorder warning. After a
series of difficulties finally I have something that is close to the ideal,
and would like to someone more acquainted with clang internals to check if
it's the best form to implement this.
Also, I've got some problems that are still remaining:
1 - I've been following the samples I've managed to find through the
internet, but every time I try to run the tool using the following command
line (I'm intentionally not providing any include paths as I don't want to
std to be parsed):
../cpp-fixya <SOURCE.CPP> --
I get the following errros:
<premain>: CommandLine Error: Argument 'version' defined more than once!
<premain>: CommandLine Error: Argument 'print-all-options' defined more
than once!
<premain>: CommandLine Error: Argument 'print-options' defined more than
once!
<premain>: CommandLine Error: Argument 'help-hidden' defined more than once!
<premain>: CommandLine Error: Argument 'help' defined more than once!
<premain>: CommandLine Error: Argument 'debug-only' defined more than once!
<premain>: CommandLine Error: Argument 'debug-buffer-size' defined more
than once!
<premain>: CommandLine Error: Argument 'debug' defined more than once!
cpp-fixya: CommandLine Error: Argument 'version' defined more than once!
cpp-fixya: CommandLine Error: Argument 'print-all-options' defined more
than once!
cpp-fixya: CommandLine Error: Argument 'print-options' defined more than
once!
cpp-fixya: CommandLine Error: Argument 'help-hidden' defined more than once!
cpp-fixya: CommandLine Error: Argument 'help' defined more than once!
cpp-fixya: CommandLine Error: Argument 'debug-only' defined more than once!
cpp-fixya: CommandLine Error: Argument 'debug-buffer-size' defined more
than once!
cpp-fixya: CommandLine Error: Argument 'debug' defined more than once!
2 - I haven't found a way to determine the class name for nested classes.
How would be the best way to detect and generate the correct naming to a
nested class? I've been using:
d->getNameAsString()
but it only returns the enclosing class
3 - How do I determine if a class declaration is on a header or a source
file? I mean that because if it's a source-only declaration (i.e. private
classes) the c++ compiler wont accept constructors in the form:
Constructor::Constructor() : <init_declrs> {
}
only in the form:
Constructor() : <init_declrs> {
}
Here is the code:
https://gist.github.com/3300494
Thanks in advance,
Victor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120809/07d2faa7/attachment.html>
More information about the cfe-dev
mailing list