<div dir="ltr">Hi,<div><br></div><div>I have observed something slightly different - both the dependent and non-dependent non-instantiated TypedefDecl are marked as referenced (ToT clang). It seems to me that you could try fixing the issue by marking the instantiated TypedefDecls as referenced if the non-instantiated is referenced (see TemplateDeclInstantiator::InstantiateTypedefNameDecl).</div><div><br></div><div>Alex</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 April 2017 at 08:29, Johannes Altmanninger via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have been working on fixing [1]. To me it is not obvious what is the<br>
proper solution is. Maybe someone has an idea?<br>
<br>
Consider this small test program:<br>
<br>
template <class T><br>
void Function(T) {<br>
  struct Struct {<br>
    typedef int Something;<br>
    Something x;<br>
  };<br>
}<br>
void test() { Function('c'); }<br>
<br>
Compiling it with -Wall -fsyntax-only generates the warning about the<br>
local typedef being unused.<br>
<br>
When adding -ast-dump one can see that there are two TypedefDecls, one<br>
for the FunctionTemplateDecl and another for the one instantiation of<br>
the template. The same thing applies when the typedef is dependent on a<br>
template parameter, say "typedef T Something" in this case.<br>
<br>
I observed this behaviour:<br>
<br>
When the typedef is independent, then neither of the TypedefDecls will<br>
be marked referenced as of now. Additionally, the type of ValueDecls<br>
like "Something x;" has the non-templated typedef as its declaration.<br>
<br>
When the typedef is dependent, then only the non-templated TypedefDecl<br>
will be marked referenced. The type of ValueDecls does naturally refer<br>
to the instantiated TypedefDecl.<br>
<br>
Is it supposed to be that way?<br>
<br>
If the types of declarations always referred to the instantiated<br>
typedefs, it would be straightforward to fix by traversing all<br>
declarations and marking the typedefs of their types referenced.<br>
<br>
Alternatively, it would be possible to only check non-instantiated<br>
types on being referenced. Actually, this might to be the simplest one..<br>
<br>
<br>
Johannes<br>
<br>
<br>
[1] <a href="https://bugs.llvm.org/show_bug.cgi?id=24883" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=24883</a><br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div>