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:
Nicholas Bishop
2026-06-05 20:49:34 +00:00
committed by GitHub
parent 44b17ff436
commit 5e62791ad2
16 changed files with 70 additions and 95 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ static auto TypeAsTagDecl(Context& context,
return nullptr;
}
return dyn_cast<clang::TagDecl>(context.clang_decls().Get(decl_id).key.decl);
return dyn_cast<clang::TagDecl>(context.clang_decls().Get(decl_id).decl());
}
// If the given type is a C++ class type, returns the corresponding class