]> granicus.if.org Git - clang/commitdiff
[libclang] When inferring nonnull use the contextual keyword for the code-completion...
authorDouglas Gregor <dgregor@apple.com>
Tue, 7 Jul 2015 06:20:31 +0000 (06:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 7 Jul 2015 06:20:31 +0000 (06:20 +0000)
when appropriate.

rdar://20742295

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

lib/Sema/SemaType.cpp
test/Index/complete-method-decls.m

index 768efeb64a09c456324bd0d932a2b605bc405218..1360c2cf28a819118e8391670300bb7c3892e753 100644 (file)
@@ -3479,6 +3479,11 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
 
       spliceAttrIntoList(*nullabilityAttr, attrs);
 
+      if (inferNullabilityCS) {
+        state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
+          ->setObjCDeclQualifier(ObjCDeclSpec::DQ_CSNullability);
+      }
+
       if (inferNullabilityInnerOnly)
         inferNullabilityInnerOnlyComplete = true;
       return nullabilityAttr;
index a74020a5ed8b7b7e4a1ca3fcaf603ed479206266..e45d68f970874daed28f92a8eaffecfbaff5a7a6 100644 (file)
@@ -90,7 +90,18 @@ typedef A *MyObjectRef;
 @end
 
 @implementation I2
--
+-(void)foo {}
+@end
+
+#pragma clang assume_nonnull begin
+@interface I3
+-(I3 *)produceI3:(I3 *)i3;
+-(instancetype)getI3;
+@end
+#pragma clang assume_nonnull end
+
+@implementation I3
+-(void)foo {}
 @end
 
 // RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
@@ -213,3 +224,7 @@ typedef A *MyObjectRef;
 
 // RUN: c-index-test -code-completion-at=%s:93:2 %s | FileCheck -check-prefix=CHECK-NULLABILITY %s
 // CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text nonnull }{Text I2 *}{RightParen )}{TypedText produceI2}{TypedText :}{LeftParen (}{Text nullable }{Text I2 *}{RightParen )}{Text i2} (40)
+
+// RUN: c-index-test -code-completion-at=%s:104:2 %s | FileCheck -check-prefix=CHECK-NULLABILITY2 %s
+// CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text nonnull }{Text instancetype}{RightParen )}{TypedText getI3} (40)
+// CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text nonnull }{Text I3 *}{RightParen )}{TypedText produceI3}{TypedText :}{LeftParen (}{Text nonnull }{Text I3 *}{RightParen )}{Text i3} (40)