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
+6 -5
View File
@@ -303,11 +303,12 @@ auto MaybeModifyCppThunkCallForConstEval(Context& context, SemIR::Call* call)
.GetAs<SemIR::FunctionDecl>(thunk_callee_inst_id)
.function_id);
function_decl =
cast<clang::FunctionDecl>(context.clang_decls()
.Get(thunk_callee_function.clang_decl_id)
.GetAsKey()
.decl);
function_decl = cast<clang::FunctionDecl>(
context.clang_decls()
.Get(context.clang_decls().Lookup(
thunk_callee_function.first_decl_id()))
.GetAsKey()
.decl);
if (!(function_decl->isConstexpr() || function_decl->isConsteval())) {
return;