7 Commits

Author SHA1 Message Date
Stephan Bergmann
907ffec490 isIntegerConstantExpr is more general than IntegerLiteral
...and subsumes not only the use of __builtin_expect in assert, but also the use
of __builtin_constant_p (nested) in htonl on Mac OS X.

Change-Id: I62ab6c71c42948c4ec1e2f1e1d23223cbb13416b
2014-02-25 19:05:01 +01:00
Stephan Bergmann
d36e60f685 Adapt to Clang <= 3.4
Change-Id: If9c9d63d85ce29629e6453f2d69355bd64ac2fc5
2014-02-21 23:59:24 +01:00
Stephan Bergmann
216bcceee1 Special handling of __builtin_expect in boolean expressions
...as found in Mac OS X' assert macro definition,

  __builtin_expect(!(e), 0) ? ... : ...

with type

  long __builtin_expect(long, long)

The code in literaltoboolconversion.cxx is needed for

  assert(false);

Change-Id: I42f87482c56986af74b2ec849db9852f74c7c938
2014-02-21 23:47:23 +01:00
Noel Grandin
a1aa702861 literaltobool conversion plugin, reduce spurious warnings with clang 3.3
It appears that clang 3.3 also generates spurious warnings, so
adjust the ifdef

Change-Id: Idb57f7eafd55effd4c7c8b1f96c03c2ea6ddaba3
2014-01-30 15:41:27 +02:00
Stephan Bergmann
c03a2a0b1b Further fix for old Clang versions
...maybe this needs adaption for 3.3 or 3.4 too, known to work with trunk
towards 3.5.

Change-Id: I9f05ae44e4a49ae51df69d5a3c1df5eb371a1c87
2014-01-29 11:15:44 +01:00
Stephan Bergmann
d433d8245b Fix for old Clang versions
Change-Id: Ib902535c03a9f1b93a2c4ff3dd61d29e316bfd49
2014-01-29 09:58:10 +01:00
Stephan Bergmann
3de97578e4 Clang plugin to warn about implicit conversion of literals to bool
...which warns about apparent errors like

  n == KIND_FOO || KIND_BAR

that should have read

  n == KIND_FOO || n == KIND_BAR

It also warns about trivial (mis-)uses of 0/1 and sal_False/True like

  while (1) { ... }

instead of

  while (true) { ... }

which it can automatically rewrite.

It does not warn if the relevant code is inside a macro in a .h (i.e., C)
include file, nor when a string literal is used in the assert macro like

  assert(!"this cannot happen");

Change-Id: If8c305a25e5da15e78f6139b5b0c0e868f06d4f3
2014-01-28 20:26:31 +01:00