Skip to content

Commit 896ef4d

Browse files
authored
Include the Name when dumping an instruction with a name (#6051)
If the first argument is an EntityNameId, then dump the name from within it. In particular this affects dumping BindName and BindSymbolicName. ``` (lldb) dump context non_canonical_query_self_inst_id inst96: {kind: BindSymbolicName, arg0: entity_name4, arg1: inst<none>, type: type(symbolic_constant35)} - name: `T` - type: type(symbolic_constant35): I(.Self) where .Self.(I(.Self).X) = (); {kind: FacetType, arg0: facet_type4, type: type(TypeType)} - value: symbolic_constant36 - loc: LocId(<none>) ```
1 parent 3480554 commit 896ef4d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

toolchain/sem_ir/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ cc_library(
258258
deps = [
259259
":file",
260260
":stringify",
261+
":typed_insts",
261262
"//common:ostream",
262263
"//common:raw_string_ostream",
263264
],

toolchain/sem_ir/dump.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#include <string>
1010

1111
#include "common/raw_string_ostream.h"
12+
#include "toolchain/sem_ir/ids.h"
1213
#include "toolchain/sem_ir/stringify.h"
14+
#include "toolchain/sem_ir/typed_insts.h"
1315

1416
namespace Carbon::SemIR {
1517

@@ -214,6 +216,14 @@ LLVM_DUMP_METHOD auto Dump(const File& file, InstId inst_id) -> std::string {
214216
}
215217

216218
Inst inst = file.insts().Get(inst_id);
219+
220+
if (inst.arg0_and_kind().kind() == IdKind::For<SemIR::EntityNameId>) {
221+
auto entity_name_id = SemIR::EntityNameId(inst.arg0());
222+
out << "\n - name:"
223+
<< DumpNameIfValid(file,
224+
file.entity_names().Get(entity_name_id).name_id);
225+
}
226+
217227
if (inst.type_id().has_value()) {
218228
out << "\n - type: " << Dump(file, inst.type_id());
219229
}

0 commit comments

Comments
 (0)