crrev.com/c/599127 fixed a bug where defining of PRINTF_FORMAT was wrapped with:
#if defined(COMPILER_GCC)
when it should have been wrapped with:
#if defined(COMPILER_GCC) || defined(__clang__)
This omission meant that format-string checking in clang was disabled on Windows (since, correct me if I'm wrong, clang defines COMPILER_GCC on Linux/OSX/Android but not on Windows).
A quick regex search for:
#if defined\(COMPILER_GCC\)\n
finds 16 places where COMPILER_GCC is checked without checking __clang__ as well. Some of these probably represent bugs. This one in particular looks suspicious.
// Macro for hinting that an expression is likely to be false.
#if !defined(UNLIKELY)
#if defined(COMPILER_GCC)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define UNLIKELY(x) (x)
#endif // defined(COMPILER_GCC)
#endif // !defined(UNLIKELY)
These should be evaluated and fixed as appropriate. Adding an explicit __clang section and a #error section for unknown compilers would make it clearer which ones were wrong. The ones with a COMPILER_MSVC case confused me at first (it's set by clang-cl) and an explicit #else #error case would have clarified that.
Thoughts?
Comment 1 by thakis@chromium.org
, Sep 26 2017