<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122850>122850</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-include-cleaner] suggest to insert header in source file when headers with base/derived class would be enough
</td>
</tr>
<tr>
<th>Labels</th>
<td>
false-positive,
clang-include-cleaner
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
EugeneZelenko
</td>
</tr>
</table>
<pre>
`clang-include-cleaner` suggest to include header with forward declaration when headers with base/derived classes should be enough.
`clang-tidy misc-include-cleaner` output:
```
clang-tidy -checks="-*,misc-include-cleaner" Forward.cpp
4 warnings generated.
Forward.cpp:3:39: warning: no header providing "detail::Forward" is directly included [misc-include-cleaner]
2 |
3 | void Test::do_something(const detail::Forward& /*forward*/)
| ^
```
I tried `clang-include-cleaner` from `main` (7d8b4eb0ead277f41ff69525ed807f9f6e227f37).
Base class header file (`Base.h`):
```
#pragma once
namespace detail
{
class Forward;
}
class Base
{
public:
virtual void do_something(const detail::Forward& forward);
};
```
Header file (`Forward.h`):
```
#pragma once
#include "Base.h"
class Test : public Base
{
public:
void do_something(const detail::Forward& forward) override;
};
```
Source file (`Forward.cpp`):
```
#include "Forward.h"
void Test::do_something(const detail::Forward& /*forward*/)
{
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0Vc-PqzYQ_mucyyiRGSCEAwd286L23J56qYw9gPsMRrZJtP995QC72Tba9lWqRBSD58f3fTOjEd7rbiSqWP7C8vNOzKG3rvo2dzTSb2Ro_G53jVVvFTtyacTY7fUozaxoLw2JkRw7cvBz15EPECyst9CTUOTgpkMPrXU34RQokkY4EbQd4dbTuBr5xaoRnhheFDl9JQXSCO_Jg-_tbBQ0BDTauesPjNfx2eAErd5g0F4-A2bnMM2BpfW70_rw-sF7L3uS3z1Lzwxxz7Bm-Po0IiJcFi4HOU3AeJ3BTbhRj52HqJgTgVRE-GDG0jqNv5Kl9WYdj6PdRJqcvWqlxw4YoqIgtImQ0y1KzKs9KO1IBvO2aayA5S9PceZnxmsAAARWvEackN5PV6sV_Eo-LPGV_d3bgUIfIeFJ2tEHeArgCAwvDOt2-1Df38s1Dyx58m9_EZnx-mcITkesX_RP6-wQDQahx_jO8FSoU5NRw0koLIo2S9r2WOaYkzrxoi3bIyEWbVowLNeOeBGelq7ZdG21oRiLHXm8PPQRFJZP24FhOjnRDQLsKGm5H8VAfhKSNk14zYqXlfKSaRMofblfnhfH5S7mfHeZ5sZouaSO7lftwizMUpEfqcN7BcqPpMvhs-4__U2DrSd_VAaG6TbVDHFVEvGRamwpiE290PwH6v-dMtgrOacVfc39Fzs7Sc-4x3n8kv0D0w-9NrL_x_gsGq2ts2HZqSpVZVqKHVVJkR5PiGWe7PqKZ62kNhHUcKHy5KTK0ylJi_KY8VaVPN_pCjnmPEkyjlmZJIemKdo2pURl5VGWqWIZp0FoczDmOhys63ba-5mqBPGU850RDRl_XweIrTCe9pP1OugrRRnwlSE-n2PEuEBcFePum7nzLONG--A_MgUdzH3VPI-Qnz9vEk8ubLOsR_APVf136wNun3fHbnam6kOYfKxPrMCl06Gfm4O0A8NLBLr-7Sdn_yAZGF7u-niGl1Wia4V_BgAA__8b_jg-">