And libclang cursor/indexing support for new Objective-C NSArray/NSDictionary/NSNumber literals.

llvm-svn: 152138
This commit is contained in:
Ted Kremenek 2012-03-06 20:06:06 +00:00
parent e65b086e07
commit 77006f6875
11 changed files with 397 additions and 13 deletions

View File

@ -1745,7 +1745,11 @@ enum CXCursorKind {
*/
CXCursor_LambdaExpr = 144,
CXCursor_LastExpr = CXCursor_LambdaExpr,
/** \brief Objective-c Boolean Literal.
*/
CXCursor_ObjCBoolLiteralExpr = 145,
CXCursor_LastExpr = CXCursor_ObjCBoolLiteralExpr,
/* Statements */
CXCursor_FirstStmt = 200,

View File

@ -0,0 +1,44 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: cp %s %t
// RUN: not %clang_cc1 -fsyntax-only -fixit -x objective-c %t
// RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t
// RUN: grep arrayWithObjects %t
typedef unsigned char BOOL;
@interface NSNumber @end
@interface NSNumber (NSNumberCreation)
+ (NSNumber *)numberWithChar:(char)value;
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
+ (NSNumber *)numberWithShort:(short)value;
+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
+ (NSNumber *)numberWithInt:(int)value;
+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
+ (NSNumber *)numberWithLong:(long)value;
+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
+ (NSNumber *)numberWithLongLong:(long long)value;
+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
+ (NSNumber *)numberWithFloat:(float)value;
+ (NSNumber *)numberWithDouble:(double)value;
+ (NSNumber *)numberWithBool:(BOOL)value;
@end
@interface NSArray
@end
@interface NSArray (NSArrayCreation)
+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
@end
@interface NSDictionary
+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
@end
void fixes() {
id arr = @[
17, // expected-error{{numeric literal must be prefixed by '@' in a collection}}
'a', // expected-error{{character literal must be prefixed by '@'}}
"blah" // expected-error{{string literal must be prefixed by '@'}}
];
}

View File

@ -0,0 +1,72 @@
typedef unsigned char BOOL;
@interface NSNumber @end
@interface NSNumber (NSNumberCreation)
+ (NSNumber *)numberWithChar:(char)value;
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
+ (NSNumber *)numberWithShort:(short)value;
+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
+ (NSNumber *)numberWithInt:(int)value;
+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
+ (NSNumber *)numberWithLong:(long)value;
+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
+ (NSNumber *)numberWithLongLong:(long long)value;
+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
+ (NSNumber *)numberWithFloat:(float)value;
+ (NSNumber *)numberWithDouble:(double)value;
+ (NSNumber *)numberWithBool:(BOOL)value;
@end
@interface NSArray
@end
@interface NSArray (NSArrayCreation)
+ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt;
@end
@interface NSDictionary
+ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
@end
void test_literals(id k1, id o1, id k2, id o2, id k3) {
id objects = @[ o1, o2 ];
id dict = @{ k1 : o1,
k2 : o2,
k3 : @17 };
}
// RUN: c-index-test -test-annotate-tokens=%s:33:1:37:1 %s | FileCheck -check-prefix=CHECK-LITERALS %s
// CHECK-LITERALS: Identifier: "id" [33:3 - 33:5] TypeRef=id:0:0
// CHECK-LITERALS: Identifier: "objects" [33:6 - 33:13] VarDecl=objects:33:6 (Definition)
// CHECK-LITERALS: Punctuation: "=" [33:14 - 33:15] VarDecl=objects:33:6 (Definition)
// CHECK-LITERALS: Punctuation: "@" [33:16 - 33:17] UnexposedExpr=
// CHECK-LITERALS: Punctuation: "[" [33:17 - 33:18] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o1" [33:19 - 33:21] DeclRefExpr=o1:32:30
// CHECK-LITERALS: Punctuation: "," [33:21 - 33:22] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o2" [33:23 - 33:25] DeclRefExpr=o2:32:44
// CHECK-LITERALS: Punctuation: "]" [33:26 - 33:27] UnexposedExpr=
// CHECK-LITERALS: Punctuation: ";" [33:27 - 33:28] DeclStmt=
// CHECK-LITERALS: Identifier: "id" [34:3 - 34:5] TypeRef=id:0:0
// CHECK-LITERALS: Identifier: "dict" [34:6 - 34:10] VarDecl=dict:34:6 (Definition)
// CHECK-LITERALS: Punctuation: "=" [34:11 - 34:12] VarDecl=dict:34:6 (Definition)
// CHECK-LITERALS: Punctuation: "@" [34:13 - 34:14] UnexposedExpr=
// CHECK-LITERALS: Punctuation: "{" [34:14 - 34:15] UnexposedExpr=
// CHECK-LITERALS: Identifier: "k1" [34:16 - 34:18] DeclRefExpr=k1:32:23
// CHECK-LITERALS: Punctuation: ":" [34:19 - 34:20] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o1" [34:21 - 34:23] DeclRefExpr=o1:32:30
// CHECK-LITERALS: Punctuation: "," [34:23 - 34:24] UnexposedExpr=
// CHECK-LITERALS: Identifier: "k2" [35:16 - 35:18] DeclRefExpr=k2:32:37
// CHECK-LITERALS: Punctuation: ":" [35:19 - 35:20] UnexposedExpr=
// CHECK-LITERALS: Identifier: "o2" [35:21 - 35:23] DeclRefExpr=o2:32:44
// CHECK-LITERALS: Punctuation: "," [35:23 - 35:24] UnexposedExpr=
// CHECK-LITERALS: Identifier: "k3" [36:16 - 36:18] DeclRefExpr=k3:32:51
// CHECK-LITERALS: Punctuation: ":" [36:19 - 36:20] UnexposedExpr=
// CHECK-LITERALS: Punctuation: "@" [36:21 - 36:22] UnexposedExpr=
// CHECK-LITERALS: Literal: "17" [36:22 - 36:24] IntegerLiteral=
// CHECK-LITERALS: Punctuation: "}" [36:25 - 36:26] UnexposedExpr=
// CHECK-LITERALS: Punctuation: ";" [36:26 - 36:27] DeclStmt=
// CHECK-LITERALS: Punctuation: "}" [37:1 - 37:2] CompoundStmt=

View File

@ -0,0 +1,92 @@
@interface NSArray
- (id)objectAtIndexedSubscript:(int)index;
+ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
@end
@interface NSMutableArray : NSArray
- (id)objectAtIndexedSubscript:(int)index;
- (void)setObject:(id)object atIndexedSubscript:(int)index;
@end
@interface NSDictionary
- (id)objectForKeyedSubscript:(id)key;
+ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
@end
@interface NSMutableDictionary : NSDictionary
- (void)setObject:(id)object forKeyedSubscript:(id)key;
@end
@class NSString;
id testArray(int index, id p) {
NSMutableArray *array;
array[3] = 0;
NSArray *arr = @[ p, p ];
return array[index];
}
void testDict() {
NSMutableDictionary *dictionary;
NSString *key;
id newObject, oldObject;
oldObject = dictionary[key];
dictionary[key] = newObject;
NSDictionary *dict = @{ key: newObject, key: oldObject };
}
// RUN: c-index-test -test-annotate-tokens=%s:22:1:36:1 -target x86_64-apple-macosx10.7 %s | FileCheck %s
// CHECK: Identifier: "array" [24:3 - 24:8] DeclRefExpr=array:23:19
// CHECK: Punctuation: "[" [24:8 - 24:9] UnexposedExpr=
// CHECK: Literal: "3" [24:9 - 24:10] IntegerLiteral=
// CHECK: Punctuation: "]" [24:10 - 24:11] UnexposedExpr=
// CHECK: Punctuation: "=" [24:12 - 24:13] BinaryOperator=
// CHECK: Literal: "0" [24:14 - 24:15] IntegerLiteral=
// CHECK: Punctuation: ";" [24:15 - 24:16] CompoundStmt=
// CHECK: Identifier: "NSArray" [25:3 - 25:10] ObjCClassRef=NSArray:1:12
// CHECK: Punctuation: "*" [25:11 - 25:12] VarDecl=arr:25:12 (Definition)
// CHECK: Identifier: "arr" [25:12 - 25:15] VarDecl=arr:25:12 (Definition)
// CHECK: Punctuation: "=" [25:16 - 25:17] VarDecl=arr:25:12 (Definition)
// CHECK: Punctuation: "@" [25:18 - 25:19] UnexposedExpr=
// CHECK: Punctuation: "[" [25:19 - 25:20] UnexposedExpr=
// CHECK: Identifier: "p" [25:21 - 25:22] DeclRefExpr=p:22:28
// CHECK: Punctuation: "," [25:22 - 25:23] UnexposedExpr=
// CHECK: Identifier: "p" [25:24 - 25:25] DeclRefExpr=p:22:28
// CHECK: Punctuation: "]" [25:26 - 25:27] UnexposedExpr=
// CHECK: Punctuation: ";" [25:27 - 25:28] DeclStmt=
// CHECK: Keyword: "return" [26:3 - 26:9] ReturnStmt=
// CHECK: Identifier: "array" [26:10 - 26:15] DeclRefExpr=array:23:19
// CHECK: Punctuation: "[" [26:15 - 26:16] UnexposedExpr=
// CHECK: Identifier: "index" [26:16 - 26:21] DeclRefExpr=index:22:18
// CHECK: Punctuation: "]" [26:21 - 26:22] UnexposedExpr=
// CHECK: Punctuation: ";" [26:22 - 26:23] CompoundStmt=
// CHECK: Identifier: "oldObject" [33:3 - 33:12] DeclRefExpr=oldObject:32:17
// CHECK: Punctuation: "=" [33:13 - 33:14] BinaryOperator=
// CHECK: Identifier: "dictionary" [33:15 - 33:25] DeclRefExpr=dictionary:30:24
// CHECK: Punctuation: "[" [33:25 - 33:26] UnexposedExpr=
// CHECK: Identifier: "key" [33:26 - 33:29] DeclRefExpr=key:31:13
// CHECK: Punctuation: "]" [33:29 - 33:30] UnexposedExpr=
// CHECK: Punctuation: ";" [33:30 - 33:31] CompoundStmt=
// CHECK: Identifier: "dictionary" [34:3 - 34:13] DeclRefExpr=dictionary:30:24
// CHECK: Punctuation: "[" [34:13 - 34:14] UnexposedExpr=
// CHECK: Identifier: "key" [34:14 - 34:17] DeclRefExpr=key:31:13
// CHECK: Punctuation: "]" [34:17 - 34:18] UnexposedExpr=
// CHECK: Punctuation: "=" [34:19 - 34:20] BinaryOperator=
// CHECK: Identifier: "newObject" [34:21 - 34:30] DeclRefExpr=newObject:32:6
// CHECK: Punctuation: ";" [34:30 - 34:31] CompoundStmt=
// CHECK: Identifier: "NSDictionary" [35:3 - 35:15] ObjCClassRef=NSDictionary:11:12
// CHECK: Punctuation: "*" [35:16 - 35:17] VarDecl=dict:35:17 (Definition)
// CHECK: Identifier: "dict" [35:17 - 35:21] VarDecl=dict:35:17 (Definition)
// CHECK: Punctuation: "=" [35:22 - 35:23] VarDecl=dict:35:17 (Definition)
// CHECK: Punctuation: "@" [35:24 - 35:25] UnexposedExpr=
// CHECK: Punctuation: "{" [35:25 - 35:26] UnexposedExpr=
// CHECK: Identifier: "key" [35:27 - 35:30] DeclRefExpr=key:31:13
// CHECK: Punctuation: ":" [35:30 - 35:31] UnexposedExpr=
// CHECK: Identifier: "newObject" [35:32 - 35:41] DeclRefExpr=newObject:32:6
// CHECK: Punctuation: "," [35:41 - 35:42] UnexposedExpr=
// CHECK: Identifier: "key" [35:43 - 35:46] DeclRefExpr=key:31:13
// CHECK: Punctuation: ":" [35:46 - 35:47] UnexposedExpr=
// CHECK: Identifier: "oldObject" [35:48 - 35:57] DeclRefExpr=oldObject:32:17
// CHECK: Punctuation: "}" [35:58 - 35:59] UnexposedExpr=
// CHECK: Punctuation: ";" [35:59 - 35:60] DeclStmt=

View File

@ -2,9 +2,9 @@ typedef signed char BOOL;
#define YES ((BOOL)1)
#define NO ((BOOL)0)
#define bool _Bool
@interface NSArray + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; @end
@interface A
- (int)method:(id)param1;
@property int prop1;
@end
__strong id global;
@ -12,10 +12,14 @@ __strong id global;
- (int)method:(id)param1 {
void foo(bool (^block)(id x, A* y));
for(BOOL B = YES; ; ) { }
@[ global ];
@{ global : global };
}
@end
// RUN: c-index-test -code-completion-at=%s:13:2 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
// CHECK-CC1: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
// CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
// CHECK-CC1: TypedefDecl:{TypedText BOOL} (50)
// CHECK-CC1: macro definition:{TypedText bool} (51)
@ -32,3 +36,14 @@ __strong id global;
// CHECK-CC3: FunctionDecl:{ResultType void}{TypedText foo}{LeftParen (}{Placeholder ^bool(id x, A *y)block}{RightParen )} (34)
// CHECK-CC3: VarDecl:{ResultType id}{TypedText global} (50)
// CHECK-CC3: ParmDecl:{ResultType id}{TypedText param1} (34)
// RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
// RUN: c-index-test -code-completion-at=%s:16:5 %s | FileCheck -check-prefix=CHECK-CC4 %s
// RUN: c-index-test -code-completion-at=%s:16:14 %s | FileCheck -check-prefix=CHECK-CC4 %s
// CHECK-CC4: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40)
// CHECK-CC4: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40)
// CHECK-CC4: NotImplemented:{ResultType SEL}{TypedText _cmd} (80)
// CHECK-CC4: macro definition:{TypedText bool} (51)
// CHECK-CC4: macro definition:{TypedText NO} (65)
// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (34)
// CHECK-CC4: macro definition:{TypedText YES} (65)

View File

@ -0,0 +1,65 @@
@interface NSArray
- (id)objectAtIndexedSubscript:(int)index;
+ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
@end
@interface NSMutableArray : NSArray
- (id)objectAtIndexedSubscript:(int)index;
- (void)setObject:(id)object atIndexedSubscript:(int)index;
@end
@interface NSDictionary
- (id)objectForKeyedSubscript:(id)key;
+ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
@end
@interface NSMutableDictionary : NSDictionary
- (void)setObject:(id)object forKeyedSubscript:(id)key;
@end
@class NSString;
id testArray(int index, id p) {
NSMutableArray *array;
array[3] = 0;
NSArray *arr = @[ p, p ];
return array[index];
}
void testDict() {
NSMutableDictionary *dictionary;
NSString *key;
id newObject, oldObject;
oldObject = dictionary[key];
dictionary[key] = newObject;
NSDictionary *dict = @{ key: newObject, key: oldObject };
}
// RUN: c-index-test \
// RUN: -file-refs-at=%s:22:21 \
// CHECK: ParmDecl=index:22:18
// CHECK-NEXT: ParmDecl=index:22:18 (Definition) =[22:18 - 22:23]
// CHECK-NEXT: DeclRefExpr=index:22:18 =[26:16 - 26:21]
// RUN: -file-refs-at=%s:22:28 \
// CHECK-NEXT: ParmDecl=p:22:28
// CHECK-NEXT: ParmDecl=p:22:28 (Definition) =[22:28 - 22:29]
// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:21 - 25:22]
// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:24 - 25:25]
// RUN: -file-refs-at=%s:34:16 \
// CHECK-NEXT: DeclRefExpr=key:31:13
// CHECK-NEXT: VarDecl=key:31:13 (Definition) =[31:13 - 31:16]
// CHECK-NEXT: DeclRefExpr=key:31:13 =[33:26 - 33:29]
// CHECK-NEXT: DeclRefExpr=key:31:13 =[34:14 - 34:17]
// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:27 - 35:30]
// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:43 - 35:46]
// RUN: -file-refs-at=%s:35:35 \
// CHECK-NEXT: DeclRefExpr=newObject:32:6
// CHECK-NEXT: VarDecl=newObject:32:6 (Definition) =[32:6 - 32:15]
// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[34:21 - 34:30]
// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[35:32 - 35:41]
// RUN: -target x86_64-apple-macosx10.7 %s | FileCheck %s

View File

@ -8,7 +8,7 @@ struct X {
void f(struct X *x) {
// CHECK: error: no member named 'wobble' in 'struct X'; did you mean 'wibble'?
// CHECK-NOT: FIX-IT
// CHECK: FIX-IT: Replace [13:12 - 13:24] with "wibble"
// CHECK: note: 'wibble' declared here
MACRO(x->wobble = 17);
// CHECK: error: no member named 'wabble' in 'struct X'; did you mean 'wibble'?

View File

@ -0,0 +1,66 @@
@interface NSArray
- (id)objectAtIndexedSubscript:(int)index;
+ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
@end
@interface NSMutableArray : NSArray
- (id)objectAtIndexedSubscript:(int)index;
- (void)setObject:(id)object atIndexedSubscript:(int)index;
@end
@interface NSDictionary
- (id)objectForKeyedSubscript:(id)key;
+ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
@end
@interface NSMutableDictionary : NSDictionary
- (void)setObject:(id)object forKeyedSubscript:(id)key;
@end
@class NSString;
int idx;
id p;
id testArray() {
NSMutableArray *array;
array[idx] = p;
NSArray *arr = @[ p, p ];
return array[idx];
}
NSString *key;
id newObject, oldObject;
void testDict() {
NSMutableDictionary *dictionary;
oldObject = dictionary[key];
dictionary[key] = newObject;
NSDictionary *dict = @{ key: newObject, key: oldObject };
}
// RUN: c-index-test -index-file -target x86_64-apple-macosx10.7 %s | FileCheck %s
// CHECK: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 27:9
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 27:16 | <parent>:: kind: function | name: testArray | USR: c:@F@testArray | lang: C | container: [testArray:25:4] | refkind: direct
// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:atIndexedSubscript:
// CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSArray
// CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: arrayWithObjects:count:
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:21
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:24
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 29:16
// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectAtIndexedSubscript:
// CHECK-NEXT: [indexDeclaration]: kind: variable | name: key
// CHECK: [indexEntityReference]: kind: variable | name: oldObject
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 37:26
// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectForKeyedSubscript:
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 38:14
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 38:21
// CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:forKeyedSubscript:
// CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSDictionary
// CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: dictionaryWithObjects:forKeys:count:
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:27
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 39:32
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:43
// CHECK-NEXT: [indexEntityReference]: kind: variable | name: oldObject | USR: c:@oldObject | lang: C | cursor: DeclRefExpr=oldObject:33:15 | loc: 39:48

View File

@ -3291,6 +3291,8 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) {
return createCXString("UnaryExpr");
case CXCursor_ObjCStringLiteral:
return createCXString("ObjCStringLiteral");
case CXCursor_ObjCBoolLiteralExpr:
return createCXString("ObjCBoolLiteralExpr");
case CXCursor_ObjCEncodeExpr:
return createCXString("ObjCEncodeExpr");
case CXCursor_ObjCSelectorExpr:

View File

@ -227,6 +227,10 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, CXTranslationUnit TU,
case Stmt::UnaryExprOrTypeTraitExprClass:
case Stmt::UnaryTypeTraitExprClass:
case Stmt::VAArgExprClass:
case Stmt::ObjCArrayLiteralClass:
case Stmt::ObjCDictionaryLiteralClass:
case Stmt::ObjCNumericLiteralClass:
case Stmt::ObjCSubscriptRefExprClass:
K = CXCursor_UnexposedExpr;
break;
@ -395,7 +399,11 @@ CXCursor cxcursor::MakeCXCursor(Stmt *S, Decl *Parent, CXTranslationUnit TU,
case Stmt::ObjCProtocolExprClass:
K = CXCursor_ObjCProtocolExpr;
break;
case Stmt::ObjCBoolLiteralExprClass:
K = CXCursor_ObjCBoolLiteralExpr;
break;
case Stmt::ObjCBridgedCastExprClass:
K = CXCursor_ObjCBridgedCastExpr;
break;

View File

@ -81,17 +81,33 @@ public:
}
bool VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
if (E->isImplicitProperty()) {
if (ObjCMethodDecl *MD = E->getImplicitPropertyGetter())
IndexCtx.handleReference(MD, E->getLocation(), Parent, ParentDC, E,
CXIdxEntityRef_Implicit);
if (ObjCMethodDecl *MD = E->getImplicitPropertySetter())
IndexCtx.handleReference(MD, E->getLocation(), Parent, ParentDC, E,
CXIdxEntityRef_Implicit);
} else {
if (E->isExplicitProperty())
IndexCtx.handleReference(E->getExplicitProperty(), E->getLocation(),
Parent, ParentDC, E);
}
// No need to do a handleReference for the objc method, because there will
// be a message expr as part of PseudoObjectExpr.
return true;
}
bool VisitObjCNumericLiteral(ObjCNumericLiteral *E) {
if (ObjCMethodDecl *MD = E->getObjCNumericLiteralMethod())
IndexCtx.handleReference(MD, E->getLocStart(),
Parent, ParentDC, E, CXIdxEntityRef_Implicit);
return true;
}
bool VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
if (ObjCMethodDecl *MD = E->getDictWithObjectsMethod())
IndexCtx.handleReference(MD, E->getLocStart(),
Parent, ParentDC, E, CXIdxEntityRef_Implicit);
return true;
}
bool VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
if (ObjCMethodDecl *MD = E->getArrayWithObjectsMethod())
IndexCtx.handleReference(MD, E->getLocStart(),
Parent, ParentDC, E, CXIdxEntityRef_Implicit);
return true;
}