================
@@ -1397,28 +1440,73 @@ void Sema::ProcessAPINotes(Decl *D) {
auto Info = Reader->lookupCXXMethod(Context->id, MethodName);
ProcessVersionedAPINotes(*this, CXXMethod, Info);
- if (ParameterSelectorCandidates)
+ auto &DiagnosticState =
+ getAPINotesSelectorDiagnosticState(*this, Reader);
+ if (auto NameOnlyKey =
+ Reader->getCXXMethodSelectorKey(Context->id, MethodName))
+ DiagnosticState.noteSeenDeclaration(*NameOnlyKey, MethodName,
+ CXXMethod->getLocation());
+
+ 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);
}
+
+ if (CXXMethod->isImplicitObjectMemberFunction()) {
+ SmallVector<api_notes::FunctionObjectSelector, 7>
ObjectSelectors;
+ getAPINotesObjectSelectorSubsets(
+ getAPINotesObjectSelector(CXXMethod), ObjectSelectors);
+ // Apply every matching object selector in increasing
specificity.
+ // Wildcard object constraints are broad refinements. Selectors
+ // that also constrain explicit parameters are applied last.
+ for (api_notes::FunctionObjectSelector ObjectSelector :
+ ObjectSelectors) {
+ api_notes::FunctionSelector Selector;
+ Selector.Object = ObjectSelector;
+ auto ObjectInfo =
+ Reader->lookupCXXMethod(Context->id, MethodName, Selector);
+ ProcessVersionedAPINotes(*this, CXXMethod, ObjectInfo);
+ if (auto ObjectKey = Reader->getCXXMethodSelectorKey(
+ Context->id, MethodName, Selector))
+ DiagnosticState.markUsed(*ObjectKey);
+ }
+
+ if (ParameterSelectorCandidates) {
+ for (api_notes::FunctionObjectSelector ObjectSelector :
+ ObjectSelectors) {
+ processExactAPINotes<api_notes::CXXMethodInfo>(
----------------
Xazax-hun wrote:
Is it possible to somehow simplify this code by folding into the
```
Reader->getCXXMethodSelectorKey(
Context->id, MethodName, Parameters);
```
call above using a default argument? As in, if we had no `ObjectSelector`, we
would just pass an empty optional? I wonder if in general having more default
arguments and fewer overloads would simplify most call sites for these overload
sets.
https://github.com/llvm/llvm-project/pull/216148
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits