Author: Haojian Wu Date: 2021-01-08T21:03:59+01:00 New Revision: 8e36d21fabcd23835d17855025d06946eb0dfb9b
URL: https://github.com/llvm/llvm-project/commit/8e36d21fabcd23835d17855025d06946eb0dfb9b DIFF: https://github.com/llvm/llvm-project/commit/8e36d21fabcd23835d17855025d06946eb0dfb9b.diff LOG: [clangd] Add go-to-def metric. to track the number of different "special" go-to-def request. Differential Revision: https://reviews.llvm.org/D94289 Added: Modified: clang-tools-extra/clangd/XRefs.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp index ebe03e74a4a7..667a90aa2efb 100644 --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -336,6 +336,8 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier, // Keep track of SymbolID -> index mapping, to fill in index data later. llvm::DenseMap<SymbolID, size_t> ResultIndex; + static constexpr trace::Metric LocateASTReferentMetric( + "locate_ast_referent", trace::Metric::Counter, "case"); auto AddResultDecl = [&](const NamedDecl *D) { D = getPreferredDecl(D); auto Loc = @@ -369,8 +371,10 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier, // saved in the AST. if (CMD->isPure()) { if (TouchedIdentifier && SM.getSpellingLoc(CMD->getLocation()) == - TouchedIdentifier->location()) + TouchedIdentifier->location()) { VirtualMethods.insert(getSymbolID(CMD)); + LocateASTReferentMetric.record(1, "method-to-override"); + } } // Special case: void foo() ^override: jump to the overridden method. const InheritableAttr *Attr = D->getAttr<OverrideAttr>(); @@ -379,6 +383,7 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier, if (Attr && TouchedIdentifier && SM.getSpellingLoc(Attr->getLocation()) == TouchedIdentifier->location()) { + LocateASTReferentMetric.record(1, "method-to-base"); // We may be overridding multiple methods - offer them all. for (const NamedDecl *ND : CMD->overridden_methods()) AddResultDecl(ND); @@ -403,6 +408,7 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier, if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) { if (TouchedIdentifier && D->getLocation() == TouchedIdentifier->location()) { + LocateASTReferentMetric.record(1, "template-specialization-to-primary"); AddResultDecl(CTSD->getSpecializedTemplate()); continue; } @@ -418,9 +424,12 @@ locateASTReferent(SourceLocation CurLoc, const syntax::Token *TouchedIdentifier, if (const auto *ID = CD->getClassInterface()) if (TouchedIdentifier && (CD->getLocation() == TouchedIdentifier->location() || - ID->getName() == TouchedIdentifier->text(SM))) + ID->getName() == TouchedIdentifier->text(SM))) { + LocateASTReferentMetric.record(1, "objc-category-to-class"); AddResultDecl(ID); + } + LocateASTReferentMetric.record(1, "regular"); // Otherwise the target declaration is the right one. AddResultDecl(D); } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits