[cfe-dev] Source to source transformation w/ comments

Andre Vehreschild via cfe-dev cfe-dev at lists.llvm.org
Fri May 6 07:31:34 PDT 2016


Hi all,

I am working on a project to rework a given program having a large code
base. While using Clang's fine and elaborate ways to understand and
massage an AST, I am missing a way to parse and transfer comments. I
have seen some efforts so far to get doxygen comments for methods and
so on. But what about the comments that document the working of
functions, i.e., all the comment that are in the .cpp files? 

Is there any support on this? 

What would be a good way to get them transfered? A new AST node on
stmt-level to refer to a comment in the SourceManager, i.e., quite light
weight? Or are there other loose ends that I can attach to?

Because I am constructing the transformed code in a bottom-up way
(bottom being the leaves of the AST), and am just streaming the result
into a stringstream, I can't traverse the resulting code a second time
and inject the comments while looking for source locations. 

Furthermore would it be appreciated to have a way of control on the
transformation process, i.e. tell the clang-tool that for a certain
routine it should do something specific. I.e. a directive should be
available. Any thoughts on this?

I am willing to develop and provide patches to get that functionality,
but for this I like know a design that would be well perceived and has
chances to make it into clang, i.e., not to waste the effort.

- Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 



More information about the cfe-dev mailing list