[clang] [APINotes] Diagnose invalid Where.Parameters selectors (PR #209408)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 21 06:39:34 PDT 2026


StoeckOverflow wrote:

Thanks, I reworked this to avoid the repeated declaration-context scan.

Instead of walking `noload_decls()` each time a function declaration is processed, Sema now keeps diagnostic state separately for each `APINotesReader`. The reader enumerates stored exact `Where.Parameters` selectors once, `ProcessAPINotes` marks matching selector candidates as used while declarations are processed, and `ActOnEndOfTranslationUnit` emits warnings for selectors that were seen by function/method name but never matched by an exact parameter selector.

I also changed the identifier reverse lookup to build a lazy ID-to-string cache from the identifier table’s `keys()` / `data()` iterators, so we avoid doing a lookup for each identifier while reconstructing the stored `Where.Parameters` strings used in diagnostics. The cache-building comment now documents that this is a one-time linear operation and depends on the iterators walking the same serialized entries in lockstep.

https://github.com/llvm/llvm-project/pull/209408


More information about the cfe-commits mailing list