<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61927>61927</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
References through template instantiations are not recognized
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kadircet
</td>
</tr>
</table>
<pre>
foo.h:
```cpp
#pragma once
struct Bar;
struct Foo { Bar getBar(); };
```
bar.h:
```cpp
#pragma once
struct Bar { void bar(); };
```
use.cc:
```
#include "bar.h"
#include "foo.h"
template <typename T> void usesBar(T t) { t.getBar().bar(); }
void foo() { usesBar(Foo{}); }
```
in use.cc, we've got a false negative for the use of `Bar`.
Currently the only workaround is for people to add `// IWYU pragma: keep` to such includes.
This is a rare enough use case, but we can consider analyzing instantiated bodies when both the instantiation point and the templated body is within the same file. (we should already be visiting template parameters even when template body is in a different file, but that's not enough).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVM1u4zYQfhrqMlhBJv2ngw5xUgO9FimKHkfkWGJDkwI5suF9-oKU4yS7PRRYwLAhfjPz_QxlTMkOnqgTm4PYvFQ48xhi94bGRk1c9cHculMI9SjUk2heRPMkts3y0dN0P5FqijicEYLXtJwljrNmOGAU6vDl6BgCiN0hQzAQ5wq5F7IV6gBi9_Iof_Asjz3GXxBRGC_BGuj_J9-cqNb6Z8IHm_XazYZASLlok_K_sCW8d4zpPDlkAqGe-TaRxzPBq1C_LeLmRGkJ5BVYyLbI5vpzTPVPBsrg0n4KYYFK38ewYwhid8i1P3T96OrTt_Vwj0A-w5WE3F0IhsCAcEKXCDwNyPZCcAoReKRcDuEEYttk1m1Tfx73PMdInt2tlAbvbnAN8Q1jmL0Bm8qUicLkCDgAGpMHCXkU8gi___X3n7BsV6gneCOaxLbJdWnWI9zTTl8IX0eb8lyEiJGAfJiHsWjUmCib6meGa370oINP1lAE9Ohu360fwPrE6Nkik4E-GEsJriN56AOPxcRHhQ0epmA9A3pTsPc9l9Zb1nG1PFpfwJSXfrKOahByfyVIY5idAXSR0NygJ7jYZDnLeFyYCSOeiSkmoAv5RcsDfWexHhCMPZ0op11I3q3yiCzkLoEPfI8jX6fKdMq0qsWKutV232zavVKqGru-N_utUXqlcYO7HUmpe0nr1mxWBtdrXdlONlI162bd7Ddypepda9R-reSmVb3RaMS6oTNaVzt3OdchDpVNaaZuu2rlrnLYk0vlj0dKT1coYH5TNi9V7HLPt34eklg3ziZOH1PYsqPuDyomNSXgMZbtPuL4spoE-QJk15F0GLz9Tqaao-tG5inlN7zcssHyOPe1Dmchj5nr_vNtiuEf0izksShMQh6Lg38DAAD__7vCnws">