[cfe-dev] [Patch] DeclContext printer
Douglas Gregor
dgregor at apple.com
Mon Jan 12 15:33:36 PST 2009
Hello Zhongxing,
On Jan 10, 2009, at 7:09 AM, Zhongxing Xu wrote:
> Hi,
>
> Attached patch implements an initial framework of a
> DeclContextPrinter. It can print DeclContext and its Decls in
> indented format. An Example:
>
> $ cat 3.cpp
> class A {
> int a;
> void f();
> };
> void A::f() {
> a = 3;
> }
>
> $ clang -print-decl-contexts 3.cpp
> [translation unit] 0x9754d7c
> <typedef> __builtin_va_list
> [class] A 0x9753310
> <class> A 0x975ce20
> <field> a
> <c++ method> f
> <c++ ctor> A
> <c++ ctor> A
> <c++ method> operator=
> <c++ dtor> ~A
> [c++ method] f [[0x9753310]]
>
> Some comments: '<>' indicates a declaration, '[]' indicates a
> definition, '[[ ]]' displays the semantic DeclContext which is
> different from the lexical DeclContext.
>
> This visualization should be helpful for DeclContext debugging.
Yes, this will definitely be useful for debugging. Please go ahead and
commit!
- Doug
More information about the cfe-dev
mailing list