diff options
author | Sam McCall <sam.mccall@gmail.com> | 2020-01-10 10:40:30 +0100 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2020-01-10 18:07:24 +0100 |
commit | 4c5a4514d14537cae5459e03d1fea422664b3bc2 (patch) | |
tree | 5acda91e525453096605293ddd825c24bf663dff /clang-tools-extra | |
parent | fbb64aa69835c8e3e9efe0afc8a73058b5a0fb3c (diff) | |
download | bcm5719-llvm-4c5a4514d14537cae5459e03d1fea422664b3bc2.tar.gz bcm5719-llvm-4c5a4514d14537cae5459e03d1fea422664b3bc2.zip |
[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
Diffstat (limited to 'clang-tools-extra')
-rw-r--r-- | clang-tools-extra/clangd/FindTarget.cpp | 6 | ||||
-rw-r--r-- | clang-tools-extra/clangd/unittests/FindTargetTests.cpp | 12 |
2 files changed, 12 insertions, 6 deletions
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp index 119b932956b..d8ce0b69283 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -334,6 +334,12 @@ public: 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 f34205a81f3..263d0154c9b 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 |