diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-07-03 10:34:46 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-07-03 10:34:46 +0000 |
commit | be79ca8111104870564b7427d0c5d99a5592d1bb (patch) | |
tree | 8ad918e5f6d713c86c6e05dcf6c356e2d2f10bc7 /clang/lib/Index/IndexBody.cpp | |
parent | 6c9af50cc815df58ed18a0a17225a41745f0107f (diff) | |
download | bcm5719-llvm-be79ca8111104870564b7427d0c5d99a5592d1bb.tar.gz bcm5719-llvm-be79ca8111104870564b7427d0c5d99a5592d1bb.zip |
[index] Remove 'implicit' role for message sends in implicit ObjC
property references
rdar://32375673
llvm-svn: 307016
Diffstat (limited to 'clang/lib/Index/IndexBody.cpp')
-rw-r--r-- | clang/lib/Index/IndexBody.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp index d3632b8b9b1..6bbd3810250 100644 --- a/clang/lib/Index/IndexBody.cpp +++ b/clang/lib/Index/IndexBody.cpp @@ -230,7 +230,31 @@ public: SmallVector<SymbolRelation, 2> Relations; addCallRole(Roles, Relations); Stmt *Containing = getParentStmt(); - if (E->isImplicit() || (Containing && isa<PseudoObjectExpr>(Containing))) + + auto IsImplicitProperty = [](const PseudoObjectExpr *POE) -> bool { + const auto *E = POE->getSyntacticForm(); + if (const auto *BinOp = dyn_cast<BinaryOperator>(E)) + E = BinOp->getLHS(); + const auto *PRE = dyn_cast<ObjCPropertyRefExpr>(E); + if (!PRE) + return false; + if (PRE->isExplicitProperty()) + return false; + if (const ObjCMethodDecl *Getter = PRE->getImplicitPropertyGetter()) { + // Class properties that are explicitly defined using @property + // declarations are represented implicitly as there is no ivar for + // class properties. + if (Getter->isClassMethod() && + Getter->getCanonicalDecl()->findPropertyDecl()) + return false; + } + return true; + }; + bool IsPropCall = Containing && isa<PseudoObjectExpr>(Containing); + // Implicit property message sends are not 'implicit'. + if ((E->isImplicit() || IsPropCall) && + !(IsPropCall && + IsImplicitProperty(cast<PseudoObjectExpr>(Containing)))) Roles |= (unsigned)SymbolRole::Implicit; if (isDynamic(E)) { |