[PATCH] D72494: [clangd] Fix targetDecl() on certain usage of ObjC properties.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 10 01:47:58 PST 2020
sammccall created this revision.
sammccall added reviewers: dgoldman, kadircet.
Herald added subscribers: cfe-commits, usaxena95, jfb, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.
This revision now requires changes to proceed.
Could you also add a test (and possibly support this in the visitors) for `findExplicitReferences`?
In particular there's a common chain:
OpaqueValueExpr->PseudoObjectExpr->ObjCPropertyRefExpr->ObjCPropertyDecl
and we weren't handling the first two edges
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D72494
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -503,15 +503,16 @@
EXPECT_DECLS("ObjCPropertyRefExpr", "- (void)setX:(int)x");
Code = R"cpp(
- @interface Foo {}
- @property int x;
+ @interface I {}
+ @property(retain) I* x;
+ @property(retain) I* y;
@end
- void test(Foo *f) {
- [[f.x]] = 42;
+ void test(I *f) {
+ [[f.x]].y = 0;
}
)cpp";
- EXPECT_DECLS("ObjCPropertyRefExpr",
- "@property(atomic, assign, unsafe_unretained, readwrite) int x");
+ EXPECT_DECLS("OpaqueValueExpr",
+ "@property(atomic, retain, readwrite) I *x");
Code = R"cpp(
@protocol Foo
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -334,6 +334,12 @@
void VisitObjCProtocolExpr(const ObjCProtocolExpr *OPE) {
Outer.add(OPE->getProtocol(), Flags);
}
+ void VisitOpaqueValueExpr(const OpaqueValueExpr *OVE) {
+ Outer.add(OVE->getSourceExpr(), Flags);
+ }
+ void VisitPseudoObjectExpr(const PseudoObjectExpr *POE) {
+ Outer.add(POE->getSyntacticForm(), Flags);
+ }
};
Visitor(*this, Flags).Visit(S);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72494.237267.patch
Type: text/x-patch
Size: 1492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200110/22b73840/attachment.bin>
More information about the cfe-commits
mailing list