diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 2 | ||||
-rw-r--r-- | tools/libclang/CXTypes.cpp | 12 | ||||
-rw-r--r-- | tools/libclang/libclang.darwin.exports | 1 | ||||
-rw-r--r-- | tools/libclang/libclang.exports | 1 |
4 files changed, 15 insertions, 1 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index 27c51a0c59..05e2d9e16b 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -470,7 +470,7 @@ static enum CXChildVisitResult PrintTypeKind(CXCursor cursor, CXCursor p, } // Print the return type if it exists. { - CXType RT = clang_getResultType(T); + CXType RT = clang_getCursorResultType(cursor); if (RT.kind != CXType_Invalid) { CXString RS = clang_getTypeKindSpelling(RT.kind); printf(" [result=%s]", clang_getCString(RS)); diff --git a/tools/libclang/CXTypes.cpp b/tools/libclang/CXTypes.cpp index 64e49fba2b..d5c9f45210 100644 --- a/tools/libclang/CXTypes.cpp +++ b/tools/libclang/CXTypes.cpp @@ -271,4 +271,16 @@ CXType clang_getResultType(CXType X) { 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" diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports index 6c7eddfec6..f21fec63f4 100644 --- a/tools/libclang/libclang.darwin.exports +++ b/tools/libclang/libclang.darwin.exports @@ -41,6 +41,7 @@ _clang_getCursorLinkage _clang_getCursorLocation _clang_getCursorReferenced _clang_getCursorSpelling +_clang_getCursorResultType _clang_getCursorType _clang_getCursorUSR _clang_getDefinitionSpellingAndExtent diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports index 138b9767b1..dcb40d413c 100644 --- a/tools/libclang/libclang.exports +++ b/tools/libclang/libclang.exports @@ -41,6 +41,7 @@ clang_getCursorLinkage clang_getCursorLocation clang_getCursorReferenced clang_getCursorSpelling +clang_getCursorResultType clang_getCursorType clang_getCursorUSR clang_getDefinitionSpellingAndExtent |