mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:14:42 +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:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user