Add Check::Context::clang_sema() method and use it (#6110)

This replaces `sem_ir().clang_ast_unit()->getSema()`.
This commit is contained in:
Boaz Brickner
2025-09-22 19:11:06 +00:00
committed by GitHub
parent 87efd4cb0b
commit a73e259620
6 changed files with 11 additions and 17 deletions
+4 -9
View File
@@ -506,9 +506,7 @@ static auto GetDeclContext(Context& context, SemIR::NameScopeId scope_id)
static auto ClangLookup(Context& context, SemIR::NameScopeId scope_id,
clang::DeclarationName name)
-> std::optional<clang::LookupResult> {
clang::ASTUnit* ast = context.sem_ir().clang_ast_unit();
CARBON_CHECK(ast);
clang::Sema& sema = ast->getSema();
clang::Sema& sema = context.clang_sema();
// TODO: Map the LocId of the lookup to a clang SourceLocation and provide it
// here so that clang's diagnostics can point into the carbon code that uses
@@ -533,7 +531,7 @@ static auto ClangConstructorLookup(Context& context,
-> clang::DeclContextLookupResult {
const SemIR::NameScope& scope = context.name_scopes().Get(scope_id);
clang::Sema& sema = context.sem_ir().clang_ast_unit()->getSema();
clang::Sema& sema = context.clang_sema();
clang::Decl* decl =
context.clang_decls().Get(scope.clang_decl_context_id()).decl;
return sema.LookupConstructors(cast<clang::CXXRecordDecl>(decl));
@@ -578,11 +576,8 @@ static auto GetDeclarationName(Context& context, SemIR::NameId name_id)
return std::nullopt;
}
return clang::DeclarationName(context.sem_ir()
.clang_ast_unit()
->getSema()
.getPreprocessor()
.getIdentifierInfo(*name));
return clang::DeclarationName(
context.clang_sema().getPreprocessor().getIdentifierInfo(*name));
}
// Looks up the given name in the Clang AST in a specific scope. Returns the