[clang-tools-extra] 4c5a451 - [clangd] Fix targetDecl() on certain usage of ObjC properties.
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 10 09:07:48 PST 2020
Author: Sam McCall
Date: 2020-01-10T18:07:24+01:00
New Revision: 4c5a4514d14537cae5459e03d1fea422664b3bc2
URL: https://github.com/llvm/llvm-project/commit/4c5a4514d14537cae5459e03d1fea422664b3bc2
DIFF: https://github.com/llvm/llvm-project/commit/4c5a4514d14537cae5459e03d1fea422664b3bc2.diff
LOG: [clangd] Fix targetDecl() on certain usage of ObjC properties.
Summary:
In particular there's a common chain:
OpaqueValueExpr->PseudoObjectExpr->ObjCPropertyRefExpr->ObjCPropertyDecl
and we weren't handling the first two edges
Reviewers: dgoldman, kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D72494
Added:
Modified:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index 119b932956be..d8ce0b69283f 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -334,6 +334,12 @@ struct TargetFinder {
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);
}
diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index f34205a81f30..263d0154c9be 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -503,15 +503,15 @@ TEST_F(TargetDeclTest, ObjC) {
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
More information about the cfe-commits
mailing list