[clang] [cindex] Add API to query the class methods of a type (PR #123539)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 15 16:45:39 PST 2025


================
@@ -54,6 +54,33 @@ unsigned clang_visitCXXBaseClasses(CXType PT, CXFieldVisitor visitor,
   return true;
 }
 
+unsigned clang_visitCXXMethods(CXType PT, CXFieldVisitor visitor,
+                               CXClientData client_data) {
+  CXCursor PC = clang_getTypeDeclaration(PT);
+  if (clang_isInvalid(PC.kind))
+    return false;
+  const CXXRecordDecl *RD =
+      dyn_cast_if_present<CXXRecordDecl>(cxcursor::getCursorDecl(PC));
+  if (!RD || RD->isInvalidDecl())
+    return false;
+  RD = RD->getDefinition();
+  if (!RD || RD->isInvalidDecl())
+    return false;
+
+  for (auto Method : RD->methods()) {
----------------
Endilll wrote:

```suggestion
  for (const auto *Method : RD->methods()) {
```

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


More information about the cfe-commits mailing list