[clang-tools-extra] [clangd] Don't collect templated decls for builtin templates (PR #78466)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 18 00:45:15 PST 2024


================
@@ -443,9 +443,15 @@ struct TargetFinder {
           Outer.add(TST->getAliasedType(), Flags | Rel::Underlying);
           // Don't *traverse* the alias, which would result in traversing the
           // template of the underlying type.
-          Outer.report(
-              TST->getTemplateName().getAsTemplateDecl()->getTemplatedDecl(),
-              Flags | Rel::Alias | Rel::TemplatePattern);
+
+          // Builtin templates e.g. __make_integer_seq, __type_pack_element
+          // are such that they don't have alias *decls*. Even then, we still
+          // traverse their desugared *types* so that instantiated decls are
+          // collected.
+          if (NamedDecl *D = TST->getTemplateName()
----------------
hokein wrote:

nit: maybe write the code like below, being explicit about the builtin template cases.
```
const TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl();
if (isa<BuiltinTemplateDecl>(TD))
    return;
...
```

https://github.com/llvm/llvm-project/pull/78466


More information about the cfe-commits mailing list