cpp_overload_set.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_SEM_IR_CPP_OVERLOAD_SET_H_
  5. #define CARBON_TOOLCHAIN_SEM_IR_CPP_OVERLOAD_SET_H_
  6. #include "clang/AST/Decl.h"
  7. #include "clang/AST/UnresolvedSet.h"
  8. #include "clang/Sema/Overload.h"
  9. #include "common/ostream.h"
  10. #include "toolchain/base/value_store.h"
  11. #include "toolchain/sem_ir/ids.h"
  12. namespace Carbon::SemIR {
  13. // An overloaded C++ function.
  14. struct CppOverloadSet : public Printable<CppOverloadSet> {
  15. // The function's name.
  16. NameId name_id;
  17. // The parent scope.
  18. NameScopeId parent_scope_id;
  19. // The naming class in the name lookup that found this overload set.
  20. clang::CXXRecordDecl* naming_class;
  21. // List of all named decls found at name lookup.
  22. // TODO: Find a good small size for the UnresolvedSet<size> or rework how we
  23. // store the candidates.
  24. clang::UnresolvedSet<4> candidate_functions;
  25. /// Information about operator rewrites to consider when adding operator
  26. /// functions to a candidate set.
  27. clang::OverloadCandidateSet::OperatorRewriteInfo operator_rewrite_info;
  28. auto Print(llvm::raw_ostream& out) const -> void {
  29. out << "name: " << name_id << ", parent_scope: " << parent_scope_id;
  30. }
  31. };
  32. using CppOverloadSetStore =
  33. ValueStore<CppOverloadSetId, CppOverloadSet, Tag<CheckIRId>>;
  34. } // namespace Carbon::SemIR
  35. #endif // CARBON_TOOLCHAIN_SEM_IR_CPP_OVERLOAD_SET_H_