mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Don't form a bound method when calling a C++ operator. (#7345)
Because we now support calling a function with a `self` parameter directly, we can unconditionally call `operator$(lhs, rhs)` rather than calling `lhs.operator$(rhs)` if the selected operator function happens to be a member function. This makes the logic a bit simpler and the SemIR a bit smaller. We can't do the same for Carbon operators, unfortunately, as we use the member access to trigger impl lookup.
This commit is contained in:
@@ -738,11 +738,6 @@ static auto GetAsCppFunctionDecl(Context& context, SemIR::InstId inst_id)
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
auto IsCppOperatorMethod(Context& context, SemIR::InstId inst_id) -> bool {
|
||||
auto* function_decl = GetAsCppFunctionDecl(context, inst_id);
|
||||
return function_decl && IsCppOperatorMethodDecl(function_decl);
|
||||
}
|
||||
|
||||
auto IsCppConstructorOrNonMethod(Context& context, SemIR::InstId inst_id)
|
||||
-> bool {
|
||||
auto* function_decl = GetAsCppFunctionDecl(context, inst_id);
|
||||
|
||||
@@ -30,11 +30,6 @@ auto LookupCppOperator(Context& context, SemIR::LocId loc_id, Operator op,
|
||||
// Returns whether the decl is an operator member function.
|
||||
auto IsCppOperatorMethodDecl(clang::Decl* decl) -> bool;
|
||||
|
||||
// Returns whether the specified instruction refers to a C++ overloaded operator
|
||||
// that is a method. If so, the first operand will be passed as `self` rather
|
||||
// than as the first argument.
|
||||
auto IsCppOperatorMethod(Context& context, SemIR::InstId inst_id) -> bool;
|
||||
|
||||
// Returns whether the specified instruction refers to a C++ constructor or
|
||||
// non-operator method. If so, when mapping from a Carbon interface to a C++
|
||||
// call, we pass a `self` parameter as the first argument instead.
|
||||
|
||||
Reference in New Issue
Block a user