[cfe-dev] Debugging Information; exploiting comments

Chris Lattner clattner at apple.com
Sat Nov 10 18:53:16 PST 2007


> Begin forwarded message:
>> Another idea I had is implementing a documentation tools (like
>> doxygen)
>> using clang. The problem is that the existing framework doesn't  
>> permit
>> analyzing the commentary and parsing in the same pass (At least I
>> don't see
>> how). I would need to add some sort of callback in the lexer or
>> preprocesseur for processing the comment (we can't parse the comment
>> token,
>> it would be an impossible task). The callback would store the
>> comment and
>> when the next declaration would be parsed, the stored comment is
>> used for
>> decoration the declaration. Do you think this is a good way? Another
>> way
>> would be to add some sort of filter between the lexer and the parser
>> which
>> would process and delete the comment token as they come, but it would
>> probably be slower and on the critical path (not sure the lexing/
>> parsing
>> part is time critical since the semantical analysis will eventually
>> probably
>> be a lot slower).

I think that Ted covered all the important points with this in his  
previous email.  The meta issue is that it is tricky.  For example, it  
is reasonably easy to buffer up comments and have the next decl that  
occurs apply the buffer to the decl.  This covers stuff like this:


/// foo
int X;


However, sometimes you want to apply it to the previous decl as well:

int X;   /// fooo!!


I think it would be great to have a nice (but optional) way to handle  
this.  I think that buffering up comments and having the AST builder  
code suck them out when needed is the right way to go...

-Chris 



More information about the cfe-dev mailing list