[libclang] Introduce clang_Cursor_isObjCOptional, which returns whether the declaration was affected by "@optional"
rdar://14348525.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185722 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index eecb16a..ae131af 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -5992,6 +5992,19 @@
return Result;
}
+unsigned clang_Cursor_isObjCOptional(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return 0;
+
+ const Decl *D = getCursorDecl(C);
+ if (const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D))
+ return PD->getPropertyImplementation() == ObjCPropertyDecl::Optional;
+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
+ return MD->getImplementationControl() == ObjCMethodDecl::Optional;
+
+ return 0;
+}
+
unsigned clang_Cursor_isVariadic(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return 0;