mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Implement support for copying C++ classes. (#6434)
When performing impl lookup for `Core.Copy` for a C++ class type, look for a copy constructor. If we find one, synthesize an impl witness that calls the constructor. This adds initial support for impl lookup to delegate to the C++ interop logic for queries involving C++ types. For now, we don't implement the rules from #6166 that compare a synthesized type structure for the C++ impl against the best Carbon type structure, but the framework for building that support is established here. Currently there is no caching of the lookup here, and we build unique `ImplWitnessTable`s for each lookup, which leads to each impl lookup producing a distinct facet value. This results in some errors in generic contexts; this will be addressed in follow-up changes. This PR aims only to support the non-generic case. --------- Co-authored-by: Dana Jansens <danakj@orodu.net> Co-authored-by: Carbon Infra Bot <carbon-external-infra@google.com>
This commit is contained in:
co-authored by
Dana Jansens
Carbon Infra Bot
parent
19660ccde0
commit
372f632d9d
@@ -40,6 +40,7 @@
|
||||
#include "toolchain/check/convert.h"
|
||||
#include "toolchain/check/cpp/access.h"
|
||||
#include "toolchain/check/cpp/custom_type_mapping.h"
|
||||
#include "toolchain/check/cpp/location.h"
|
||||
#include "toolchain/check/cpp/macros.h"
|
||||
#include "toolchain/check/cpp/thunk.h"
|
||||
#include "toolchain/check/diagnostic_helpers.h"
|
||||
@@ -1809,6 +1810,11 @@ static auto ImportFunctionDecl(Context& context, SemIR::LocId loc_id,
|
||||
function_info.SetHasCppThunk(thunk_function_decl_id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Inform Clang that the function has been referenced. This will trigger
|
||||
// instantiation if needed.
|
||||
context.clang_sema().MarkFunctionReferenced(GetCppLocation(context, loc_id),
|
||||
clang_decl);
|
||||
}
|
||||
|
||||
return function_info.first_owning_decl_id;
|
||||
|
||||
Reference in New Issue
Block a user