Issue 110502
Summary clang-tidy-19: modernize-type-traits false positive when modern type traits are already used
Labels clang-tidy, false-positive
Assignees
Reporter hvdijk
    This is heavily reduced from real code:
```c++
#include <utility>
template <class T>
struct S { template <class U, class = std::enable_if_t<!std::is_same_v<S, std::remove_reference_t<U>>>> S(U); };
S<int> s(std::move(1));
```
Running `clang-tidy-19 --checks=modernize-type-traits test.cpp` produces:
```
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "test.cpp"
No compilation database found in /home/harald or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
Running without flags.
116 warnings generated.
/home/harald/test.cpp:3:99: warning: use c++14 style type templates [modernize-type-traits]
    3 | struct S { template <class U, class = std::enable_if_t<!std::is_same_v<S, std::remove_reference_t<U>>>> S(U); };
      | ^
      | _t
Suppressed 114 warnings (114 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```
It appears that `clang-tidy-19` is getting confused by `std::remove_reference_t`'s definition being in terms of `std::remove_reference`, ultimately the same issue as #67896. However, that issue should not be hit here because the location of `std::remove_reference` should be the system headers, and that should cause the warning to be suppressed. Because it is detected at the wrong location, the warning does not get suppressed.

No warning is emitted for this on `clang-tidy-18`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to