Author: akirtzidis
Date: Fri Jul 24 12:00:19 2015
New Revision: 243119

URL: http://llvm.org/viewvc/llvm-project?rev=243119&view=rev
Log:
[code-completion] Strip outer nullability annotations when completing method 
implementations.

The outer nullability is transferred from the declaration to the implementation 
so including them is redundant.
The inner ones are not transferred so they are kept to match the exact types. 
When we transfer the inner ones as well
adding them in the implementation will become redundant and we should strip 
those as well.

rdar://21737451

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

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=243119&r1=243118&r2=243119&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Fri Jul 24 12:00:19 2015
@@ -7079,11 +7079,13 @@ void Sema::CodeCompleteObjCMethodDecl(Sc
     
     // If the result type was not already provided, add it to the
     // pattern as (type).
-    if (ReturnType.isNull())
-      AddObjCPassingTypeChunk(Method->getSendResultType()
-                                  .stripObjCKindOfType(Context),
+    if (ReturnType.isNull()) {
+      QualType ResTy = 
Method->getSendResultType().stripObjCKindOfType(Context);
+      AttributedType::stripOuterNullability(ResTy);
+      AddObjCPassingTypeChunk(ResTy,
                               Method->getObjCDeclQualifier(), Context, Policy,
                               Builder);
+    }
 
     Selector Sel = Method->getSelector();
 
@@ -7114,6 +7116,7 @@ void Sema::CodeCompleteObjCMethodDecl(Sc
         ParamType = (*P)->getOriginalType();
       ParamType = ParamType.substObjCTypeArgs(Context, {},
                                             
ObjCSubstitutionContext::Parameter);
+      AttributedType::stripOuterNullability(ParamType);
       AddObjCPassingTypeChunk(ParamType,
                               (*P)->getObjCDeclQualifier(),
                               Context, Policy,

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=243119&r1=243118&r2=243119&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-method-decls.m (original)
+++ cfe/trunk/test/Index/complete-method-decls.m Fri Jul 24 12:00:19 2015
@@ -87,6 +87,7 @@ typedef A *MyObjectRef;
 
 @interface I2
 -(nonnull I2 *)produceI2:(nullable I2 *)i2;
+-(int *__nullable *__nullable)something:(void(^__nullable)(int *__nullable))b;
 @end
 
 @implementation I2
@@ -222,9 +223,10 @@ typedef A *MyObjectRef;
 // CHECK-CLASSTY: ObjCInstanceMethodDecl:{LeftParen (}{Text MyObject<P1> 
*}{RightParen )}{TypedText meth2}
 // CHECK-CLASSTY: ObjCInstanceMethodDecl:{LeftParen (}{Text 
MyObjectRef}{RightParen )}{TypedText meth3}
 
-// 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)
+// RUN: c-index-test -code-completion-at=%s:94:2 %s | FileCheck 
-check-prefix=CHECK-NULLABILITY %s
+// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text I2 
*}{RightParen )}{TypedText produceI2}{TypedText :}{LeftParen (}{Text I2 
*}{RightParen )}{Text i2} (40)
+// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text int * 
_Nullable *}{RightParen )}{TypedText something}{TypedText :}{LeftParen (}{Text 
void (^)(int * _Nullable)}{RightParen )}{Text b}
+
+// RUN: c-index-test -code-completion-at=%s:105:2 %s | FileCheck 
-check-prefix=CHECK-NULLABILITY2 %s
+// CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text 
instancetype}{RightParen )}{TypedText getI3} (40)
+// CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text I3 
*}{RightParen )}{TypedText produceI3}{TypedText :}{LeftParen (}{Text I3 
*}{RightParen )}{Text i3} (40)

Modified: cfe/trunk/test/Index/complete-parameterized-classes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-parameterized-classes.m?rev=243119&r1=243118&r2=243119&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-parameterized-classes.m (original)
+++ cfe/trunk/test/Index/complete-parameterized-classes.m Fri Jul 24 12:00:19 
2015
@@ -65,7 +65,7 @@ void test3() {
 // CHECK-CC5: ObjCIvarDecl:{ResultType __kindof NSObject *}{TypedText myVar} 
(35)
 
 // RUN: c-index-test -code-completion-at=%s:37:2 %s | FileCheck 
-check-prefix=CHECK-CC6 %s
-// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen 
)}{TypedText apply2}{TypedText :}{LeftParen (}{Text void (^ _Nonnull)(id, 
NSObject *)}{RightParen )}{Text block} (40)
+// CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen 
)}{TypedText apply2}{TypedText :}{LeftParen (}{Text void (^)(id, NSObject 
*)}{RightParen )}{Text block} (40)
 // CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen 
)}{TypedText apply}{TypedText :}{LeftParen (}{Text void (^)(id, NSObject 
*)}{RightParen )}{Text block} (40)
 // CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text NSObject *}{RightParen 
)}{TypedText getit}{TypedText :}{LeftParen (}{Text id}{RightParen )}{Text val} 
(40)
 // CHECK-CC6: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen 
)}{TypedText prop} (40)


_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to