r263295 - Fix ObjCMethodDecl::findPropertyDecl for class properties.
Jordan Rose via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 11 13:14:40 PST 2016
Author: jrose
Date: Fri Mar 11 15:14:40 2016
New Revision: 263295
URL: http://llvm.org/viewvc/llvm-project?rev=263295&view=rev
Log:
Fix ObjCMethodDecl::findPropertyDecl for class properties.
This affects code completion and a few other things; hopefully the code completion
test is sufficient to catch regressions.
Added:
cfe/trunk/test/CodeCompletion/documentation.m
Modified:
cfe/trunk/lib/AST/DeclObjC.cpp
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=263295&r1=263294&r2=263295&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Mar 11 15:14:40 2016
@@ -1234,23 +1234,29 @@ ObjCMethodDecl::findPropertyDecl(bool Ch
if (NumArgs > 1)
return nullptr;
- if (!isInstanceMethod())
- return nullptr;
-
if (isPropertyAccessor()) {
const ObjCContainerDecl *Container = cast<ObjCContainerDecl>(getParent());
bool IsGetter = (NumArgs == 0);
+ bool IsInstance = isInstanceMethod();
/// Local function that attempts to find a matching property within the
/// given Objective-C container.
auto findMatchingProperty =
[&](const ObjCContainerDecl *Container) -> const ObjCPropertyDecl * {
-
- for (const auto *I : Container->instance_properties()) {
- Selector NextSel = IsGetter ? I->getGetterName()
- : I->getSetterName();
- if (NextSel == Sel)
- return I;
+ if (IsInstance) {
+ for (const auto *I : Container->instance_properties()) {
+ Selector NextSel = IsGetter ? I->getGetterName()
+ : I->getSetterName();
+ if (NextSel == Sel)
+ return I;
+ }
+ } else {
+ for (const auto *I : Container->class_properties()) {
+ Selector NextSel = IsGetter ? I->getGetterName()
+ : I->getSetterName();
+ if (NextSel == Sel)
+ return I;
+ }
}
return nullptr;
Added: cfe/trunk/test/CodeCompletion/documentation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/documentation.m?rev=263295&view=auto
==============================================================================
--- cfe/trunk/test/CodeCompletion/documentation.m (added)
+++ cfe/trunk/test/CodeCompletion/documentation.m Fri Mar 11 15:14:40 2016
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+ at interface Base
+ at end
+
+ at interface Test : Base
+/// Instance!
+ at property id instanceProp;
+/// Class!
+ at property (class) id classProp;
+ at end
+
+void test(Test *obj) {
+ [obj instanceProp];
+ [Test classProp];
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:15:8 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+// CHECK-CC1: instanceProp : [#id#]instanceProp : Instance!
+// CHECK-CC1: setInstanceProp: : [#void#]setInstanceProp:<#(id)#> : Instance!
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:16:9 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: classProp : [#id#]classProp : Class!
+// CHECK-CC2: setClassProp: : [#void#]setClassProp:<#(id)#> : Class!
More information about the cfe-commits
mailing list