Using RecursiveASTVisitor with comment nodes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using RecursiveASTVisitor with comment nodes

Eric Fiselier via cfe-dev
I'm working on a doc-comment tool using RecursiveASTVisitor however it doesn't seem to work with member functions named Visit[Comment Type]Comment. 
E.g. VisitFullComment never gets called. When dumping the AST for the same source it clearly shows the comments nested under a FunctionDecl node.

Do I have to extract the comments directly from declaration nodes? Or can I extract them independently?

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using RecursiveASTVisitor with comment nodes

Eric Fiselier via cfe-dev
Hi Stephen,

I believe that the comment nodes are stored in a side table, and are not visited by the RecursiveASTVisitor. Here's how the AST dumper gets them:

    if (const FullComment *Comment =
            D->getASTContext().getLocalCommentForDeclUncached(D))
      dumpFullComment(Comment);

You get them in the same manner in your visitor in your VisitDecl function if you want to visit them.

I hope this helps,
Alex

On 23 October 2017 at 18:38, Stephen Pegoraro via cfe-dev <[hidden email]> wrote:
I'm working on a doc-comment tool using RecursiveASTVisitor however it doesn't seem to work with member functions named Visit[Comment Type]Comment. 
E.g. VisitFullComment never gets called. When dumping the AST for the same source it clearly shows the comments nested under a FunctionDecl node.

Do I have to extract the comments directly from declaration nodes? Or can I extract them independently?

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Using RecursiveASTVisitor with comment nodes

Eric Fiselier via cfe-dev
Hi Alex,

Thanks for clarifying! That's how I ended up implementing it anyway.


Cheers,
Steve

On 25 October 2017 at 01:13, Alex L <[hidden email]> wrote:
Hi Stephen,

I believe that the comment nodes are stored in a side table, and are not visited by the RecursiveASTVisitor. Here's how the AST dumper gets them:

    if (const FullComment *Comment =
            D->getASTContext().getLocalCommentForDeclUncached(D))
      dumpFullComment(Comment);

You get them in the same manner in your visitor in your VisitDecl function if you want to visit them.

I hope this helps,
Alex

On 23 October 2017 at 18:38, Stephen Pegoraro via cfe-dev <[hidden email]> wrote:
I'm working on a doc-comment tool using RecursiveASTVisitor however it doesn't seem to work with member functions named Visit[Comment Type]Comment. 
E.g. VisitFullComment never gets called. When dumping the AST for the same source it clearly shows the comments nested under a FunctionDecl node.

Do I have to extract the comments directly from declaration nodes? Or can I extract them independently?

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev