<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62172>62172</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
IWYU pragmas can be misleading in presence of forward declarations
</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_priv.h:
```
// IWYU pragma: private, include "foo.h"
class Bar;
class Foo {};
```
foo.h:
```
#include "foo_priv.h"
```
bar_header.h:
```
class Bar {};
```
Despite of `foo.h` not owning `Bar`, we'll infer it as canonical header for `Bar`, because of the IWYU private pragma.
I guess we can adjust private pragma to only affect declarations with a definition.
The other alternative is changing the strength for canonical signal, but it might regress other cases.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMU01r4zwQ_jXyZaiR5cR2Dj40bwj0_i7LnspYGtvqKlKQxg3994ucfqVsYcHYWGKej3lmMCU7eaJebPdieyhw4TnE_jcaGzVxMQTz0o8hPJ6jfS5nUd8LeRDyXjTy9bn-qqNQR3j4-esHnCNOJxT1PeQaZBLqP7Beu8UQCKXGEMpZKHWt1A5Tgj1GUe8_nxxDANHuRXt4v_jKub6vaN_Kqm-J32y8sf8VcsD4OBMait8jv8v-J5EHSmfLBGEE0cir5EaCDwzh4q2f8nHuQSNzsy4kVOscWD9SBMuACTT64K1GB1dpMIZ4WzWQxiWtJDzTWxZrAq-ZlJ81PcC0UEpwoYwNaJ6WxF8KgAME714Ax5E0gyHtMCLb4BNcLM-AYGi03uajG_j_Z4LAM0VAxxQ9sn0msAn0jH7KlrPIxJH8xPPq5sNinkl0q6mFcwNOdpoZIk0xS77iakyUysL0tdnVOyyor5quaqtdp7pi7iu1HeqhakfUDUmlK9mikd1m0JvOdFtZ2F5JVctN1cpO1Zuu1FsatVF1YwasdijFRtIJrSudez6VIU6FTWmhvlFVqwqHA7m07o1Sni6wXubJ2h6K2Oeau2GZkthIZxOnDxS27Kj_tCtrujAQnGxyhCZ3x3o4R0rk9ZroGOIFo7lJoFii62fmc8pTum7gZHlehlKHk1DHTPj6uTvH8ESahTquMpNQx9XGnwAAAP__3e47TQ">