[cfe-commits] r58001 - in /cfe/trunk: include/clang/AST/Type.h include/clang/AST/TypeOrdering.h lib/AST/InheritViz.cpp lib/Sema/SemaDeclCXX.cpp

Doug Gregor doug.gregor at gmail.com
Wed Oct 22 18:38:05 PDT 2008


On Wed, Oct 22, 2008 at 6:04 PM, Chris Lattner <clattner at apple.com> wrote:
>
> On Oct 22, 2008, at 2:13 PM, Douglas Gregor wrote:
>
>> Author: dgregor
>> Date: Wed Oct 22 16:13:31 2008
>> New Revision: 58001
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=58001&view=rev
>> Log:
>> Added GraphViz visualization of C++ inheritance hierarchies.
>>
>> Factored the QualTypeOrdering predicate into its own header
>> (TypeOrdering.h), now that it is used in two places.
>
> Woo, cool!  One random stream of thought question for you :), does this make
> sense to be a method on Type, or would it be possible to make this a driver
> option? If it's an option to the driver - "clang -view-inheritance" or
> something - this would get it out of libast.

We could make it a driver option, if it would be useful. It would need
to be something like "-view-inheritance=<class-name>", where we'd call
the parser at the end of the translation unit to parse <class-name>
for us and then render the inheritance graph starting with that type.
I'm perfectly happy to implement this, if people would find it useful.

 > However, since it's just in a
> debug build, it probably isn't worth worrying about, and I can imagine that
> this is very useful in gdb.

My plan was to use it to help debug cases where lookup into a class is
ambiguous (e.g., by highlighting the multiple paths lookup finds), so
as long as it is available somewhere in GDB, I'm happy.

It occurs to me that, if we were sufficiently crazy, we could actually
use this in (HTML) error messages. If you trigger an ambiguous
conversion from a derived pointer to a base pointer (where there are
multiple bases of the same type), it could show you the various paths.
I was actually planning to just print the paths in ASCII, e.g.,
D->B->A, D->C->A, but showing it graphically would be way cooler.

> If this is only in debug builds, please #ifdef the out-of-line methods in
> InheritViz.cpp so that they don't get linked into release builds.

Okay, if we don't end up adding -view-inheritance.

  - Doug



More information about the cfe-commits mailing list