cpp_overload_resolution.h 1.5 KB

123456789101112131415161718192021222324252627282930313233
  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/ids.h"
  8. namespace Carbon::Check {
  9. // Performs overloading resolution for a call to an overloaded C++ set. A set
  10. // with a single non-templated function goes through the same rules for
  11. // overloading resolution. Uses Clang to find the best viable function for the
  12. // call. Returns the resolved function, or `nullopt` if overload resolution
  13. // failed.
  14. //
  15. // Note on non-overloaded functions: In C++, a single non-templated function is
  16. // also treated as an overloaded set and goes through the overload resolution to
  17. // ensure that the function is viable for the call. This is to make sure that
  18. // calls that have no viable implicit conversion sequence are rejected even when
  19. // an implicit conversion is possible. Keeping the same behavior here for
  20. // consistency and supporting migrations so that the migrated callers from C++
  21. // remain valid.
  22. auto PerformCppOverloadResolution(Context& context, SemIR::LocId loc_id,
  23. SemIR::CppOverloadSetId overload_set_id,
  24. llvm::ArrayRef<SemIR::InstId> arg_ids)
  25. -> std::optional<SemIR::InstId>;
  26. } // namespace Carbon::Check
  27. #endif // CARBON_TOOLCHAIN_CHECK_CPP_OVERLOAD_RESOLUTION_H_