mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Propagate location to CppOverloadSetValue instructions (#6317)
Part of #5915.
This commit is contained in:
@@ -2144,8 +2144,9 @@ static auto LookupBuiltinTypes(Context& context, SemIR::LocId loc_id,
|
||||
}
|
||||
|
||||
auto ImportCppOverloadSet(
|
||||
Context& context, SemIR::NameScopeId scope_id, SemIR::NameId name_id,
|
||||
clang::CXXRecordDecl* naming_class, clang::UnresolvedSet<4>&& overload_set,
|
||||
Context& context, SemIR::LocId loc_id, SemIR::NameScopeId scope_id,
|
||||
SemIR::NameId name_id, clang::CXXRecordDecl* naming_class,
|
||||
clang::UnresolvedSet<4>&& overload_set,
|
||||
clang::OverloadCandidateSet::OperatorRewriteInfo operator_rewrite_info)
|
||||
-> SemIR::InstId {
|
||||
SemIR::CppOverloadSetId overload_set_id = context.cpp_overload_sets().Add(
|
||||
@@ -2154,14 +2155,11 @@ auto ImportCppOverloadSet(
|
||||
.naming_class = naming_class,
|
||||
.candidate_functions = std::move(overload_set),
|
||||
.operator_rewrite_info = operator_rewrite_info});
|
||||
|
||||
auto overload_set_inst_id =
|
||||
// TODO: Add a location.
|
||||
AddInstInNoBlock<SemIR::CppOverloadSetValue>(
|
||||
context, Parse::NodeId::None,
|
||||
{.type_id = GetCppOverloadSetType(context, overload_set_id,
|
||||
SemIR::SpecificId::None),
|
||||
.overload_set_id = overload_set_id});
|
||||
auto overload_set_inst_id = AddInstInNoBlock<SemIR::CppOverloadSetValue>(
|
||||
context, loc_id,
|
||||
{.type_id = GetCppOverloadSetType(context, overload_set_id,
|
||||
SemIR::SpecificId::None),
|
||||
.overload_set_id = overload_set_id});
|
||||
|
||||
context.imports().push_back(overload_set_inst_id);
|
||||
return overload_set_inst_id;
|
||||
@@ -2184,7 +2182,7 @@ static auto GetOverloadSetAccess(const clang::UnresolvedSet<4>& overload_set)
|
||||
|
||||
// Imports an overload set from Clang to Carbon and adds the name into the
|
||||
// `NameScope`.
|
||||
static auto ImportOverloadSetIntoScope(Context& context,
|
||||
static auto ImportOverloadSetIntoScope(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::NameScopeId scope_id,
|
||||
SemIR::NameId name_id,
|
||||
clang::CXXRecordDecl* naming_class,
|
||||
@@ -2192,7 +2190,7 @@ static auto ImportOverloadSetIntoScope(Context& context,
|
||||
-> SemIR::ScopeLookupResult {
|
||||
SemIR::AccessKind access_kind = GetOverloadSetAccess(overload_set);
|
||||
SemIR::InstId inst_id = ImportCppOverloadSet(
|
||||
context, scope_id, name_id, naming_class, std::move(overload_set),
|
||||
context, loc_id, scope_id, name_id, naming_class, std::move(overload_set),
|
||||
/*operator_rewrite_info=*/{});
|
||||
AddNameToScope(context, scope_id, name_id, access_kind, inst_id);
|
||||
return SemIR::ScopeLookupResult::MakeWrappedLookupResult(inst_id,
|
||||
@@ -2202,7 +2200,7 @@ static auto ImportOverloadSetIntoScope(Context& context,
|
||||
// Imports the constructors for a given class name. The found constructors are
|
||||
// imported as part of an overload set into the scope. Currently copy/move
|
||||
// constructors are not imported.
|
||||
static auto ImportConstructorsIntoScope(Context& context,
|
||||
static auto ImportConstructorsIntoScope(Context& context, SemIR::LocId loc_id,
|
||||
SemIR::NameScopeId scope_id,
|
||||
SemIR::NameId name_id)
|
||||
-> SemIR::ScopeLookupResult {
|
||||
@@ -2223,8 +2221,8 @@ static auto ImportConstructorsIntoScope(Context& context,
|
||||
return SemIR::ScopeLookupResult::MakeNotFound();
|
||||
}
|
||||
|
||||
return ImportOverloadSetIntoScope(context, scope_id, name_id, naming_class,
|
||||
std::move(overload_set));
|
||||
return ImportOverloadSetIntoScope(context, loc_id, scope_id, name_id,
|
||||
naming_class, std::move(overload_set));
|
||||
}
|
||||
|
||||
// Imports a builtin type from Clang to Carbon and adds the name into the
|
||||
@@ -2278,7 +2276,7 @@ auto ImportNameFromCpp(Context& context, SemIR::LocId loc_id,
|
||||
lookup->getFoundDecl()->isFunctionOrFunctionTemplate())) {
|
||||
clang::UnresolvedSet<4> overload_set;
|
||||
overload_set.append(lookup->begin(), lookup->end());
|
||||
return ImportOverloadSetIntoScope(context, scope_id, name_id,
|
||||
return ImportOverloadSetIntoScope(context, loc_id, scope_id, name_id,
|
||||
lookup->getNamingClass(),
|
||||
std::move(overload_set));
|
||||
}
|
||||
@@ -2296,7 +2294,7 @@ auto ImportNameFromCpp(Context& context, SemIR::LocId loc_id,
|
||||
}
|
||||
if (IsDeclInjectedClassName(context, scope_id, name_id,
|
||||
lookup->getFoundDecl())) {
|
||||
return ImportConstructorsIntoScope(context, scope_id, name_id);
|
||||
return ImportConstructorsIntoScope(context, loc_id, scope_id, name_id);
|
||||
}
|
||||
auto key = SemIR::ClangDeclKey::ForNonFunctionDecl(lookup->getFoundDecl());
|
||||
return ImportNameDeclIntoScope(context, loc_id, scope_id, name_id, key,
|
||||
|
||||
Reference in New Issue
Block a user