[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 21 08:12:24 PST 2020


hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:585
+      // We choose to only visit TemplatedDecls for {Class, Function, Var,
+      // TypeAlias} TemplateDecls. As DescribedTemplates are covering the same
+      // range, but contains the duplication of template parameters that are
----------------
It took me a  while to understand this comment, I think not everyone is very familiar with `TemplatedDecls` and `DescribedTemplates` terms, how about?

`Avoid reporting references from {Class,Function,Var,TypeAlias}TemplateDecls to avoid duplicated results, as we will report references from their underlying decls which have the same range.`


================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:588
+      // already reported. Therefore we skip them here.
+      if (llvm::isa<RedeclarableTemplateDecl>(ND))
+        return;
----------------
I would check it more elaborately (to reflect the comment above).

```
if (llvm::isa<ClassTemplateDecl>(ND) || llvm::isa<FunctionTemplateDecl>(ND)..)
  return
```

or using `ND->getKind()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73101/new/

https://reviews.llvm.org/D73101





More information about the cfe-commits mailing list