llvm-project/clang/tools
Douglas Gregor c6d5edd2ed Add support for retrieving the Doxygen comment associated with a given
declaration in the AST. 

The new ASTContext::getCommentForDecl function searches for a comment
that is attached to the given declaration, and returns that comment, 
which may be composed of several comment blocks.

Comments are always available in an AST. However, to avoid harming
performance, we don't actually parse the comments. Rather, we keep the
source ranges of all of the comments within a large, sorted vector,
then lazily extract comments via a binary search in that vector only
when needed (which never occurs in a "normal" compile).

Comments are written to a precompiled header/AST file as a blob of
source ranges. That blob is only lazily loaded when one requests a
comment for a declaration (this never occurs in a "normal" compile). 

The indexer testbed now supports comment extraction. When the
-point-at location points to a declaration with a Doxygen-style
comment, the indexer testbed prints the associated comment
block(s). See test/Index/comments.c for an example.

Some notes:
  - We don't actually attempt to parse the comment blocks themselves,
  beyond identifying them as Doxygen comment blocks to associate them
  with a declaration.
  - We won't find comment blocks that aren't adjacent to the
  declaration, because we start our search based on the location of
  the declaration.
  - We don't go through the necessary hops to find, for example,
  whether some redeclaration of a declaration has comments when our
  current declaration does not. Similarly, we don't attempt to
  associate a \param Foo marker in a function body comment with the
  parameter named Foo (although that is certainly possible).
  - Verification of my "no performance impact" claims is still "to be
  done".

llvm-svn: 74704
2009-07-02 17:08:52 +00:00
..
clang-cc Update for changes in LLVM. Hopefully this is the last one for a while. 2009-07-01 23:14:14 +00:00
driver Driver: Move Compilation::Execute to Driver::ExecuteCompilation. 2009-07-01 20:03:04 +00:00
index-test Add support for retrieving the Doxygen comment associated with a given 2009-07-02 17:08:52 +00:00
scan-view Increase scan-view max timeout to 1 minute. 2009-05-04 19:02:41 +00:00
CMakeLists.txt Introduce tools/index-test. 2009-06-25 18:22:52 +00:00
Makefile Introduce tools/index-test. 2009-06-25 18:22:52 +00:00