mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 17:52:58 +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:
@@ -732,12 +732,10 @@ static auto GetAsCppFunctionDecl(Context& context, SemIR::InstId inst_id)
|
||||
if (!function_type) {
|
||||
return nullptr;
|
||||
}
|
||||
SemIR::ClangDeclId clang_decl_id = context.clang_decls().Lookup(
|
||||
const auto* clang_decl = context.clang_decls().Lookup(
|
||||
context.functions().Get(function_type->function_id).first_decl_id());
|
||||
return clang_decl_id.has_value()
|
||||
? dyn_cast<clang::FunctionDecl>(
|
||||
context.clang_decls().Get(clang_decl_id).key.decl)
|
||||
: nullptr;
|
||||
return clang_decl ? dyn_cast<clang::FunctionDecl>(clang_decl->decl())
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
auto IsCppOperatorMethod(Context& context, SemIR::InstId inst_id) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user