[cfe-dev] [clang-tidy] Some possible contributions

Firat Kasmis via cfe-dev cfe-dev at lists.llvm.org
Mon Dec 14 16:00:05 PST 2015

Hi Piotr,

regarding your issue #1: I have already implemented a transformer which
performs exactly this, including a possible initializer. I can provide you
tomorrow with a simple snippet guiding you in the right direction.
Basically, I am matching for DeclStmt and iterating through its DeclGroup.
The group members are VarDecl as you can see by using "clang-check
-ast-dump file.c --". Once you have the VarDecl there is any type and
initialzer information you need. Unfortunately, this works only for
init-declarator lists, which are defined in a scope and not globally (a
DeclStmt/Statement just exists in a scope). See my post:

I am going to debug this. Meanwhile, I think instead of matching for
DeclStmt and iterating through the DeclGroup, looking for all VarDecl's
with the same line location should work too.

2015-12-14 22:56 GMT+01:00 Richard via cfe-dev <cfe-dev at lists.llvm.org>:

> [Please reply *only* to the list and do not include my email directly
> in the To: or Cc: of your reply; otherwise I will not see your reply.
> Thanks.]
> In article <566F436A.2080902 at gmail.com>,
>     Piotr Dziwinski via cfe-dev <cfe-dev at lists.llvm.org> writes:
> > On 14/12/15 20:42, Richard via cfe-dev wrote:
> > > IMO, the proper place to fix this is in the AST itself.  I would like
> > > to see the AST node should provide an iterator API that allows you to
> > > walk over all the identifiers (SourceLocation begin/end for each
> > > identifier) in a single declaration and obtain their actual types:
> > >
> > > a -> long int
> > > b -> long int *
> > > c -> long int[10]
> > > [...]
> >
> > Well, in a way, we do have this information, as part of QualType and
> > Type components of AST which I can access for these declarations.
> Great!
> > But the crux of the problem is the correct generation of removals in
> > FixIt hints.
> > [...]
> > This is where I need to know the locations where the cuts are to be made.
> Yes, this is what I tried to find in the parser before, but I was
> unsuccessful being unfamiliar with the parser code.
> --
> "The Direct3D Graphics Pipeline" free book <
> http://tinyurl.com/d3d-pipeline>
>      The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
>          The Terminals Wiki <http://terminals.classiccmp.org>
>   Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151215/59c2a3d2/attachment.html>

More information about the cfe-dev mailing list