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 authored and GitHub committed 2026-06-05 20:49:34 +00:00
1 parent 44b17ff436
commit 5e62791ad2
16 files changed
+70 -95

No files matched your search

+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