Move the mapping from entity name to an imported C++ global variable declaration outside of EntityName (#6211)

This would save space for every `EntityName` that is not an imported C++
global variable.
C++ global variables include static data members.
Created `CppGlobalVarId`, `CppGlobalVarKey` and `CppGlobalVar` to allow
having `CanonicalValueStore` that maps `EntityNameId` (which is in
`CppGlobalVarKey` and `CppGlobalVar`) to `ClangDeclId` (which is also in
`CppGlobalVar`).
This is similar to `ClangDeclId`, `ClangDeclKey` and `ClangDecl` .
This commit is contained in:
Boaz Brickner
2025-10-15 13:33:32 +00:00
committed by GitHub
parent 3fa427b811
commit ffefa7711c
18 changed files with 354 additions and 191 deletions
+3 -1
View File
@@ -1853,7 +1853,9 @@ static auto ImportVarDecl(Context& context, SemIR::LocId loc_id,
SemIR::EntityNameId entity_name_id =
context.entity_names().AddSymbolicBindingName(
var_name_id, GetParentNameScopeId(context, var_decl),
SemIR::CompileTimeBindIndex::None, false, clang_decl_id);
SemIR::CompileTimeBindIndex::None, false);
context.cpp_global_names().Add({.key = {.entity_name_id = entity_name_id},
.clang_decl_id = clang_decl_id});
// Create `BindingPattern` and `VarPattern` in a `NameBindingDecl`.
context.pattern_block_stack().Push();