Repository: carbon-language/carbon-lang
File: toolchain/sem_ir/function.h (C/C++)

Code before:
    special_function_kind_data = AnyRawId(kind.AsInt());
  }

  // Sets that this function is a thunk.
  auto SetThunk(InstId decl_id) -> void {
    CARBON_CHECK(special_function_kind == SpecialFunctionKind::None);
    special_function_kind = SpecialFunctionKind::Thunk;
    special_function_kind_data = AnyRawId(decl_id.index);
  }

  // Sets that this function is a C++ function that should be called using a C++
  // thunk.
  auto SetHasCppThunk(InstId decl_id) -> void {
    CARBON_CHECK(special_function_kind == SpecialFunctionKind::None);
    special_function_kind = SpecialFunctionKind::HasCppThunk;
    special_function_kind_data = AnyRawId(decl_id.index);
  }
};

using FunctionStore = ValueStore<FunctionId, Function>;

class File;

struct CalleeFunction : public Printable<CalleeFunction> {
  // This is a C++ overload set.
  struct CppOverload {
    // The overload set.
    CppOverloadSetId cpp_overload_set_id;
    // The bound `self` parameter. `None` if not a method.
    InstId self_id;
  };

  // An error instruction was found.
  struct Error {};

  // This is a function.
  struct Function {
    // The function.
    FunctionId function_id;
    // The specific that contains the function.
    SpecificId enclosing_specific_id;
    // The specific for the callee itself, in a resolved call.
    SpecificId resolved_specific_id;
    // The bound `Self` type or facet value. `None` if not a bound interface
    // member.
    InstId self_type_id;
    // The bound `self` parameter. `None` if not a method.
    InstId self_id;
  };

  // This is a generic entity, not a function.

Review comment (suggestion):
```suggestion
  struct CppOverloadSet {
```
This represents an overload set, not a single overload.

Code after:
    special_function_kind_data = AnyRawId(kind.AsInt());
  }

  // Sets that this function is a thunk.
  auto SetThunk(InstId decl_id) -> void {
    CARBON_CHECK(special_function_kind == SpecialFunctionKind::None);
    special_function_kind = SpecialFunctionKind::Thunk;
    special_function_kind_data = AnyRawId(decl_id.index);
  }

  // Sets that this function is a C++ function that should be called using a C++
  // thunk.
  auto SetHasCppThunk(InstId decl_id) -> void {
    CARBON_CHECK(special_function_kind == SpecialFunctionKind::None);
    special_function_kind = SpecialFunctionKind::HasCppThunk;
    special_function_kind_data = AnyRawId(decl_id.index);
  }
};

using FunctionStore = ValueStore<FunctionId, Function>;

class File;

struct CalleeFunction : public Printable<CalleeFunction> {
  // This is a C++ overload set.
  struct CppOverloadSet {
    // The overload set.
    CppOverloadSetId cpp_overload_set_id;
    // The bound `self` parameter. `None` if not a method.
    InstId self_id;
  };

  // An error instruction was found.
  struct Error {};

  // This is a function.
  struct Function {
    // The function.
    FunctionId function_id;
    // The specific that contains the function.
    SpecificId enclosing_specific_id;
    // The specific for the callee itself, in a resolved call.
    SpecificId resolved_specific_id;
    // The bound `Self` type or facet value. `None` if not a bound interface
    // member.
    InstId self_type_id;
    // The bound `self` parameter. `None` if not a method.
    InstId self_id;
  };

  // This may be a generic type, or could be an invalid callee.