mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:31:03 +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:
@@ -245,11 +245,17 @@ struct CalleeFunctionInfo {
|
||||
|
||||
auto IsCppThunkRequired(Context& context, const SemIR::Function& function)
|
||||
-> bool {
|
||||
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 false;
|
||||
}
|
||||
|
||||
const auto& decl_info = context.clang_decls().Get(clang_decl_id);
|
||||
|
||||
if (!decl_info.is_imported) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& decl_info = context.clang_decls().Get(function.clang_decl_id);
|
||||
const auto& signature =
|
||||
context.clang_decl_signatures().Get(decl_info.key.signature_id);
|
||||
auto* decl = cast<clang::FunctionDecl>(decl_info.key.decl);
|
||||
@@ -646,7 +652,9 @@ static auto BuildThunkBody(CppContext& cpp_context, clang::Sema& sema,
|
||||
auto BuildCppThunk(Context& context, const SemIR::Function& callee_function)
|
||||
-> clang::FunctionDecl* {
|
||||
auto clang_decl_key =
|
||||
context.clang_decls().Get(callee_function.clang_decl_id).key;
|
||||
context.clang_decls()
|
||||
.Get(context.clang_decls().Lookup(callee_function.first_decl_id()))
|
||||
.key;
|
||||
clang::FunctionDecl* callee_function_decl =
|
||||
clang_decl_key.decl->getAsFunction();
|
||||
CARBON_CHECK(callee_function_decl);
|
||||
|
||||
Reference in New Issue
Block a user