mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user