call.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_CHECK_CPP_CALL_H_
  5. #define CARBON_TOOLCHAIN_CHECK_CPP_CALL_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/ids.h"
  8. namespace Carbon::Check {
  9. // Checks and builds SemIR for a call to a C++ function in the given overload
  10. // set with self `self_id` and arguments `arg_ids`.
  11. //
  12. // Chooses the best viable C++ function by performing Clang overloading
  13. // resolution over the overload set.
  14. //
  15. // Preserves the given self, if set. If not set, and the function is a C++
  16. // member operator, self will be set to the first argument, which in turn will
  17. // be removed from the given args.
  18. //
  19. // A set with a single non-templated function goes through the same rules for
  20. // overloading resolution. This is to make sure that calls that have no viable
  21. // implicit conversion sequence are rejected even when an implicit conversion is
  22. // possible. Keeping the same behavior here for consistency and supporting
  23. // migrations so that the migrated callers from C++ remain valid.
  24. auto PerformCallToCppFunction(Context& context, SemIR::LocId loc_id,
  25. SemIR::CppOverloadSetId overload_set_id,
  26. SemIR::InstId self_id,
  27. llvm::ArrayRef<SemIR::InstId> arg_ids)
  28. -> SemIR::InstId;
  29. } // namespace Carbon::Check
  30. #endif // CARBON_TOOLCHAIN_CHECK_CPP_CALL_H_