From d2fbbd3c7af3e97876a9dee8bf38a772f1eee749 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 29 Oct 2025 15:10:50 -0400 Subject: [PATCH] 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 --- toolchain/sem_ir/inst_fingerprinter.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/toolchain/sem_ir/inst_fingerprinter.cpp b/toolchain/sem_ir/inst_fingerprinter.cpp index a43a029b37f7..41760cdb3e93 100644 --- a/toolchain/sem_ir/inst_fingerprinter.cpp +++ b/toolchain/sem_ir/inst_fingerprinter.cpp @@ -14,6 +14,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StableHashing.h" #include "toolchain/base/fixed_size_value_store.h" +#include "toolchain/base/kind_switch.h" #include "toolchain/base/value_ids.h" #include "toolchain/sem_ir/cpp_overload_set.h" #include "toolchain/sem_ir/entity_with_params_base.h" @@ -416,10 +417,18 @@ struct Worklist { if (!std::holds_alternative(next)) { // Add the contents of the `next` instruction so they all contribute to // the `contents`. - if (auto* impl_id = std::get_if(&next)) { - Add(*impl_id); - } else if (auto* inst_block_id = std::get_if(&next)) { - Add(*inst_block_id); + CARBON_KIND_SWITCH(next) { + case CARBON_KIND(InstId _): + CARBON_FATAL("InstId is checked for above."); + case CARBON_KIND(ImplId impl_id): + Add(impl_id); + break; + case CARBON_KIND(InstBlockId inst_block_id): + Add(inst_block_id); + break; + case CARBON_KIND(CppOverloadSetId overload_set_id): + Add(overload_set_id); + break; } // If we didn't add any more work, then we have a fingerprint for the