diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-18 22:15:49 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-18 22:15:49 +0000 |
commit | 9ee6a66d19aacc35397bbdc4fd535e3944301856 (patch) | |
tree | 1dda8ae33cb9348288b3e10465aea886b7634987 /tools | |
parent | 3a5891277e6c545e72551935526fce7337446e88 (diff) |
[libclang] Introduce clang_Cursor_getObjCPropertyAttributes to query the written attributes in a property declaration.
rdar://13684512
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179803 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/c-index-test/c-index-test.c | 22 | ||||
-rw-r--r-- | tools/libclang/CIndex.cpp | 29 | ||||
-rw-r--r-- | tools/libclang/libclang.exports | 1 |
3 files changed, 52 insertions, 0 deletions
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index b77c88de58..ab022a9d98 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -787,6 +787,28 @@ static void PrintCursor(CXCursor Cursor, } PrintCursorComments(Cursor, ValidationData); + + { + unsigned PropAttrs = clang_Cursor_getObjCPropertyAttributes(Cursor, 0); + if (PropAttrs != CXObjCPropertyAttr_noattr) { + printf(" ["); + #define PRINT_PROP_ATTR(A) \ + if (PropAttrs & CXObjCPropertyAttr_##A) printf(#A ",") + PRINT_PROP_ATTR(readonly); + PRINT_PROP_ATTR(getter); + PRINT_PROP_ATTR(assign); + PRINT_PROP_ATTR(readwrite); + PRINT_PROP_ATTR(retain); + PRINT_PROP_ATTR(copy); + PRINT_PROP_ATTR(nonatomic); + PRINT_PROP_ATTR(setter); + PRINT_PROP_ATTR(atomic); + PRINT_PROP_ATTR(weak); + PRINT_PROP_ATTR(strong); + PRINT_PROP_ATTR(unsafe_unretained); + printf("]"); + } + } } } diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 95b49fcd25..fd13401173 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -5919,6 +5919,35 @@ CXFile clang_getIncludedFile(CXCursor cursor) { return const_cast<FileEntry *>(ID->getFile()); } +unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved) { + if (C.kind != CXCursor_ObjCPropertyDecl) + return CXObjCPropertyAttr_noattr; + + unsigned Result = CXObjCPropertyAttr_noattr; + const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(getCursorDecl(C)); + ObjCPropertyDecl::PropertyAttributeKind Attr = + PD->getPropertyAttributesAsWritten(); + +#define SET_CXOBJCPROP_ATTR(A) \ + if (Attr & ObjCPropertyDecl::OBJC_PR_##A) \ + Result |= CXObjCPropertyAttr_##A + SET_CXOBJCPROP_ATTR(readonly); + SET_CXOBJCPROP_ATTR(getter); + SET_CXOBJCPROP_ATTR(assign); + SET_CXOBJCPROP_ATTR(readwrite); + SET_CXOBJCPROP_ATTR(retain); + SET_CXOBJCPROP_ATTR(copy); + SET_CXOBJCPROP_ATTR(nonatomic); + SET_CXOBJCPROP_ATTR(setter); + SET_CXOBJCPROP_ATTR(atomic); + SET_CXOBJCPROP_ATTR(weak); + SET_CXOBJCPROP_ATTR(strong); + SET_CXOBJCPROP_ATTR(unsafe_unretained); +#undef SET_CXOBJCPROP_ATTR + + 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 16932a5100..ad5181274d 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_getObjCPropertyAttributes clang_Cursor_getObjCSelectorIndex clang_Cursor_getSpellingNameRange clang_Cursor_getTranslationUnit |