[clang] [APINotes] Diagnose invalid Where.Parameters selectors (PR #209408)
John Hui via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 27 00:27:41 PDT 2026
================
@@ -1374,3 +1450,33 @@ void Sema::ProcessAPINotes(Decl *D) {
}
}
}
+
+void APINotesSelectorDiagnosticReaderState::diagnoseUnused(Sema &S) const {
+ for (const auto &Selector : Selectors) {
+ if (Selector.Used)
+ continue;
+
+ auto SeenName = SeenNames.find(Selector.BroadKey);
+ if (SeenName == SeenNames.end())
+ continue;
+
+ S.Diag(SeenName->second.Loc, diag::warn_apinotes_message)
+ << (llvm::Twine("API notes entry for '") + SeenName->second.Name +
+ "' has unmatched Where.Parameters " +
+ api_notes::formatAPINotesParameterSelector(Selector.Parameters))
+ .str();
+ }
+}
+
+void APINotesSelectorDiagnosticState::diagnoseUnused(Sema &S) const {
----------------
j-hui wrote:
I wonder if this definition should be inlined at the declaration site, given how simple it is?
I don't feel strongly about this, though, and am fine with this here for consistency with `APINotesSelectorDiagnosticReaderState::diagnoseUnused`.
https://github.com/llvm/llvm-project/pull/209408
More information about the cfe-commits
mailing list