[clang] [APINotes] Add Where.Object selectors for C++ methods (PR #216148)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 7 04:52:17 PDT 2026


================
@@ -1397,27 +1429,56 @@ void Sema::ProcessAPINotes(Decl *D) {
             auto Info = Reader->lookupCXXMethod(Context->id, MethodName);
             ProcessVersionedAPINotes(*this, CXXMethod, Info);
 
-            if (ParameterSelectorCandidates)
-              processExactAPINotes<api_notes::CXXMethodInfo>(
-                  *this, CXXMethod, *ParameterSelectorCandidates,
-                  [&](ArrayRef<std::string> Parameters) {
-                    return Reader->lookupCXXMethod(Context->id, MethodName,
-                                                   Parameters);
-                  });
-
-            if (ParameterSelectorCandidates) {
-              auto &DiagnosticState =
-                  getAPINotesSelectorDiagnosticState(*this, Reader);
-              if (auto BroadKey =
-                      Reader->getCXXMethodSelectorKey(Context->id, MethodName))
-                DiagnosticState.noteSeenDeclaration(*BroadKey, MethodName,
-                                                    CXXMethod->getLocation());
-              DiagnosticState.markCandidatesUsed(
-                  [&](ArrayRef<std::string> Parameters) {
-                    return Reader->getCXXMethodSelectorKey(
-                        Context->id, MethodName, Parameters);
-                  },
-                  *ParameterSelectorCandidates);
+            auto &DiagnosticState =
+                getAPINotesSelectorDiagnosticState(*this, Reader);
+            if (auto NameOnlyKey =
+                    Reader->getCXXMethodSelectorKey(Context->id, MethodName))
+              DiagnosticState.noteSeenDeclaration(*NameOnlyKey, MethodName,
+                                                  CXXMethod->getLocation());
+
+            SmallVector<api_notes::FunctionSelector, 8> BaseSelectors;
+            BaseSelectors.emplace_back();
+            if (CXXMethod->isImplicitObjectMemberFunction()) {
+              SmallVector<api_notes::FunctionObjectSelector, 7> ObjectSelectors;
----------------
Xazax-hun wrote:

Is there any way to avoid building all possible subsets for the object selector and repeat the lookup for all of them? Could we instead make the lookup logic do the right thing? 

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


More information about the cfe-commits mailing list