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

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 20:30:07 PDT 2016


Prazek added a comment.

In https://reviews.llvm.org/D22725#505020, @JDevlieghere wrote:

> Addresses comments from Aaron Ballman
>
> @aaron.ballman Thanks for the thorough review! Can you check whether the tests I added address your concerns? Could you also elaborate on the case with the C-function pointer? Unless I explicitly cast it to void* the compiler rejects will reject it as an argument to memcpy. Am I missing a case where this could go wrong? I still added it to the pointer arithmetic check though, just to be sure.


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

I have one idea, which should be fixed. Memset takes char as an argument, so if you would fill the array of ints with memset(arr, 0, sizeof(arr)), then it will set all
the elements to zero. But if you would do it with with set say 1, you will end up having

  int val = 1 | (1 << 8) | (1 << 16) | (1 << 24)

for each elemnt of the array.

I don't think tho that any LLVM code depend od this, you usually set everything to zero, or to another value if you operate on char type.

So allow transformation and diagnostic if the argument equals 0, or when the type is char.


Repository:
  rL LLVM

https://reviews.llvm.org/D22725





More information about the cfe-commits mailing list