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
+8 -3
View File
@@ -3452,9 +3452,14 @@ static auto TryEvalCall(EvalContext& outer_eval_context, SemIR::LocId loc_id,
const SemIR::Function& function,
SemIR::SpecificId specific_id,
SemIR::InstBlockId args_id) -> SemIR::ConstantId {
if (function.clang_decl_id != SemIR::ClangDeclId::None) {
return EvalCppCall(outer_eval_context.context(), loc_id,
function.clang_decl_id, args_id);
auto clang_decl_id = outer_eval_context.sem_ir().clang_decls().Lookup(
function.first_decl_id());
if (clang_decl_id.has_value() && outer_eval_context.sem_ir()
.clang_decls()
.Get(clang_decl_id)
.is_imported) {
return EvalCppCall(outer_eval_context.context(), loc_id, clang_decl_id,
args_id);
} else if (function.body_block_ids.empty()) {
// TODO: Diagnose this.
return SemIR::ConstantId::NotConstant;