diff options
author | Kadir Cetinkaya <kadircet@google.com> | 2019-03-08 08:30:20 +0000 |
---|---|---|
committer | Kadir Cetinkaya <kadircet@google.com> | 2019-03-08 08:30:20 +0000 |
commit | 87becae02c7bcddcc684aa2f1d4191cdfee78c8e (patch) | |
tree | 5e580ee2cb86a2113c184b27d0fde08f79348376 /lib/Index | |
parent | bb4e581872047f891a408e293f1a4cb9b931154c (diff) | |
download | clang-87becae02c7bcddcc684aa2f1d4191cdfee78c8e.tar.gz |
[clang][Index] Mark references from Constructors and Destructors to class as NameReference
Summary:
In current indexing logic we get references to class itself when we see
a constructor/destructor which is only syntactically true. Semantically
this information is not correct. This patch marks that reference as
NameReference to let clients deal with it.
Reviewers: akyrtzi, gribozavr, nathawes, benlangmuir
Reviewed By: gribozavr, nathawes
Subscribers: nathawes, arphaman, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D58814
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Index')
-rw-r--r-- | lib/Index/IndexDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Index/IndexSymbol.cpp | 2 | ||||
-rw-r--r-- | lib/Index/IndexingContext.cpp | 1 |
3 files changed, 7 insertions, 2 deletions
diff --git a/lib/Index/IndexDecl.cpp b/lib/Index/IndexDecl.cpp index d7835c51d0..7e6be5d7f6 100644 --- a/lib/Index/IndexDecl.cpp +++ b/lib/Index/IndexDecl.cpp @@ -247,7 +247,8 @@ public: if (const CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) { IndexCtx.handleReference(Ctor->getParent(), Ctor->getLocation(), - Ctor->getParent(), Ctor->getDeclContext()); + Ctor->getParent(), Ctor->getDeclContext(), + (unsigned)SymbolRole::NameReference); // Constructor initializers. for (const auto *Init : Ctor->inits()) { @@ -263,7 +264,8 @@ public: if (auto TypeNameInfo = Dtor->getNameInfo().getNamedTypeInfo()) { IndexCtx.handleReference(Dtor->getParent(), TypeNameInfo->getTypeLoc().getBeginLoc(), - Dtor->getParent(), Dtor->getDeclContext()); + Dtor->getParent(), Dtor->getDeclContext(), + (unsigned)SymbolRole::NameReference); } } else if (const auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) { IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(), diff --git a/lib/Index/IndexSymbol.cpp b/lib/Index/IndexSymbol.cpp index 218f89360b..a8f11b3448 100644 --- a/lib/Index/IndexSymbol.cpp +++ b/lib/Index/IndexSymbol.cpp @@ -396,6 +396,7 @@ bool index::applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles, APPLY_FOR_ROLE(RelationContainedBy); APPLY_FOR_ROLE(RelationIBTypeOf); APPLY_FOR_ROLE(RelationSpecializationOf); + APPLY_FOR_ROLE(NameReference); #undef APPLY_FOR_ROLE @@ -438,6 +439,7 @@ void index::printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS) { case SymbolRole::RelationContainedBy: OS << "RelCont"; break; case SymbolRole::RelationIBTypeOf: OS << "RelIBType"; break; case SymbolRole::RelationSpecializationOf: OS << "RelSpecialization"; break; + case SymbolRole::NameReference: OS << "NameReference"; break; } }); } diff --git a/lib/Index/IndexingContext.cpp b/lib/Index/IndexingContext.cpp index d01dd50f3b..edff2eb566 100644 --- a/lib/Index/IndexingContext.cpp +++ b/lib/Index/IndexingContext.cpp @@ -332,6 +332,7 @@ static bool shouldReportOccurrenceForSystemDeclOnlyMode( case SymbolRole::RelationCalledBy: case SymbolRole::RelationContainedBy: case SymbolRole::RelationSpecializationOf: + case SymbolRole::NameReference: return true; } llvm_unreachable("Unsupported SymbolRole value!"); |