<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/132809>132809</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Check request: avoid adl lookup for generic types
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
denzor200
</td>
</tr>
</table>
<pre>
Needs a check that will find calls with ADL and suggest to get ride of ADL.
This is important for generic libraries(like Boost, for example: https://github.com/boostorg/pfr/pull/77#discussion_r1199710227 ) because once a time a library's user will exploit it to make an unexpected change of library's behaviour.
BEFORE:
```
namespace A {
void foo(Foo);
template<typename T>
void bar() {
foo(T{}); // BAD
}
}
```
AFTER:
```
namespace A {
void foo(Foo);
template<typename T>
void bar() {
A::foo(T{}); // OK
}
}
```
This check should never trigger on:
- swap calls(See https://github.com/llvm/llvm-project/issues/130444 ).
- ??
Also we should provide a way to intentionally use ADL(might be helpful for customization points or friend functions, for example).
In my point of view it can be a special attribute or a special macro that do nothing:
```
[[adl_required]] auto result = foo(bar); // OK
auto result = ALLOW_ADL(foo(bar)); // OK
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzElN9vozgQx_8a52XUyBhIyAMPpCnS6aqrtFfpHqsBBvDV2Jx_JM3-9SdDV83uSr2He1g0MpLtGeY7fGbQOTloopLlR5afNhj8aGzZkf5qrOB805juWjJe_UHUOUBoR2pfwY_o4SKVgl7qDlpUysFF-hGq0yOg7sCFYSDnwRsYyIOVHYHp4_GW8ep5lA6iTbOxHrWH3lgYSJOVLSjZWLSSHBOFkq8ER2OcZ-J-uUVvOM2KWFrB6P3sWFoxUTNRD9KPodm2ZmKibqKLsQMT9dzbuAalmKj3eybSTro2OCeNfrFJcjjsEy7EHpg4QEMtBkdgdEuA4OUUX2tGVyb2DoIju2qnt1kZ6UEuMid8JUANQdPbTK2nDtoR9bDovg3Q0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