Use clang_decls as the source of truth for function interop mapping (#7303)

Removing the clang_decl_id on SemIR::Function - using only the
clang_decls map to create the association between SemIR::Function and
clang::FunctionDecls.

This adds an `is_external` flag to ClangDecl to indicate whether the
entity originated from Carbon or was imported from another language.
(I'm open to names - I guess for now we mostly use "is this from C++" to
be more specific than "is this external" - eg: NameScope::is_cpp_scope)
This commit is contained in:
David Blaikie
2026-06-04 23:16:11 +00:00
committed by GitHub
parent b6774ab4c8
commit 2d87bb02d9
12 changed files with 87 additions and 47 deletions
+2 -2
View File
@@ -732,8 +732,8 @@ static auto GetAsCppFunctionDecl(Context& context, SemIR::InstId inst_id)
if (!function_type) {
return nullptr;
}
SemIR::ClangDeclId clang_decl_id =
context.functions().Get(function_type->function_id).clang_decl_id;
SemIR::ClangDeclId clang_decl_id = context.clang_decls().Lookup(
context.functions().Get(function_type->function_id).first_decl_id());
return clang_decl_id.has_value()
? dyn_cast<clang::FunctionDecl>(
context.clang_decls().Get(clang_decl_id).key.decl)