<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59251>59251</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Handle base class member access from derived class in include-cleaner
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hokein
</td>
</tr>
</table>
<pre>
Given an example
```
// base.h
class Base { int a; };
```
```
// derived.h
class Derived : pubic Base {};
```
```
// main.cpp
#include "derived.h"
void fun(Derived d) {
d.a;
}
```
Should we include the `base.h` for the base member access `a` ? The conclusion is no, as this member expr is via the Derived object.
In current include-cleaner library implementation, we consider the `base.h` is used (thus we should insert it) -- when we visit the `MemberExpr .a` in `WalkAST.cpp`, the corresponding target symbol is the `FieldDecl a` defined in Base which is in base.h.
For this case, we should not report the `FieldDecl a`, instead we should visit the type of the Base expr `d` which is `class Derived`.
A sad bit is that the `RefLocation` and `Target` is confusing in the HTML dump tool now:
- `RefLocation` points to `d.^a`;
- `Target` points to the `Derived` class;
But this is not a thing we need to worry about at the moment, we can improve later on.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVEGPmzoQ_jVwGQUFExI4cNi8dNsntZd2pZ6NbYJbYyPbJM2_f2MDm0276uFJCPB4PPN938y4NfzWfJQXoYFqEL_oMCqRbE_J9ml577fLMy_JMz7QUieyfjYxRZ2DI1ogORxBag80KY64OOHn_Sh_Cc2FRTj8MfppNkJSPME4tZK95vufWQYqdcbGcTUWUjM1cQxJyB0BIW8jXYzk0E06IdWKhyekjiiiAwDP6B0NInsPwbfeTIrDVcCa0_eYd79dRN1voTM2GoMFBjG0wgJlTKASuE2DS1I8wwu6MBOCOGk0SAfaJOQfoA5P42o5KX6NNmxeJI1RV_Cm_SGYz95S_FcDm6wVWMMF3IYpQTVGUbK11N5Ahg4Z0IN6TBrSXSMKJ1G3P6lg3smFypHK95MLzm4WQGon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