llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clang-tidy] `performance-inefficient-algorithm` suggestion does not compile

Open davidmenggx opened this issue 3 months ago • 1 comments

The suggestion generated does not compile:

#include <set>
#include <algorithm>

#define SET_RANGE s.begin(), s.end()

bool f(std::set<int> s) {
    return std::find(SET_RANGE, 46) != s.end();
}

Suggestion currently is:

<source>:7:12: warning: this STL algorithm call should be replaced with a container method [performance-inefficient-algorithm]
    7 |     return std::find(SET_RANGE, 46) != s.end();
      |            ^~~~~~~~~~~~~~~~~~~~~~~~
      |            .find(46)

Godbolt: https://godbolt.org/z/E8eovTYEe

Related: https://github.com/llvm/llvm-project/issues/217457

davidmenggx avatar Aug 20 '26 17:08 davidmenggx

@llvm/issue-subscribers-clang-tidy

Author: David Meng (davidmenggx)

The suggestion generated does not compile: ```cpp #include <set> #include <algorithm>

#define SET_RANGE s.begin(), s.end()

bool f(std::set<int> s) { return std::find(SET_RANGE, 46) != s.end(); }

Suggestion currently is:

<source>:7:12: warning: this STL algorithm call should be replaced with a container method [performance-inefficient-algorithm] 7 | return std::find(SET_RANGE, 46) != s.end(); | ^~~~~~~~~~~~~~~~~~~~~~~~ | .find(46)


Godbolt: https://godbolt.org/z/E8eovTYEe

Related: https://github.com/llvm/llvm-project/issues/217457
</details>