[all-commits] [llvm/llvm-project] 4247cd: [clang]: Add DeclContext::dumpAsDecl().
Tom Honermann via All-commits
all-commits at lists.llvm.org
Mon Oct 3 14:26:18 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4247cdb568eca4c31b14d91105fe5ee140225036
https://github.com/llvm/llvm-project/commit/4247cdb568eca4c31b14d91105fe5ee140225036
Author: Tom Honermann <tom.honermann at intel.com>
Date: 2022-10-03 (Mon, 03 Oct 2022)
Changed paths:
M clang/include/clang/AST/ASTDumper.h
M clang/include/clang/AST/DeclBase.h
M clang/lib/AST/ASTDumper.cpp
M clang/lib/AST/DeclBase.cpp
Log Message:
-----------
[clang]: Add DeclContext::dumpAsDecl().
This change enables a declaration to be conveniently displayed within
a debugger when only a pointer to its DeclContext is available. For example,
in gdb:
(gdb) p Ctx
$1 = (const clang::DeclContext *) 0x14c1a580
(gdb) p Ctx->dumpAsDecl()
ClassTemplateSpecializationDecl 0x14c1a540 <t.cpp:1:1, line:7:1> line:2:8 struct ct
`-TemplateArgument type 'int'
`-BuiltinType 0x14bac420 'int'
$2 = void
In the event that the pointed to DeclContext is invalid (that it has an
invalid DeclKind as a result of a dangling pointer, memory corruption, etc...)
it is not possible to dump its associated declaration. In this case, the
DeclContext will be reported as invalid. For example, in gdb:
(gdb) p Ctx->dumpAsDecl()
DeclContext 0x14c1a580 <unrecognized Decl kind 127>
$3 = void
More information about the All-commits
mailing list