summaryrefslogtreecommitdiff
path: root/lib/Index
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2018-08-17 23:50:59 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2018-08-17 23:50:59 +0000
commit712a70e658ea7debadcc2c9331f09df009e4cae6 (patch)
tree8a60177788b662a27f07423681abe9a08a46169a /lib/Index
parentb14b766b1c2e712e1b2ccca1418fb0fbb68d0230 (diff)
downloadclang-712a70e658ea7debadcc2c9331f09df009e4cae6.tar.gz
[index] For an ObjC message call, also record as receivers the protocols if they are present in the ObjC type
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340109 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index')
-rw-r--r--lib/Index/IndexBody.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Index/IndexBody.cpp b/lib/Index/IndexBody.cpp
index d79f0c3967..dd8a1c7b3f 100644
--- a/lib/Index/IndexBody.cpp
+++ b/lib/Index/IndexBody.cpp
@@ -259,8 +259,24 @@ public:
if (isDynamic(E)) {
Roles |= (unsigned)SymbolRole::Dynamic;
- if (auto *RecD = E->getReceiverInterface())
- Relations.emplace_back((unsigned)SymbolRole::RelationReceivedBy, RecD);
+
+ auto addReceivers = [&](const ObjCObjectType *Ty) {
+ if (!Ty)
+ return;
+ if (const auto *clsD = Ty->getInterface()) {
+ Relations.emplace_back((unsigned)SymbolRole::RelationReceivedBy,
+ clsD);
+ }
+ for (const auto *protD : Ty->quals()) {
+ Relations.emplace_back((unsigned)SymbolRole::RelationReceivedBy,
+ protD);
+ }
+ };
+ QualType recT = E->getReceiverType();
+ if (const auto *Ptr = recT->getAs<ObjCObjectPointerType>())
+ addReceivers(Ptr->getObjectType());
+ else
+ addReceivers(recT->getAs<ObjCObjectType>());
}
return IndexCtx.handleReference(MD, E->getSelectorStartLoc(),