Skip to content

Commit d0d2f18

Browse files
authored
Add unit tagging to CppOverloadSetId (#6212)
No update to lldbinit.py because we don't currently have dumping/debugging support for CppOverloadSetId anyway.
1 parent a0ef7e7 commit d0d2f18

File tree

5 files changed

+12
-3
lines changed

5 files changed

+12
-3
lines changed

toolchain/check/testdata/basics/raw_sem_ir/cpp_interop.carbon

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ fn G(x: Cpp.X) {
135135
// CHECK:STDOUT: inst60000022: {kind: CompleteTypeWitness, arg0: inst60000020, type: type(inst(WitnessType))}
136136
// CHECK:STDOUT: inst60000023: {kind: PointerType, arg0: inst60000020, type: type(TypeType)}
137137
// CHECK:STDOUT: inst60000024: {kind: NameRef, arg0: name0, arg1: inst60000010, type: type(inst(NamespaceType))}
138-
// CHECK:STDOUT: inst60000025: {kind: CppOverloadSetType, arg0: cpp_overload_set0, arg1: specific<none>, type: type(TypeType)}
139-
// CHECK:STDOUT: inst60000026: {kind: CppOverloadSetValue, arg0: cpp_overload_set0, type: type(inst60000025)}
140-
// CHECK:STDOUT: inst60000027: {kind: CppOverloadSetValue, arg0: cpp_overload_set0, type: type(inst60000025)}
138+
// CHECK:STDOUT: inst60000025: {kind: CppOverloadSetType, arg0: cpp_overload_set60000000, arg1: specific<none>, type: type(TypeType)}
139+
// CHECK:STDOUT: inst60000026: {kind: CppOverloadSetValue, arg0: cpp_overload_set60000000, type: type(inst60000025)}
140+
// CHECK:STDOUT: inst60000027: {kind: CppOverloadSetValue, arg0: cpp_overload_set60000000, type: type(inst60000025)}
141141
// CHECK:STDOUT: inst60000028: {kind: NameRef, arg0: name4, arg1: inst60000026, type: type(inst60000025)}
142142
// CHECK:STDOUT: inst60000029: {kind: FunctionDecl, arg0: function1, arg1: inst_block_empty, type: type(inst6000002A)}
143143
// CHECK:STDOUT: inst6000002A: {kind: FunctionType, arg0: function1, arg1: specific<none>, type: type(TypeType)}

toolchain/sem_ir/file.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ File::File(const Parse::Tree* parse_tree, CheckIRId check_ir_id,
3535
: LibraryNameId::Default),
3636
value_stores_(&value_stores),
3737
filename_(std::move(filename)),
38+
cpp_overload_sets_(IdTag(check_ir_id.index, 0)),
3839
classes_(IdTag(check_ir_id.index, 0)),
3940
associated_constants_(IdTag(check_ir_id.index, 0)),
4041
impls_(*this),

toolchain/sem_ir/ids.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ auto ConstantId::Print(llvm::raw_ostream& out, bool disambiguate) const
4242
}
4343
}
4444

45+
auto CppOverloadSetId::Print(llvm::raw_ostream& out) const -> void {
46+
IdBase::PrintHex(out);
47+
}
48+
4549
auto CheckIRId::Print(llvm::raw_ostream& out) const -> void {
4650
if (*this == Cpp) {
4751
out << Label << "(Cpp)";

toolchain/sem_ir/ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ struct CppOverloadSetId : public IdBase<CppOverloadSetId> {
276276
static constexpr llvm::StringLiteral Label = "cpp_overload_set";
277277

278278
using IdBase::IdBase;
279+
280+
auto Print(llvm::raw_ostream& out) const -> void;
279281
};
280282

281283
// The ID of a function.

toolchain/sem_ir/inst_namer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class InstNamer {
5353
auto index = id.index;
5454
if constexpr (std::is_same_v<IdT, ClassId>) {
5555
index = sem_ir_->classes().GetRawIndex(id);
56+
} else if constexpr (std::is_same_v<IdT, CppOverloadSetId>) {
57+
index = sem_ir_->cpp_overload_sets().GetRawIndex(id);
5658
} else if constexpr (std::is_same_v<IdT, AssociatedConstantId>) {
5759
index = sem_ir_->associated_constants().GetRawIndex(id);
5860
}

0 commit comments

Comments
 (0)