Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing comments with clang

Tags:

clang

clang++

I am trying to utilize clang tooling library for the purpose of my future tool. What I would like to do with this tool is: 1. parse all the source code (with includes) and detect any of my keywords in the comments (comments will be some kind of interface between the programmer and my tool, which will do various things with the rest of the source code according to commands placed in the comments). 2. according to commands from the source code, do some refactoring of it

The refactoring itself will be done using clang AST, like from example below: http://eli.thegreenplace.net/2014/07/29/ast-matchers-and-clang-refactoring-tools

The thing I am looking for currently is how to parse the comments, within the same run of clang tooling procedures. I do not want to make separate step just for parsing the source code, because it have to be already done in tooling library.

Do you know how to somehow get the information about comments included in the source code I am parsing by tooling library?

like image 788
user2301299 Avatar asked Feb 22 '16 21:02

user2301299


1 Answers

Try the options -Wdocumentation and associated options (as -fparse-all-comments). If U use some tools (as clang-check or clang-tidy, adds these options in the compile commands db.

like image 62
Rémi Cohen-Scali Avatar answered Jan 03 '23 14:01

Rémi Cohen-Scali