Skip to content

New check suggestion: use LLVM STLExtras range-based API #38468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kirillbobyrev opened this issue Sep 28, 2018 · 4 comments
Open

New check suggestion: use LLVM STLExtras range-based API #38468

kirillbobyrev opened this issue Sep 28, 2018 · 4 comments
Labels
bugzilla Issues migrated from bugzilla check-request Request for a new check in clang-tidy clang-tidy

Comments

@kirillbobyrev
Copy link
Member

Bugzilla Link 39120
Version unspecified
OS All
CC @JonasToth

Extended Description

LLVM has include/llvm/STLExtras.h full of Standard Library function replacements with more convenient API leveraging ranges, such as

void llvm::sort (Container &&C)
void llvm::sort (Container &&C, Compare Comp)
auto llvm::find (R &&Range, const T &Val) -> decltype(adl_begin(Range))
UnaryPredicate llvm::for_each (R &&Range, UnaryPredicate P)
...

There are several patches with manual cleanups (D52576, D52650) and it would be nice to

  • automatically detect these cases
  • enforce readability by providing diagnostics later on
@JonasToth
Copy link
Member

Could be generalized to a modernize-use-ranges transforming check. There are other range libraries (v3) and the standardization effort that should be considered

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@EugeneZelenko EugeneZelenko added the enhancement Improving things as opposed to bug fixing, e.g. new or missing feature label Jan 21, 2022
@5chmidti
Copy link
Contributor

modernize-use-ranges has been implemented in #97764. It currently only supports the STL and boost (through boost-use-ranges)

@kirillbobyrev
Copy link
Member Author

modernize-use-ranges has been implemented in #97764. It currently only supports the STL and boost (through boost-use-ranges)

Thanks for noticing!

@EugeneZelenko EugeneZelenko added check-request Request for a new check in clang-tidy and removed enhancement Improving things as opposed to bug fixing, e.g. new or missing feature labels Oct 16, 2024
@5chmidti
Copy link
Contributor

The above check is not actually yet implementing using LLVM's ranges algorithms, which would be nice to have as I am not sure when we will switch to C++20

@5chmidti 5chmidti reopened this Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla check-request Request for a new check in clang-tidy clang-tidy
Projects
None yet
Development

No branches or pull requests

4 participants