Friday, June 17, 2011

Alpha release of dxr

I am pleased to announce an alpha release of DXR built on top of Clang. A live demo of DXR can be found at, which is an index of a relatively recent copy of the Clang source code. Since this is merely an alpha release, expect to find bugs and inconsistencies in the output. For more information, you can go to #static on or contact the static analysis mailing list. A list of most of the bugs I am aware of is at the end of this blog post.

So what is DXR? DXR is a smart code browser that works by using instrumented compilers to use what the compiler knows about the code to provide a database of the code. For C and C++ in particular, using an instrumented compiler is necessary, since it is the only reliable way to fix the issue of macros. Take, for instance, RecursiveASTVistor in the Clang codebase. Most of the almost 1200 functions are defined via macros as opposed to in raw code; as a consequence, the doxygen output for this class is useless: as far as I can tell, there are only five methods I can override to visit AST nodes. On the other hand, DXR neatly tells me all of the methods that are defined, and can point me to the place where that function is defined (within the macro, of course).

Where can you get the code? DXR is available both as a github repository (use the dxr-clang branch) and as a Mercurial repository. Instructions on how to use can be found on the wiki page.

The following is a list of known problems:

  • Links occur at odd boundaries
  • Some lines have id="l234"/> prepended
  • Non-root installs (i.e., installing to cause issues. Interestingly, refreshing the page often causes things to work.
  • There is a long list of scrolling text when compiling code. Ignore it.
  • HTML generation produces IndexErrors
  • .csv files are created in the source directory and HTML code is generated.
  • Inheritance searches don't match the full hierarchy, only one or two levels.


Benoit Jacob said...

Really great news. How well are C++ templates supported? I'm considering using this for a project that uses a lot of template metaprogramming. It would be nice to be able to search for templates, know what type is a template specialization of what other, search for typedefs, search for integer constants (static const int, enum values, template parameters...)

Joshua Cranmer said...

So far, I haven't really started worrying about templates, but I should be able to make that sort of stuff possible in future releases.