mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Improve ClangDeclStore ergonomics (#7311)
Change `Lookup` by InstId to return a ClangDecl pointer. All callers were immediately calling `Get` anyway, so this makes call sites a little shorter. The other `Lookup` method, by ClangDeclKey, is sometimes called without calling `Get`, so left that as-is, but renamed to `LookupId`. Also add a `decl` method to ClangDecl so that the commonly repeated `clang_decl->key.decl` can be written `clang_decl->decl()`.
This commit is contained in:
@@ -140,7 +140,7 @@ static auto ConvertArgToTemplateArg(
|
||||
context.types().TryGetAs<SemIR::CppTemplateNameType>(
|
||||
inst.type_id())) {
|
||||
clang::TemplateName name(cast<clang::TemplateDecl>(
|
||||
context.clang_decls().Get(template_name_type->decl_id).key.decl));
|
||||
context.clang_decls().Get(template_name_type->decl_id).decl()));
|
||||
return clang::TemplateArgumentLoc(
|
||||
context.ast_context(), clang::TemplateArgument(name),
|
||||
/*TemplateKWLoc=*/clang::SourceLocation(),
|
||||
@@ -346,7 +346,7 @@ auto PerformCallToCppTemplateName(Context& context, SemIR::LocId loc_id,
|
||||
llvm::ArrayRef<SemIR::InstId> arg_ids)
|
||||
-> SemIR::InstId {
|
||||
auto* template_decl = dyn_cast<clang::TemplateDecl>(
|
||||
context.clang_decls().Get(template_decl_id).key.decl);
|
||||
context.clang_decls().Get(template_decl_id).decl());
|
||||
auto loc = GetCppLocation(context, loc_id);
|
||||
|
||||
// Form a template argument list for this template.
|
||||
|
||||
Reference in New Issue
Block a user