overload_resolution.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_OVERLOAD_RESOLUTION_H_
  5. #define CARBON_TOOLCHAIN_CHECK_CPP_OVERLOAD_RESOLUTION_H_
  6. #include "toolchain/check/context.h"
  7. #include "toolchain/sem_ir/function.h"
  8. #include "toolchain/sem_ir/ids.h"
  9. namespace Carbon::Check {
  10. // Checks whether a selected overload is accessible and diagnoses if not.
  11. // `parent_scope_id`, if specified, describes the scope that was named to find
  12. // the overload. If unspecified, we assume the overload was found in the class
  13. // that it is a direct member of, rather than a derived class.
  14. auto CheckCppOverloadAccess(
  15. Context& context, SemIR::LocId loc_id, clang::DeclAccessPair overload,
  16. SemIR::KnownInstId<SemIR::FunctionDecl> overload_inst_id,
  17. SemIR::NameScopeId parent_scope_id = SemIR::NameScopeId::None) -> void;
  18. // Resolves which function to call using Clang overload resolution. Returns an
  19. // instruction referring to that function, or an error instruction if overload
  20. // resolution failed.
  21. //
  22. // A set with a single non-templated function goes through the same rules for
  23. // overload 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 PerformCppOverloadResolution(
  28. Context& context, SemIR::LocId loc_id,
  29. const SemIR::CppOverloadSet& overload_set,
  30. llvm::ArrayRef<SemIR::InstId> template_arg_ids, SemIR::InstId self_id,
  31. llvm::ArrayRef<SemIR::InstId> arg_ids) -> SemIR::InstId;
  32. } // namespace Carbon::Check
  33. #endif // CARBON_TOOLCHAIN_CHECK_CPP_OVERLOAD_RESOLUTION_H_