<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/122852>122852</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-include-cleaner] suggest to insert header where base class is defined
</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 where base class is defined as well as forward declaration when base/derived class headers should be enough.
`clang-tidy misc-include-cleaner` output:
```
clang-tidy -checks="-*,misc-include-cleaner" Forward.cpp
5 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)
| ^
Forward.cpp:5:5: warning: no header providing "Base" is directly included [misc-include-cleaner]
5 | Base::do_something(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)
{
Base::do_something(forward);
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVU1v4zYQ_TXjC2GDGn3ZBx2UeI323J56KShyJLFLiwJJOci_L6iPjYM10jRYQAIpkPPmvccZUXivu4GogvwJ8vNOTKG3rvo2dTTQX2Ro-G53jVWvFRRcGjF0ez1IMynaS0NiIAcFZ37qOvKBBcvWVdaTUOTYS0-OWCM8MWmE90x7pqjVAykmPHshY-LYWvcinGKKpBFOBG2HGDrMkYAXRU7fSK0YC7ZnvreTUawhRoOduv4AvI7PxjRo9cqu2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