[PATCH] D133499: [clang]: Add DeclContext::dumpDecl() in order to conveniently dump an AST from a DeclContext.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 8 10:48:40 PDT 2022


erichkeane added inline comments.


================
Comment at: clang/lib/AST/ASTDumper.cpp:205
+  if (const Decl *D = dyn_cast<Decl>(this))
+    D->dump();
+}
----------------
aaron.ballman wrote:
> erichkeane wrote:
> > One thing to note is that the 'else' case here is a little uninformative.  See https://clang.llvm.org/doxygen/DeclBase_8cpp_source.html#l00915 for some similar logic here (though not sure we should be emulating that).
> > 
> > More, I wonder if there is SOME message here that should be dumped for 'else'.
> Looking at what inherits from `DeclContext`, is there use of it which is *not* a `Decl`? I couldn't find a use where it's not also a `Decl`.
I've DEFINITELY run into it in the debugger before, but I have no idea WHAT case that is. It is sometimes just "DeclContext is an invalid pointer" kinda thing, so it might be worth-while to have SOME output besides "print nothing", particularly when debugging.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133499/new/

https://reviews.llvm.org/D133499



More information about the cfe-commits mailing list