From 5b48274e588d7c36bbda15fcfa2261c8b3c78567 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 14 Jul 2026 15:58:05 -0700 Subject: [PATCH] Add extern template declarations for ValueStore in inst.h and entity_name.h (#7507) Add extern template declarations and explicit template instantiations for ValueStore and ValueStore to prevent redundant template instantiations. Place them in their respective domain files (inst.h/cpp and entity_name.h/cpp) to maintain modularity. Assisted-by: Antigravity with Gemini --- toolchain/sem_ir/BUILD | 1 + toolchain/sem_ir/entity_name.cpp | 12 ++++++++++++ toolchain/sem_ir/entity_name.h | 5 +++++ toolchain/sem_ir/inst.cpp | 1 + toolchain/sem_ir/inst.h | 2 ++ 5 files changed, 21 insertions(+) create mode 100644 toolchain/sem_ir/entity_name.cpp diff --git a/toolchain/sem_ir/BUILD b/toolchain/sem_ir/BUILD index e4c1862e64bb..8b3102d5da2c 100644 --- a/toolchain/sem_ir/BUILD +++ b/toolchain/sem_ir/BUILD @@ -92,6 +92,7 @@ cc_library( "cpp_file.cpp", "cpp_initializer_list.cpp", "cpp_overload_set.cpp", + "entity_name.cpp", "facet_type_info.cpp", "field.cpp", "file.cpp", diff --git a/toolchain/sem_ir/entity_name.cpp b/toolchain/sem_ir/entity_name.cpp new file mode 100644 index 000000000000..6d6cc45a5955 --- /dev/null +++ b/toolchain/sem_ir/entity_name.cpp @@ -0,0 +1,12 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "toolchain/sem_ir/entity_name.h" + +#include "toolchain/base/value_store_impl.h" + +namespace Carbon { +template class ValueStore>; +} // namespace Carbon diff --git a/toolchain/sem_ir/entity_name.h b/toolchain/sem_ir/entity_name.h index 805ce41000b6..e80ca0d76130 100644 --- a/toolchain/sem_ir/entity_name.h +++ b/toolchain/sem_ir/entity_name.h @@ -142,4 +142,9 @@ inline auto EntityNameStore::MakeCanonical(EntityNameId id) -> EntityNameId { } // namespace Carbon::SemIR +namespace Carbon { +extern template class ValueStore>; +} // namespace Carbon + #endif // CARBON_TOOLCHAIN_SEM_IR_ENTITY_NAME_H_ diff --git a/toolchain/sem_ir/inst.cpp b/toolchain/sem_ir/inst.cpp index 59beb9aeb4ad..f4b3d0b19a91 100644 --- a/toolchain/sem_ir/inst.cpp +++ b/toolchain/sem_ir/inst.cpp @@ -169,4 +169,5 @@ template class ValueStore>; template class BlockValueStore>; +template class ValueStore>; } // namespace Carbon diff --git a/toolchain/sem_ir/inst.h b/toolchain/sem_ir/inst.h index b6af696b4103..dfb03f475399 100644 --- a/toolchain/sem_ir/inst.h +++ b/toolchain/sem_ir/inst.h @@ -718,6 +718,8 @@ extern template class ValueStore>; extern template class BlockValueStore>; +extern template class ValueStore>; } // namespace Carbon #endif // CARBON_TOOLCHAIN_SEM_IR_INST_H_