Issue 132809
Summary [clang-tidy] Check request: avoid adl lookup for generic types
Labels clang-tidy
Assignees
Reporter denzor200
    
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
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to