[cfe-users] Reading and Attaching Comments to CLANG AST

Bewoayia Kebianyor via cfe-users cfe-users at lists.llvm.org
Wed Mar 7 01:49:13 PST 2018


Hi,

can anyone help in providing clarification to this query?

I am new to Clang, LLVM and have some questions regarding attaching comments to the clang AST. I would like to parse a C/C++ file and get preceeding comments to variable declarations and attach these to the AST. The comments are annotations of model objects in the source code. I need to get the source location for certain actions in the model based on these comments.

So far I can visit the VarDecl, statements using the ASTRecursive visitor. I have read several tutorials and searched, but could not find any straight forward way of reading the comments and attaching it to the AST node. I also noticed that the getRawCommentForDeclNoCache(VarDecl) is always null. From one of the tutorials it was mentioned that the option -fparse-all-comments must be passed to clang inorder to have non-doxygen style of comments.

Can someone please provide me with more clarification on this? Why do I always get nullptr for  getRawCommentForDeclNoCache(VarDecl). Where to pass this option.

Thanks inadvance,

Bewoayia

-----"cfe-users" <cfe-users-bounces at lists.llvm.org> schrieb: -----
An: cfe-users at lists.llvm.org
Von: Bewoayia Kebianyor via cfe-users 
Gesendet von: "cfe-users" 
Datum: 28.02.2018 14:36
Betreff: [cfe-users] Reading and Attaching Comments to CLANG AST

Hello,

I am new to Clang, LLVM and have some questions regarding attaching comments to the clang AST. I would like to parse a C/C++ file and get preceeding comments to variable declarations and attach these to the AST. The comments are annotations of model objects in the source code. I need to get the source location for certain actions in the model based on these comments.

So far I can visit the VarDecl, statements using the ASTRecursive visitor. I have read several tutorials and searched, but could not find any straight forward way of reading the comments and attaching it to the AST node. I also noticed that the getRawCommentForDeclNoCache(VarDecl) is always null. From one of the tutorials it was mentioned that the option -fparse-all-comments must be passed to clang inorder to have non-doxygen style of comments.

Can someone please provide me with more clarification on this? Why do I always get nullptr for  getRawCommentForDeclNoCache(VarDecl). Where to pass this option.

Thanks inadvance,

Bewoayia
 
_______________________________________________
cfe-users mailing list
cfe-users at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users



More information about the cfe-users mailing list