zmodem wrote:

I tried this on Chromium, and we seem to get a lot of false positives where the 
macros are correctly parenthesized. For example:

```
../../third_party/icu/source/common/udataswp.cpp:390:41: warning: operator '==' 
in macro expansion has operand outside the macro; operator precedence may be 
different than expected [-Wmacro-mixed-operator]
  390 |     swapper->readUInt16= inIsBigEndian==U_IS_BIG_ENDIAN ? 
uprv_readDirectUInt16 : uprv_readSwapUInt16;
      |                                         ^~~~~~~~~~~~~~~
../../third_party/icu/source/common/unicode/platform.h:353:44: note: expanded 
from macro 'U_IS_BIG_ENDIAN'
  353 | #   define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
      |                             ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~

In file included from 
../../third_party/icu/source/i18n/number_scientific.cpp:10:
In file included from ../../third_party/icu/source/i18n/number_utils.h:18:
../../third_party/icu/source/i18n/decNumber.h:89:23: warning: operator '+' in 
macro expansion has operand outside the macro; operator precedence may be 
different than expected [-Wmacro-mixed-operator]
   89 |     decNumberUnit lsu[DECNUMUNITS];
      |                       ^~~~~~~~~~~
../../third_party/icu/source/i18n/decNumber.h:80:37: note: expanded from macro 
'DECNUMUNITS'
   80 |   #define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN)
      |                         ~~~~~~~~~~~~^~~~~~~~


In file included from 
../../third_party/libc++/src/src/filesystem/directory_entry.cpp:14:
../../third_party/libc++/src/src/filesystem/file_descriptor.h:215:7: warning: 
operator '&' in macro expansion has operand outside the macro; operator 
precedence may be different than expected [-Wmacro-mixed-operator]
  215 |   if (S_ISLNK(mode))
      |       ^~~~~~~~~~~~~
../../build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu/sys/stat.h:133:25:
 note: expanded from macro 'S_ISLNK'
  133 | # define S_ISLNK(mode)   __S_ISTYPE((mode), __S_IFLNK)
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu/sys/stat.h:123:41:
 note: expanded from macro '__S_ISTYPE'
  123 | #define __S_ISTYPE(mode, mask)  (((mode) & __S_IFMT) == (mask))
      |                                   ~~~~~~ ^ ~~~~~~~~
```

These are just a few of the first ones, but it almost seems to be warning about 
all macros.

Could you try this out on a bootstrap build of Clang or something like that to 
ensure the false-positive rate isn't too high?

https://github.com/llvm/llvm-project/pull/184924
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to