[clang] [libclang] Add API to query more information about base classes. (PR #120300)

Jannick Kremer via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 19 08:17:47 PST 2024


================
@@ -2663,6 +2671,21 @@ def visitor(field, children):
         conf.lib.clang_Type_visitFields(self, fields_visit_callback(visitor), fields)
         return iter(fields)
 
+    def get_bases(self):
+        """Return an iterator for accessing the base classes of this type."""
+
+        def visitor(field, children):
+            assert field != conf.lib.clang_getNullCursor()
+
+            # Create reference to TU so it isn't GC'd before Cursor.
+            field._tu = self._tu
+            fields.append(field)
+            return 1  # continue
+
+        fields: list[Cursor] = []
----------------
DeinAlptraum wrote:

Shouldn't `fields` be named differently here? E.g. `base_classes` or similar

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


More information about the cfe-commits mailing list