]> granicus.if.org Git - clang/commitdiff
[libclang] For convenience to clients, make sure that nullability and __kindof annota...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 24 Aug 2015 19:50:45 +0000 (19:50 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 24 Aug 2015 19:50:45 +0000 (19:50 +0000)
the underlying type.

rdar://22063577

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245867 91177308-0d34-0410-b5e6-96231b3b80d8

test/Index/get-cursor.m
test/Index/print-type.m
tools/libclang/CXType.cpp

index f659fb1ff61cd7fda0d628ad8230e0d615250022..d321233401c8e90f72494708ca47e1a19f2e3ab9 100644 (file)
@@ -112,6 +112,23 @@ void foo3(Test3 *test3) {
 @property (retain) id propProp3;
 @end
 
+@interface TestNullability
+@property (strong, nonnull) id prop1;
+@property (strong, nullable) id prop2;
+@end
+
+@implementation TestNullability
+- (void)meth {
+  TestNullability *o;
+  [o.prop1 meth];
+  [o.prop2 meth];
+  _Nullable id lo1;
+  _Nonnull id lo2;
+  [lo1 meth];
+  [lo2 meth];
+}
+@end
+
 
 // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s
 // CHECK-PROP: ObjCPropertyDecl=foo1:4:26
@@ -170,3 +187,9 @@ void foo3(Test3 *test3) {
 // CHECK-OBJCOPTIONAL: 108:23 ObjCPropertyDecl=propProp2:108:23 (@optional) [retain,] Extent=[108:1 - 108:32]
 // CHECK-OBJCOPTIONAL: 111:8 ObjCInstanceMethodDecl=protMeth3:111:8 Extent=[111:1 - 111:18]
 // CHECK-OBJCOPTIONAL: 112:23 ObjCPropertyDecl=propProp3:112:23 [retain,] Extent=[112:1 - 112:32]
+
+// RUN: c-index-test -cursor-at=%s:123:12 %s | FileCheck -check-prefix=CHECK-RECEIVER-WITH-NULLABILITY %s
+// RUN: c-index-test -cursor-at=%s:124:12 %s | FileCheck -check-prefix=CHECK-RECEIVER-WITH-NULLABILITY %s
+// RUN: c-index-test -cursor-at=%s:127:8 %s | FileCheck -check-prefix=CHECK-RECEIVER-WITH-NULLABILITY %s
+// RUN: c-index-test -cursor-at=%s:128:8 %s | FileCheck -check-prefix=CHECK-RECEIVER-WITH-NULLABILITY %s
+// CHECK-RECEIVER-WITH-NULLABILITY: Receiver-type=ObjCId
index 5a4272b131b68a78046d6285b4f8a2fa5a771688..777069b3a58b395611c4b77527133865a267e023 100644 (file)
@@ -3,6 +3,7 @@
 -(int) mymethod;
 -(const id) mymethod2:(id)x blah:(Class)y boo:(SEL)z;
 -(bycopy)methodIn:(in int)i andOut:(out short *)j , ...;
+-(void)kindof_meth:(__kindof Foo *)p;
 @end
 
 // RUN: c-index-test -test-print-type %s | FileCheck %s
@@ -13,3 +14,4 @@
 // CHECK: ObjCInstanceMethodDecl=methodIn:andOut::5:10 (variadic) [Bycopy,] [type=] [typekind=Invalid] [resulttype=id] [resulttypekind=ObjCId] [args= [int] [Int] [short *] [Pointer]] [isPOD=0]
 // CHECK: ParmDecl=i:5:27 (Definition) [In,] [type=int] [typekind=Int] [isPOD=1]
 // CHECK: ParmDecl=j:5:49 (Definition) [Out,] [type=short *] [typekind=Pointer] [isPOD=1] [pointeetype=short] [pointeekind=Short]
+// CHECK: ParmDecl=p:6:36 (Definition) [type=__kindof Foo *] [typekind=ObjCObjectPointer] [canonicaltype=__kindof Foo *] [canonicaltypekind=ObjCObjectPointer] [isPOD=1] [pointeetype=Foo] [pointeekind=ObjCInterface]
index 1318e86b555398a214664893591f4fdf110f9f9e..6fd7bc31258be8d49365bad9c638b856d543c386 100644 (file)
@@ -101,6 +101,11 @@ CXType cxtype::MakeCXType(QualType T, CXTranslationUnit TU) {
   CXTypeKind TK = CXType_Invalid;
 
   if (TU && !T.isNull()) {
+    // Handle attributed types as the original type
+    if (auto *ATT = T->getAs<AttributedType>()) {
+      return MakeCXType(ATT->getModifiedType(), TU);
+    }
+
     ASTContext &Ctx = cxtu::getASTUnit(TU)->getASTContext();
     if (Ctx.getLangOpts().ObjC1) {
       QualType UnqualT = T.getUnqualifiedType();