aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-18 23:29:12 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-18 23:29:12 +0000
commit38dbad233bfc7906e38e028707ffe5925b9ca46c (patch)
treebc9ecf00b32582125b78d7047d9465efee7e426e /tools
parent68ea1d26ff6cdd3b8bcd37dd88b24d430e71581a (diff)
[libclang] Introduce clang_Cursor_getObjCDeclQualifiers, to query for 'ObjC Qualifiers' written next to the return and
parameter types in an ObjC method declarations. rdar://13676977 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179816 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/c-index-test/c-index-test.c16
-rw-r--r--tools/libclang/CIndex.cpp24
-rw-r--r--tools/libclang/libclang.exports1
3 files changed, 41 insertions, 0 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index ab022a9d98..b8664ed75a 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -809,6 +809,22 @@ static void PrintCursor(CXCursor Cursor,
printf("]");
}
}
+
+ {
+ unsigned QT = clang_Cursor_getObjCDeclQualifiers(Cursor);
+ if (QT != CXObjCDeclQualifier_None) {
+ printf(" [");
+ #define PRINT_OBJC_QUAL(A) \
+ if (QT & CXObjCDeclQualifier_##A) printf(#A ",")
+ PRINT_OBJC_QUAL(In);
+ PRINT_OBJC_QUAL(Inout);
+ PRINT_OBJC_QUAL(Out);
+ PRINT_OBJC_QUAL(Bycopy);
+ PRINT_OBJC_QUAL(Byref);
+ PRINT_OBJC_QUAL(Oneway);
+ printf("]");
+ }
+ }
}
}
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index fd13401173..8a56f4da06 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -5948,6 +5948,30 @@ unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved) {
return Result;
}
+unsigned clang_Cursor_getObjCDeclQualifiers(CXCursor C) {
+ if (!clang_isDeclaration(C.kind))
+ return CXObjCDeclQualifier_None;
+
+ Decl::ObjCDeclQualifier QT = Decl::OBJC_TQ_None;
+ const Decl *D = getCursorDecl(C);
+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
+ QT = MD->getObjCDeclQualifier();
+ else if (const ParmVarDecl *PD = dyn_cast<ParmVarDecl>(D))
+ QT = PD->getObjCDeclQualifier();
+ if (QT == Decl::OBJC_TQ_None)
+ return CXObjCDeclQualifier_None;
+
+ unsigned Result = CXObjCDeclQualifier_None;
+ if (QT & Decl::OBJC_TQ_In) Result |= CXObjCDeclQualifier_In;
+ if (QT & Decl::OBJC_TQ_Inout) Result |= CXObjCDeclQualifier_Inout;
+ if (QT & Decl::OBJC_TQ_Out) Result |= CXObjCDeclQualifier_Out;
+ if (QT & Decl::OBJC_TQ_Bycopy) Result |= CXObjCDeclQualifier_Bycopy;
+ if (QT & Decl::OBJC_TQ_Byref) Result |= CXObjCDeclQualifier_Byref;
+ if (QT & Decl::OBJC_TQ_Oneway) Result |= CXObjCDeclQualifier_Oneway;
+
+ return Result;
+}
+
CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return clang_getNullRange();
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index ad5181274d..ffea921cad 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -10,6 +10,7 @@ clang_Cursor_getCommentRange
clang_Cursor_getParsedComment
clang_Cursor_getRawCommentText
clang_Cursor_getNumArguments
+clang_Cursor_getObjCDeclQualifiers
clang_Cursor_getObjCPropertyAttributes
clang_Cursor_getObjCSelectorIndex
clang_Cursor_getSpellingNameRange