summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2015-07-07 06:20:31 +0000
committerDouglas Gregor <dgregor@apple.com>2015-07-07 06:20:31 +0000
commit7fa93c77303e408aa3fad7a9e3cc43849ce021ce (patch)
tree51bbfeaa035b2614a62537f6e677a862956db6a8
parent9b7b3e90385cbca4af1cc6f2a3afb1da44762780 (diff)
downloadbcm5719-llvm-7fa93c77303e408aa3fad7a9e3cc43849ce021ce.tar.gz
bcm5719-llvm-7fa93c77303e408aa3fad7a9e3cc43849ce021ce.zip
[libclang] When inferring nonnull use the contextual keyword for the code-completion results,
when appropriate. rdar://20742295 llvm-svn: 241560
-rw-r--r--clang/lib/Sema/SemaType.cpp5
-rw-r--r--clang/test/Index/complete-method-decls.m17
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 768efeb64a0..1360c2cf28a 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -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;
diff --git a/clang/test/Index/complete-method-decls.m b/clang/test/Index/complete-method-decls.m
index a74020a5ed8..e45d68f9708 100644
--- a/clang/test/Index/complete-method-decls.m
+++ b/clang/test/Index/complete-method-decls.m
@@ -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)
OpenPOWER on IntegriCloud