overload_resolution.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 overloading resolution, or
  19. // returns an error instruction if overload resolution failed.
  20. //
  21. // A set with a single non-templated function goes through the same rules for
  22. // overloading resolution. This is to make sure that calls that have no viable
  23. // implicit conversion sequence are rejected even when an implicit conversion is
  24. // possible. Keeping the same behavior here for consistency and supporting
  25. // migrations so that the migrated callers from C++ remain valid.
  26. auto PerformCppOverloadResolution(Context& context, SemIR::LocId loc_id,
  27. SemIR::CppOverloadSetId overload_set_id,
  28. SemIR::InstId self_id,
  29. llvm::ArrayRef<SemIR::InstId> arg_ids)
  30. -> SemIR::InstId;
  31. } // namespace Carbon::Check
  32. #endif // CARBON_TOOLCHAIN_CHECK_CPP_OVERLOAD_RESOLUTION_H_