| Issue |
183006
|
| Summary |
[clang-tidy][FN] `bugprone-fold-init-type` misses custom binary operators
|
| Labels |
clang-tidy
|
| Assignees |
|
| Reporter |
XGPSPL
|
**Environment:**
- Clang-Tidy Version: LLVM version 23.0.0git (Optimized build with assertions)
- Commit Hash: [`5654ecd5ddeb2f40e124a6bf10cc78230da4ef49`](https://github.com/llvm/llvm-project/commit/5654ecd5ddeb2f40e124a6bf10cc78230da4ef49)
- Platform: Linux 6.18.6
**Reproducer:**
```c++
#include <numeric>
#include <vector>
#include <functional>
void bugprone_fold_init_type_fn() {
float a[] = {0.5f, 0.5f};
// Accumulate with custom operator
auto r2 = std::accumulate(std::begin(a), std::end(a), 0, std::plus<>());
// Reduce with custom operator
auto r3 = std::reduce(std::begin(a), std::end(a), 0, std::plus<>());
}
```
**Godbolt:** https://clang-tidy.godbolt.org/z/feTTo3Ea5
**Impact:** This pattern is [common](https://github.com/search?q=%2Fstd%3A%3Aaccumulate%5Cs*%5C%28%5B%5E%2C%3B%5D%2B%2C%5B%5E%2C%3B%5D%2B%2C%5B%5E%2C%3B%5D%2B%2C%5B%5E%2C%3B%5D%2B%5C%29%2F&type=code), it would be nice if `clang-tidy` can support this.
**AI Usage:** This issue was found using an LLM-Assisted Fuzzer and verified by a human.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs