================
@@ -1072,6 +1073,69 @@ getAPINotesParameterSelectorCandidates(const Sema &S,
const FunctionDecl *FD) {
return Candidates;
}
+static api_notes::APINotesFunctionSelectorKey
+getBroadAPINotesSelectorKey(api_notes::APINotesFunctionSelectorKey Key) {
+ Key.ParameterTypeIDs = std::nullopt;
+ return Key;
+}
+
+static APINotesSelectorDiagnosticReaderState &
+getAPINotesSelectorDiagnosticState(Sema &S, api_notes::APINotesReader *Reader)
{
+ if (!S.APINotesSelectorDiagnostics)
+ S.APINotesSelectorDiagnostics =
+ std::make_unique<APINotesSelectorDiagnosticState>();
+ auto &State = S.APINotesSelectorDiagnostics->Readers[Reader];
+ if (State.Initialized)
+ return State;
+
+ State.Initialized = true;
+ SmallVector<api_notes::APINotesFunctionSelector, 4> Selectors;
+ if (!Reader->collectExactFunctionParameterSelectors(Selectors))
+ return State;
+
+ State.Selectors.reserve(Selectors.size());
+ State.SelectorIndices.reserve(Selectors.size());
+ State.SeenNames.reserve(Selectors.size());
+ for (auto &Selector : Selectors) {
+ unsigned Index = State.Selectors.size();
+ APINotesSelectorDiagnosticEntry Entry;
+ Entry.BroadKey = getBroadAPINotesSelectorKey(Selector.Key);
+ Entry.Parameters = std::move(Selector.Parameters);
+ State.Selectors.push_back(std::move(Entry));
+ State.SelectorIndices.insert({Selector.Key, Index});
+ }
+ return State;
+}
+
+static void noteSeenAPINotesSelectorName(
----------------
j-hui wrote:
This function (as well as `markAPINotesSelectorUsed` and
`markAPINotesSelectorCandidatesUsed`) seem like they should be methods of
`APINotesSelectorDiagnosticReaderState`.
https://github.com/llvm/llvm-project/pull/209408
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits