call.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. // Checks and builds SemIR for a call to a C++ template name with arguments
  30. // `arg_ids`.
  31. //
  32. // Converts the arguments to a C++ template argument list and attempts to
  33. // instantiate a template specialization and import a declaration of it.
  34. auto PerformCallToCppTemplateName(Context& context, SemIR::LocId loc_id,
  35. SemIR::ClangDeclId template_decl_id,
  36. llvm::ArrayRef<SemIR::InstId> arg_ids)
  37. -> SemIR::InstId;
  38. } // namespace Carbon::Check
  39. #endif // CARBON_TOOLCHAIN_CHECK_CPP_CALL_H_