[PATCH] D25436: [CodeCompletion] Improve completion for properties declared in Objective-C protocols
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 12 05:22:13 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284007: [CodeCompletion] Show protocol properties that are accessed through qualified id (authored by arphaman).
Changed prior to commit:
https://reviews.llvm.org/D25436?vs=74227&id=74364#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25436
Files:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/objc-protocol-member-access.m
Index: cfe/trunk/test/CodeCompletion/objc-protocol-member-access.m
===================================================================
--- cfe/trunk/test/CodeCompletion/objc-protocol-member-access.m
+++ cfe/trunk/test/CodeCompletion/objc-protocol-member-access.m
@@ -0,0 +1,24 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+ at protocol Bar
+ at property (readonly) int bar;
+ at end
+
+ at protocol Foo <Bar>
+
+ at property (nonatomic, readonly) int foo;
+- (void)foobar: (int)x;
+
+ at end
+
+int getFoo(id object) {
+ id<Foo> modelObject = (id<Foo>)object;
+ int foo = modelObject.;
+ return foo;
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:17:25 %s -o - | FileCheck %s
+// CHECK: bar : [#int#]bar
+// CHECK: foo : [#int#]foo
+// CHECK-NOT: foobar
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -3720,20 +3720,21 @@
Results.AddResult(Result("template"));
}
}
- } else if (!IsArrow && BaseType->getAsObjCInterfacePointerType()) {
+ } else if (!IsArrow && BaseType->isObjCObjectPointerType()) {
// Objective-C property reference.
AddedPropertiesSet AddedProperties;
-
- // Add property results based on our interface.
- const ObjCObjectPointerType *ObjCPtr
- = BaseType->getAsObjCInterfacePointerType();
- assert(ObjCPtr && "Non-NULL pointer guaranteed above!");
- AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true,
- /*AllowNullaryMethods=*/true, CurContext,
- AddedProperties, Results);
-
+
+ if (const ObjCObjectPointerType *ObjCPtr =
+ BaseType->getAsObjCInterfacePointerType()) {
+ // Add property results based on our interface.
+ assert(ObjCPtr && "Non-NULL pointer guaranteed above!");
+ AddObjCProperties(CCContext, ObjCPtr->getInterfaceDecl(), true,
+ /*AllowNullaryMethods=*/true, CurContext,
+ AddedProperties, Results);
+ }
+
// Add properties from the protocols in a qualified interface.
- for (auto *I : ObjCPtr->quals())
+ for (auto *I : BaseType->getAs<ObjCObjectPointerType>()->quals())
AddObjCProperties(CCContext, I, true, /*AllowNullaryMethods=*/true,
CurContext, AddedProperties, Results);
} else if ((IsArrow && BaseType->isObjCObjectPointerType()) ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25436.74364.patch
Type: text/x-patch
Size: 2536 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161012/29ea822f/attachment.bin>
More information about the cfe-commits
mailing list