[clang] [APINotes] Diagnose invalid Where.Parameters selectors (PR #209408)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 20 07:30:29 PDT 2026
================
@@ -1072,6 +1110,56 @@ getAPINotesParameterSelectorCandidates(const Sema &S, const FunctionDecl *FD) {
return Candidates;
}
+static void collectOverloadParameterSelectors(const Sema &S, FunctionDecl *FD,
+ APINotesParameterSelectorSet &Set,
+ bool &IsRepresentative) {
+ IsRepresentative = false;
+ bool FoundRepresentative = false;
+
+ auto AddCandidate = [&](const FunctionDecl *Candidate) {
+ if (!FoundRepresentative) {
+ IsRepresentative =
+ Candidate->getCanonicalDecl() == FD->getCanonicalDecl();
+ FoundRepresentative = true;
+ }
+
+ if (auto Candidates = getAPINotesParameterSelectorCandidates(S, Candidate))
+ Set.add(*Candidates);
+ };
+
+ for (Decl *D : FD->getDeclContext()->noload_decls()) {
----------------
Xazax-hun wrote:
I am a bit anxious about enumerating all the declarations here. This can get quadratic really easily as we enumerate all declarations each time we process a new function declaration. It would be nice if we were able to solve the problem without this.
Would it be possible to keep some state around whenever a selector was matched and only detect unmatched selectors as a last step once we finished processing a TU and some selectors are unused?
https://github.com/llvm/llvm-project/pull/209408
More information about the cfe-commits
mailing list