[PATCH] D22725: [clang-tidy] Add check 'modernize-use-algorithm'

Jonas Devlieghere via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 4 11:37:08 PDT 2016


JDevlieghere updated this revision to Diff 66835.
JDevlieghere marked 9 inline comments as done.
JDevlieghere added a comment.

- Added function pointer test case
- Used placeholders for diagnostics

I extended the matchers to include `::memcpy` and `::memset` as well because the check otherwise does not work on my mac because the `cstring` header that ships with Xcode is implemented as shown below.

  _LIBCPP_BEGIN_NAMESPACE_STD
  using ::size_t;
  using ::memcpy;
  using ::memset;
  ...
  _LIBCPP_END_NAMESPACE_STD

This is annoying as I have no way to discriminate functions that have the same signature. Unless there's a better solution, this seems like a reasonable trade-off to me. Of course I'm open to suggestions!

In https://reviews.llvm.org/D22725#505739, @aaron.ballman wrote:

> The tests added mostly cover them -- I elaborated on the function pointer case, which I don't *think* will go wrong with this check, but should have a pathological test case for just to be sure.


I added the test case. The call is indeed replaced, which I guess is fine?

In https://reviews.llvm.org/D22725#505476, @Prazek wrote:

> Did you manage to see what was wrong in the transformation that you did on LLVM?


Not yet, thought it seemed to be related to `std::copy` rather than `std::fill`. I'm still trying to pinpoint the culprit but it's extremely time consuming as I have to recompile LLVM completely in order to run the tests...


Repository:
  rL LLVM

https://reviews.llvm.org/D22725

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseAlgorithmCheck.cpp
  clang-tidy/modernize/UseAlgorithmCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-algorithm.rst
  test/clang-tidy/modernize-use-algorithm.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22725.66835.patch
Type: text/x-patch
Size: 16837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160804/e17f56cf/attachment-0001.bin>


More information about the cfe-commits mailing list