Clang Can Analyze Code Comments, Generate Docs

Written by Michael Larabel in LLVM on 18 November 2012 at 01:49 AM EST. 5 Comments
LLVM
Aside from why LLVM/Clang was ported to one of the fastest super computer's in the world and using Clang to implement Microsoft's C++ AMP, another interesting session at this month's LLVM Developers' Conference in San Jose was about using Clang to analyze code comments.

By having Clang parse documentation comments, Clang could be enhanced to do additional semantic checking, ensure the code comments remain relevant to the actual code, and code completion APIs could take advantage of the documentation within the code. Ultimately, a Doxygen-like tool could be created based upon Clang for generating proper documentation out of the code itself and the associated comments. Further out, automatic comment re-factoring could be done to update names referenced within the inline code comments so that the resulting documentation is always up-to-date.

Lots of this has already been implemented within Clang and the libclang library. Dmitri Gribenko of the HPC Center at the National Technical University of Ukraine in Kyiv presented on this work. There are PDF slides available for those interested in parsing documentation comments in Clang.

What's implemented up to this point is that Clang can parse documentation comments, find semantic errors in comments, and export comments as XML. Dmitri says, "This work enables more awesome features in future!"

Parsing of documentation comments isn't done by default since some programmers don't want it plus it would slow down the build process. This process is only done if -Wdocumentation is passed to the compiler front-end.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week