r241560 - [libclang] When inferring nonnull use the contextual keyword for the code-completion results,

Douglas Gregor dgregor at apple.com
Mon Jul 6 23:20:31 PDT 2015


Author: dgregor
Date: Tue Jul  7 01:20:31 2015
New Revision: 241560

URL: http://llvm.org/viewvc/llvm-project?rev=241560&view=rev
Log:
[libclang] When inferring nonnull use the contextual keyword for the code-completion results,
when appropriate.

rdar://20742295

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/Index/complete-method-decls.m

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=241560&r1=241559&r2=241560&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Jul  7 01:20:31 2015
@@ -3479,6 +3479,11 @@ static TypeSourceInfo *GetFullTypeForDec
 
       spliceAttrIntoList(*nullabilityAttr, attrs);
 
+      if (inferNullabilityCS) {
+        state.getDeclarator().getMutableDeclSpec().getObjCQualifiers()
+          ->setObjCDeclQualifier(ObjCDeclSpec::DQ_CSNullability);
+      }
+
       if (inferNullabilityInnerOnly)
         inferNullabilityInnerOnlyComplete = true;
       return nullabilityAttr;

Modified: cfe/trunk/test/Index/complete-method-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-method-decls.m?rev=241560&r1=241559&r2=241560&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-method-decls.m (original)
+++ cfe/trunk/test/Index/complete-method-decls.m Tue Jul  7 01:20:31 2015
@@ -90,7 +90,18 @@ typedef A *MyObjectRef;
 @end
 
 @implementation I2
--
+-(void)foo {}
+ at end
+
+#pragma clang assume_nonnull begin
+ at interface I3
+-(I3 *)produceI3:(I3 *)i3;
+-(instancetype)getI3;
+ at end
+#pragma clang assume_nonnull end
+
+ at 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)





More information about the cfe-commits mailing list