Skip to content

Commit d2fbbd3

Browse files
danakjjonmeow
andauthored
Actually do fingerprinting for InstFingerprinter::GetOrCompute with a CppOverloadSet (#6296)
Currently we schedule work on the CppOverloadSet but then never `Add()` it to add its contents to be fingerprinted, and just immediately return an empty fingerprint. Use CARBON_KIND_SWITCH to prevent this sort of thing from happening in the future, now that we can use it for std::variant. --------- Co-authored-by: Jon Ross-Perkins <[email protected]>
1 parent a1fd86c commit d2fbbd3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

toolchain/sem_ir/inst_fingerprinter.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/ADT/SmallVector.h"
1515
#include "llvm/ADT/StableHashing.h"
1616
#include "toolchain/base/fixed_size_value_store.h"
17+
#include "toolchain/base/kind_switch.h"
1718
#include "toolchain/base/value_ids.h"
1819
#include "toolchain/sem_ir/cpp_overload_set.h"
1920
#include "toolchain/sem_ir/entity_with_params_base.h"
@@ -416,10 +417,18 @@ struct Worklist {
416417
if (!std::holds_alternative<InstId>(next)) {
417418
// Add the contents of the `next` instruction so they all contribute to
418419
// the `contents`.
419-
if (auto* impl_id = std::get_if<ImplId>(&next)) {
420-
Add(*impl_id);
421-
} else if (auto* inst_block_id = std::get_if<InstBlockId>(&next)) {
422-
Add(*inst_block_id);
420+
CARBON_KIND_SWITCH(next) {
421+
case CARBON_KIND(InstId _):
422+
CARBON_FATAL("InstId is checked for above.");
423+
case CARBON_KIND(ImplId impl_id):
424+
Add(impl_id);
425+
break;
426+
case CARBON_KIND(InstBlockId inst_block_id):
427+
Add(inst_block_id);
428+
break;
429+
case CARBON_KIND(CppOverloadSetId overload_set_id):
430+
Add(overload_set_id);
431+
break;
423432
}
424433

425434
// If we didn't add any more work, then we have a fingerprint for the

0 commit comments

Comments
 (0)