name_scope.h 818 B

12345678910111213141516171819202122232425262728
  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_NAME_SCOPE_H_
  5. #define CARBON_TOOLCHAIN_CHECK_NAME_SCOPE_H_
  6. #include <optional>
  7. #include "toolchain/check/context.h"
  8. #include "toolchain/sem_ir/ids.h"
  9. #include "toolchain/sem_ir/typed_insts.h"
  10. namespace Carbon::Check {
  11. struct ClassScope {
  12. SemIR::ClassDecl class_decl;
  13. SemIR::NameScope* name_scope;
  14. };
  15. // If the specified name scope corresponds to a class, returns the corresponding
  16. // class declaration.
  17. auto TryAsClassScope(Context& context, SemIR::NameScopeId scope_id)
  18. -> std::optional<ClassScope>;
  19. } // namespace Carbon::Check
  20. #endif // CARBON_TOOLCHAIN_CHECK_NAME_SCOPE_H_