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
+3 -2
View File
@@ -448,9 +448,10 @@ auto CarbonExternalASTSource::GetOrExportFunctionToCpp(
SemIR::InstId target_inst_id, SemIR::FunctionId function_id)
-> clang::FunctionDecl* {
const SemIR::Function& function = context_->functions().Get(function_id);
if (function.clang_decl_id.has_value()) {
auto clang_decl_id = context_->clang_decls().Lookup(function.first_decl_id());
if (clang_decl_id.has_value()) {
return cast<clang::FunctionDecl>(
context_->clang_decls().Get(function.clang_decl_id).key.decl);
context_->clang_decls().Get(clang_decl_id).key.decl);
}
return ExportFunctionToCpp(*context_, SemIR::LocId(target_inst_id),