summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2016-03-11 21:14:40 +0000
committerJordan Rose <jordan_rose@apple.com>2016-03-11 21:14:40 +0000
commit31cf7d49db5483ee086132dce1458631f460a83c (patch)
treed2ccd2846157f440f8f4afb7d3d0328960636c91
parent60e53cdcb71cb823ae0a05be8974b0b31e7a4fa4 (diff)
downloadbcm5719-llvm-31cf7d49db5483ee086132dce1458631f460a83c.tar.gz
bcm5719-llvm-31cf7d49db5483ee086132dce1458631f460a83c.zip
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. llvm-svn: 263295
-rw-r--r--clang/lib/AST/DeclObjC.cpp24
-rw-r--r--clang/test/CodeCompletion/documentation.m25
2 files changed, 40 insertions, 9 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 1480a55d56a..d2701211bea 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -1234,23 +1234,29 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) const {
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;
diff --git a/clang/test/CodeCompletion/documentation.m b/clang/test/CodeCompletion/documentation.m
new file mode 100644
index 00000000000..47add5b6ca0
--- /dev/null
+++ b/clang/test/CodeCompletion/documentation.m
@@ -0,0 +1,25 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+@interface Base
+@end
+
+@interface Test : Base
+/// Instance!
+@property id instanceProp;
+/// Class!
+@property (class) id classProp;
+@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!
OpenPOWER on IntegriCloud