Skip to content

Commit 5b5b7b6

Browse files
committed
review
1 parent 567d7a9 commit 5b5b7b6

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

scripts/lldbinit.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ def print_usage() -> None:
4444
Dumps the value of an associated ID, using the C++ Dump() functions.
4545
4646
Usage:
47-
dump <CONTEXT> [<EXPR>|-- <EXPR>|<TYPE><ID>|<IR>.<TYPE><ID>]
47+
dump <CONTEXT> [<EXPR>|-- <EXPR>|[<IR>.]<TYPE><ID>]
4848
4949
Args:
5050
CONTEXT is the dump context, such a SemIR::Context reference, a SemIR::File,
5151
a Parse::Context, or a Lex::TokenizeBuffer.
5252
EXPR is a C++ expression such as a variable name. Use `--` to prevent it from
5353
being treated as a TYPE and ID.
54-
IR is the CheckIRId(N) in the form `irN`.
54+
IR is the CheckIRId(N) in the form `irN`. Not all ID types have an `ir`
55+
prefix, the ones which do are dumped with that prefix, such as for
56+
InstId as `ir1.inst2`.
5557
TYPE can be `inst`, `constant`, `generic`, `impl`, `entity_name`, etc. See
5658
the `Label` string in `IdBase` classes to find possible TYPE names,
5759
though only Id types that have a matching `Make...Id()` function are
@@ -76,7 +78,7 @@ def print_usage() -> None:
7678
context = args[0]
7779

7880
# The set of "Make" functions in dump.cpp. These use ADL to find the factory
79-
# function in `context/` or in `sem_ir/`.
81+
# function in `check/` or in `sem_ir/`.
8082
id_types = {
8183
"inst": "MakeInstId",
8284
}

toolchain/check/dump.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@
1111
// - lldb: `expr Dump(context, id)`
1212
// - gdb: `call Dump(context, id)`
1313

14-
#include "toolchain/sem_ir/ids.h"
1514
#ifndef NDEBUG
1615

16+
#include "toolchain/lex/dump.h"
17+
1718
#include <string>
1819

1920
#include "common/check.h"
2021
#include "common/raw_string_ostream.h"
2122
#include "toolchain/check/context.h"
22-
#include "toolchain/lex/dump.h"
2323
#include "toolchain/lex/tokenized_buffer.h"
2424
#include "toolchain/parse/dump.h"
2525
#include "toolchain/parse/tree.h"
2626
#include "toolchain/sem_ir/dump.h"
2727
#include "toolchain/sem_ir/file.h"
28+
#include "toolchain/sem_ir/ids.h"
2829

2930
namespace Carbon::Check {
3031

toolchain/sem_ir/dump.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,12 @@ LLVM_DUMP_METHOD static auto MakeInstBlockId(int id) -> InstBlockId {
454454
}
455455
LLVM_DUMP_METHOD auto MakeInstId(const SemIR::File& file, int check_ir_id,
456456
int id) -> InstId {
457-
CARBON_CHECK(file.check_ir_id() == SemIR::CheckIRId(check_ir_id),
458-
"SemIR::MakeInstId given a CheckIRId for the wrong SemIR::File. "
459-
"Maybe you want to dump from a Check::Context.");
457+
if (file.check_ir_id() != SemIR::CheckIRId(check_ir_id)) {
458+
llvm::errs()
459+
<< "SemIR::MakeInstId given a CheckIRId for the wrong SemIR::File. "
460+
"Maybe you want to dump from a Check::Context.\n";
461+
return SemIR::InstId::None;
462+
}
460463
return InstId(file.insts().GetIdTag().Apply(id));
461464
}
462465
LLVM_DUMP_METHOD static auto MakeInterfaceId(int id) -> InterfaceId {

0 commit comments

Comments
 (0)