aboutsummaryrefslogtreecommitdiff
path: root/clang/tools/c-index-test/c-index-test.c
diff options
context:
space:
mode:
authorMichael Wu <mwu.code@gmail.com>2018-08-03 05:38:29 +0000
committerMichael Wu <mwu.code@gmail.com>2018-08-03 05:38:29 +0000
commit6e88f5334ca731e3a2da51286602bae450404216 (patch)
treef63e237f60a0370e733953acb31910a9825646ee /clang/tools/c-index-test/c-index-test.c
parent40ff105663d9f55185d44844eddcbadf0b45360a (diff)
downloadllvm-6e88f5334ca731e3a2da51286602bae450404216.zip
llvm-6e88f5334ca731e3a2da51286602bae450404216.tar.gz
llvm-6e88f5334ca731e3a2da51286602bae450404216.tar.bz2
[libclang 7/8] Add support for getting property setter and getter names
Summary: This allows libclang to access the actual names of property setters and getters without needing to go through the indexer API. Usually default names are used, but the property can specify a different name. Reviewers: yvvan, jbcoe Reviewed By: yvvan Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49634 llvm-svn: 338816
Diffstat (limited to 'clang/tools/c-index-test/c-index-test.c')
-rw-r--r--clang/tools/c-index-test/c-index-test.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 41dbbe7..7c88811 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -1103,6 +1103,34 @@ static void PrintCursor(CXCursor Cursor, const char *CommentSchemaFile) {
}
}
+ if (Cursor.kind == CXCursor_ObjCPropertyDecl) {
+ CXString Name = clang_Cursor_getObjCPropertyGetterName(Cursor);
+ CXString Spelling = clang_getCursorSpelling(Cursor);
+ const char *CName = clang_getCString(Name);
+ const char *CSpelling = clang_getCString(Spelling);
+ if (CName && strcmp(CName, CSpelling)) {
+ printf(" (getter=%s)", CName);
+ }
+ clang_disposeString(Spelling);
+ clang_disposeString(Name);
+ }
+
+ if (Cursor.kind == CXCursor_ObjCPropertyDecl) {
+ CXString Name = clang_Cursor_getObjCPropertySetterName(Cursor);
+ CXString Spelling = clang_getCursorSpelling(Cursor);
+ const char *CName = clang_getCString(Name);
+ const char *CSpelling = clang_getCString(Spelling);
+ char *DefaultSetter = malloc(strlen(CSpelling) + 5);
+ sprintf(DefaultSetter, "set%s:", CSpelling);
+ DefaultSetter[3] &= ~(1 << 5); /* Make uppercase */
+ if (CName && strcmp(CName, DefaultSetter)) {
+ printf(" (setter=%s)", CName);
+ }
+ free(DefaultSetter);
+ clang_disposeString(Spelling);
+ clang_disposeString(Name);
+ }
+
{
unsigned QT = clang_Cursor_getObjCDeclQualifiers(Cursor);
if (QT != CXObjCDeclQualifier_None) {