Add CXType support for querying the return type of Objective-C methods. This is done by
adding a clang_getCursorResultType() function (which complements clang_getResultType()).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106473 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CXTypes.cpp b/tools/libclang/CXTypes.cpp
index 64e49fb..d5c9f45 100644
--- a/tools/libclang/CXTypes.cpp
+++ b/tools/libclang/CXTypes.cpp
@@ -271,4 +271,16 @@
return MakeCXType(QualType(), GetASTU(X));
}
+CXType clang_getCursorResultType(CXCursor C) {
+ if (clang_isDeclaration(C.kind)) {
+ Decl *D = cxcursor::getCursorDecl(C);
+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
+ return MakeCXType(MD->getResultType(), cxcursor::getCursorASTUnit(C));
+
+ return clang_getResultType(clang_getCursorType(C));
+ }
+
+ return MakeCXType(QualType(), cxcursor::getCursorASTUnit(C));
+}
+
} // end: extern "C"