[clang] [APINotes] Upstream APINotesWriter (PR #65187)

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 4 11:18:44 PDT 2023


================
@@ -105,6 +110,40 @@ class APINotesWriter::Implementation {
                  llvm::SmallVector<std::pair<VersionTuple, TypedefInfo>, 1>>
       Typedefs;
 
+  /// Retrieve the ID for the given identifier.
+  IdentifierID getIdentifier(StringRef Identifier) {
+    if (Identifier.empty())
+      return 0;
+
+    auto Known = IdentifierIDs.find(Identifier);
+    if (Known != IdentifierIDs.end())
+      return Known->second;
+
+    // Add to the identifier table.
+    Known = IdentifierIDs.insert({Identifier, IdentifierIDs.size() + 1}).first;
+    return Known->second;
+  }
+
+  /// Retrieve the ID for the given selector.
+  SelectorID getSelector(ObjCSelectorRef SelectorRef) {
+    // Translate the selector reference into a stored selector.
+    StoredObjCSelector Selector;
+    Selector.Identifiers.reserve(SelectorRef.Identifiers.size());
+    for (auto piece : SelectorRef.Identifiers) {
----------------
compnerd wrote:

Braces aren't really needed... almost makes me prefer a `std::transform`.

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


More information about the cfe-commits mailing list