cpp_overload_resolution.h 1.5 KB

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