Add CXType support for FunctionNoProto and FunctionProto types. This includes adding a new
function, clang_getResultType(), which returns the result type of the function type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106459 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CXTypes.cpp b/tools/libclang/CXTypes.cpp
index ae756c7..64e49fb 100644
--- a/tools/libclang/CXTypes.cpp
+++ b/tools/libclang/CXTypes.cpp
@@ -77,6 +77,8 @@
TKCASE(Typedef);
TKCASE(ObjCInterface);
TKCASE(ObjCObjectPointer);
+ TKCASE(FunctionNoProto);
+ TKCASE(FunctionProto);
default:
return CXType_Unexposed;
}
@@ -118,7 +120,8 @@
return MakeCXType(VD->getType(), AU);
if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D))
return MakeCXType(PD->getType(), AU);
-
+ if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
+ return MakeCXType(FD->getType(), AU);
return MakeCXType(QualType(), AU);
}
@@ -246,6 +249,8 @@
TKIND(Typedef);
TKIND(ObjCInterface);
TKIND(ObjCObjectPointer);
+ TKIND(FunctionNoProto);
+ TKIND(FunctionProto);
}
#undef TKIND
return cxstring::createCXString(s);
@@ -255,4 +260,15 @@
return A.data[0] == B.data[0] && A.data[1] == B.data[1];;
}
+CXType clang_getResultType(CXType X) {
+ QualType T = GetQualType(X);
+ if (!T.getTypePtr())
+ return MakeCXType(QualType(), GetASTU(X));
+
+ if (const FunctionType *FD = T->getAs<FunctionType>())
+ return MakeCXType(FD->getResultType(), GetASTU(X));
+
+ return MakeCXType(QualType(), GetASTU(X));
+}
+
} // end: extern "C"
diff --git a/tools/libclang/libclang.darwin.exports b/tools/libclang/libclang.darwin.exports
index 3ef3b74..6c7eddf 100644
--- a/tools/libclang/libclang.darwin.exports
+++ b/tools/libclang/libclang.darwin.exports
@@ -67,6 +67,7 @@
_clang_getRange
_clang_getRangeEnd
_clang_getRangeStart
+_clang_getResultType
_clang_getTokenExtent
_clang_getTokenKind
_clang_getTokenLocation
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index c7831f7..138b976 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -67,6 +67,7 @@
clang_getRange
clang_getRangeEnd
clang_getRangeStart
+clang_getResultType
clang_getTokenExtent
clang_getTokenKind
clang_getTokenLocation