================
@@ -893,6 +905,56 @@
APINotesReader::Implementation::getIdentifier(llvm::StringRef Str) {
return *Known;
}
+std::optional<llvm::StringRef>
+APINotesReader::Implementation::getIdentifierString(IdentifierID ID) {
+ if (!IdentifierTable)
+ return std::nullopt;
+
+ if (ID == IdentifierID(0))
+ return llvm::StringRef();
+
+ for (llvm::StringRef Identifier : IdentifierTable->keys()) {
+ auto KnownID = IdentifierTable->find(Identifier);
+ if (KnownID != IdentifierTable->end() && *KnownID == ID)
+ return Identifier;
+ }
+
+ return std::nullopt;
+}
+
+template <typename TableT>
+void APINotesReader::Implementation::collectFunctionParameterSelectors(
+ TableT *Table, uint32_t ParentContextID, llvm::StringRef Name,
+ llvm::SmallVectorImpl<llvm::SmallVector<std::string, 4>> &Selectors) {
+ if (!Table)
+ return;
+
+ std::optional<IdentifierID> NameID = getIdentifier(Name);
+ if (!NameID)
+ return;
+
+ for (auto I = Table->key_begin(), E = Table->key_end(); I != E; ++I) {
+ FunctionTableKey Key = I.getInternalKey();
+ if (Key.parentContextID != ParentContextID ||
+ Key.nameID != static_cast<unsigned>(*NameID) || !Key.parameterTypeIDs)
+ continue;
+
+ llvm::SmallVector<std::string, 4> ParameterSelector;
+ ParameterSelector.reserve(Key.parameterTypeIDs->size());
+ bool Failed = false;
+ for (IdentifierID TypeID : *Key.parameterTypeIDs) {
+ std::optional<llvm::StringRef> TypeName = getIdentifierString(TypeID);
+ if (!TypeName) {
+ Failed = true;
----------------
Xazax-hun wrote:
I wonder if it would be worth making `Failed` a return value so the caller
knows if there were an unexpected error vs just nothing found?
https://github.com/llvm/llvm-project/pull/209408
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits