call.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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`. `is_operator_syntax`
  11. // indicates that this call was generated from an operator rather than from
  12. // function call syntax, so arguments to `ref` parameters aren't required to
  13. // have `ref` tags.
  14. //
  15. // Chooses the best viable C++ function by performing Clang overloading
  16. // resolution over the overload set.
  17. //
  18. // Preserves the given self, if set. If not set, and the function is a C++
  19. // member operator, self will be set to the first argument, which in turn will
  20. // be removed from the given args.
  21. //
  22. // A set with a single non-templated function goes through the same rules for
  23. // overloading resolution. This is to make sure that calls that have no viable
  24. // implicit conversion sequence are rejected even when an implicit conversion is
  25. // possible. Keeping the same behavior here for consistency and supporting
  26. // migrations so that the migrated callers from C++ remain valid.
  27. auto PerformCallToCppFunction(Context& context, SemIR::LocId loc_id,
  28. SemIR::CppOverloadSetId overload_set_id,
  29. SemIR::InstId self_id,
  30. llvm::ArrayRef<SemIR::InstId> arg_ids,
  31. bool is_operator_syntax) -> SemIR::InstId;
  32. // Checks and builds SemIR for a call to a C++ template name with arguments
  33. // `arg_ids`.
  34. //
  35. // Converts the arguments to a C++ template argument list and attempts to
  36. // instantiate a template specialization and import a declaration of it.
  37. auto PerformCallToCppTemplateName(Context& context, SemIR::LocId loc_id,
  38. SemIR::ClangDeclId template_decl_id,
  39. llvm::ArrayRef<SemIR::InstId> arg_ids)
  40. -> SemIR::InstId;
  41. } // namespace Carbon::Check
  42. #endif // CARBON_TOOLCHAIN_CHECK_CPP_CALL_H_