[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 19 11:19:16 PDT 2019


xbolva00 added a comment.

>From post commit discussion, Nico Weber:

1. Hi,
2.
3. this results in a false positive on webrtc, on this code:
4.
5. https://cs.chromium.org/chromium/src/third_party/libwebp/src/enc/picture_csp_enc.c?q=picture_csp_enc.c&sq=package:chromium&dr&l=1002
6.
7. The code does this:
8.
9. #ifdef WORDS_BIGENDIAN
10. #define ALPHA_OFFSET 0   // uint32_t 0xff000000 is 0xff,00,00,00 in memory
11. #else
12. #define ALPHA_OFFSET 3   // uint32_t 0xff000000 is 0x00,00,00,ff in memory
13. #endif
14.
15. // ...
16.
17. const uint8_t* const argb = (const uint8_t*)picture->argb;
18. const uint8_t* const a = argb + (0 ^ ALPHA_OFFSET);
19. const uint8_t* const r = argb + (1 ^ ALPHA_OFFSET);
20. const uint8_t* const g = argb + (2 ^ ALPHA_OFFSET);
21. const uint8_t* const b = argb + (3 ^ ALPHA_OFFSET);
22.
23. The idea is to get bytes 0, 1, 2, 3 as a, r, g, b if ALPHA_OFFSET is 0, or bytes 3, 2, 1, 0 if ALPHA_OFFSET is 3.
24.
25. Maybe this shouldn't fire if the rhs is a macro?
26.
27. (On all of Chromium, this fired 3 times; in the other 2 cases the rhs was a literal as well, and those two were true positives.)




Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66397/new/

https://reviews.llvm.org/D66397





More information about the cfe-commits mailing list