32 Commits

Author SHA1 Message Date
Stephan Bergmann
1ce7176ba1 Remove support for Clang < 3.3
Change-Id: I185852a738bac10dc6d331afccfcbc7ae1225cb1
2016-06-29 08:55:27 +02:00
Stephan Bergmann
0d3738a258 More Clang 3.4 "(anonymous namespace)" fixes
Change-Id: I7cb43f915565dadd611b90ee30373e472f97efb5
Reviewed-on: https://gerrit.libreoffice.org/26748
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-06-28 20:33:58 +00:00
Stephan Bergmann
9308f35318 Adapt to Clang 3.4 (in preparation of a buildbot on CentOS 7)
Change-Id: Ie2859f03b31c57deb7fd0deba3285f782e33b239
2016-06-28 16:26:33 +02:00
Stephan Bergmann
82da3d95c1 loplugin:salbool: Implicit conversions from non-Boolean fundamental types
Change-Id: I67eac95686678e6f5a2d60798535b2c65a9ba5d7
2016-06-19 21:29:43 +02:00
Jochen Nitschke
1520d0d6f3 cppcheck: silence warnings in compilerplugins
mostly missing explicit before ctors and
uninitialized member vars

one odd use of std::find
> compilerplugins/clang/implicitboolconversion.cxx
> 800 stlIfFind warning	Suspicious condition.
> The result of find() is an iterator, but it is not properly checked.

Change-Id: Iade53494cd7fe8ddb0e110e431449ae5a517fe3b
Reviewed-on: https://gerrit.libreoffice.org/24398
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-04-27 12:03:57 +00:00
Stephan Bergmann
8c423eeb49 Use Sequence ctor taking initializer_list
needed adapting loplugin:implicitboolconversion to not warn about

  Sequence<sal_Bool> arBool({true, false, true});

Change-Id: I971918aab7c958ef8f1e4e0548a84314e95f8325
2016-04-21 17:27:43 +02:00
Stephan Bergmann
a3858ed3a7 Use cast to bool to normalize sal_Bool values
Change-Id: I8a886f752d2a16ec4c10656bcd0b3631647971b2
2016-04-20 17:25:31 +02:00
Stephan Bergmann
01f3b95884 These version checks are about the Clang the plugins are built /against/
...not the (Clang) compiler they are being built /with/.  (Also simplifies the
checking #if code.)

Change-Id: I416321be4ef4478785be40571f81500fd3b6feb8
2016-02-26 14:34:29 +01:00
Stephan Bergmann
f44bd6b054 Adapt loplugin:implicitboolconversion to changes in Clang trunk towards 3.8
Change-Id: I7841eee5b66a118c52258c0226d73a1139a0df9a
2016-01-05 09:51:29 +01:00
Benjamin Ni
be729e7721 tdf#94269: Replace "n" prefix for bool variables with "b"
Change-Id: I178545792c7354a362658ac7ef8b1d4cf0865797
Signed-off-by: Michael Stahl <mstahl@redhat.com>
2015-11-02 23:40:57 +01:00
Stephan Bergmann
c15b4cf39a Adapt to current Clang trunk towards 3.7
Change-Id: Ibb2c641d49a1773be789c9259f53a040db6f605f
2015-08-04 09:36:32 +02:00
Stephan Bergmann
e12e0087e2 Suppress loplugin:implicitboolconversion warnings in Objective-C code
...(but not Objective-C++ code) where BOOL (aka unsigned char) expressions are
routinely implicitly converted to int per the C rules, e.g., as operands of &&.

Change-Id: I17e5dae9f065aaa814850196b1ef31f8fb07c99b
2015-05-11 09:20:13 +02:00
Stephan Bergmann
9be45dd750 lopluign:implicitboolconversion: warn about conversion from sal_Bool etc., too
Change-Id: I5bc23a2b599742c579ad82c1b1f68df130ac426b
2015-05-08 09:49:05 +02:00
Stephan Bergmann
6052a839f5 Mac OS X ctype.h isdigit is not extern "C"
Change-Id: Ied43178bacc020b848ee3196080713e08c780133
2015-04-23 23:48:01 +02:00
Stephan Bergmann
59076a9825 Improve loplugin:implicitboolconversion cond. expr. handling
...so that

  ... ? isdigit(...) : true

will not trigger a warning (where isdigit is the standard C function returning
int).  (Odd code like that will fall out of the improved
loplugin:literaltoboolconversion rewriter shortly.)

Change-Id: If51402bd5f4b3f8b0630e874988f4b836ae246f8
2015-04-23 18:39:06 +02:00
Stephan Bergmann
8e4d82cd11 loplugin:implicitboolconversion: warn about conversions to unsigned char
...while avoiding warnings about conversions to bool-like typedefs (sal_Bool
etc.), also in cases where those typedefs are used as type arguments of
template specializations (which is no little feat, and the current code is only
an approximation of it, one that appears to cover the relevant cases in our code
base though).

Change-Id: I0ed3801aec7787bf38b429b66e25244ec00cac9b
2015-04-17 15:20:48 +02:00
Stephan Bergmann
6fcc7efad0 Fix logic to obtain callee's FunctionProtoType (if any)
Change-Id: I1bfdd865429cc6fa89ea3b6b4fc132b5d5b57b0d
2014-06-17 15:51:53 +02:00
Stephan Bergmann
76b114f849 implicitboolconversion: warn about implicit conversion of call args to bool
...to be able to find problems like 6e0bdf04add338b7d5b29fc7b3fc9f08cfd5e96f
"sal_Bool arg of SetUseImagesInMenus was abused to squeeze '2' through it"
earlier when converting occurrences of sal_Bool to bool.

Restricting this check to function call arguments avoids too much noise while
hopefully still catching all the relevant problems.

(This check partially overlaps the pointertobool check, so implicit conversions
from pointers to bool call arguments will now generate two loplugin warnings,
but that's harmless.)

Change-Id: I0b03b1d1615aaf8bc18e7a84c56fff3ef9903508
2014-02-24 17:25:05 +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
Stephan Bergmann
3316202888 implicitboolconversion: support for Objective C BOOL
Change-Id: Id63f42fa8875211af9f41c21f3fa128403f8a880
2014-02-21 23:47:22 +01:00
Matúš Kukan
caedbd44ba one more -Werror,-Wsign-compare
Change-Id: I3139021c07db6efe16895e10c0539a8bc60aac9c
2014-02-14 12:37:45 +01:00
Stephan Bergmann
8edec7c89f -Wsign-compare
Change-Id: I81a7fac291c46a0ee6da76ab3e29c53ad0678b66
2014-02-14 11:30:15 +01:00
Stephan Bergmann
d19598b56c Adapt ImplicitBoolConversion to 32-bit builds (where sal_Int32 is long)
Change-Id: I64480e6026e7e39fe89f90c7d269f6bb1d02968d
2014-02-13 10:49:13 +01:00
Stephan Bergmann
b21e3d16aa Clang API function terminology got changed
...at least in trunk 200400 towards Clang 3.5.

Change-Id: I6e295e3a4cf721fbda9df8e7c5bed3993ee78216
2014-01-31 09:44:46 +01:00
Stephan Bergmann
81760e2702 implicitboolconversion: also warn about redundant explicit casts
Change-Id: Ib89b4c12d2cdca873a9fe9a509d7a123977652a7
2014-01-29 15:42:37 +01:00
Stephan Bergmann
1f078fcadd Prepare dual-mode compiler plugin feature
...which can act as either a rewriter or a non-rewriter that emits warnings.

Also added COMPILER_PLUGIN_WARNINGS_ONLY=X to demote warnings from plugin X from
errors to warnings, even under --enable-werror.

Change-Id: I05361936240a890515c6bba2459565417c1746b7
2014-01-27 13:12:33 +01:00
Stephan Bergmann
cd20baf40a implicitboolconversion: warn about mixing bool with integer
...in &=, |=, ^=, as does MSVC, too.

Change-Id: I57ecc9d784dd483e04ae561c62595b1d0380517f
2014-01-26 12:28:09 +01:00
Stephan Bergmann
8128644312 implicitboolconversion: also warn about mixing bool/sal_Bool in &=, |=, ^=
...as MSVC would warn about those anyway.

Change-Id: If22dfd35bc01aff1a1bef68702c616e711db42fb
2014-01-22 15:00:54 +01:00
Stephan Bergmann
cb710f3a1e implicitboolconversion: also warn about mixing bool/sal_Bool in == etc.
...as MSVC would warn about those anyway (at least about cases that do not
compare against literal sal_True/sal_False, but warning even about those helped
clean up lots of redundant

  if (foo == true)

instead of just

  if (foo)

etc. across the code base).

Change-Id: Iad4b335c35c5411070f04f87f974db7942c288d4
2014-01-22 11:39:22 +01:00
Stephan Bergmann
4865115d1b Improve Clang 3.2 hasCLanguageLinkageType workaround
Change-Id: If5c104adc05aa362d15cedf6f8953bda478897bc
2014-01-22 11:03:30 +01:00
Stephan Bergmann
3c2a6ad96b Make implicitboolconversion.cxx compile with Clang 3.2
Change-Id: I011e74fd044d0b76cccc60adea362805917c584a
2014-01-20 14:32:35 +01:00
Stephan Bergmann
e908f69ec0 Clang plugin that flags implicit conversions from bool
...as they are often enough errors, like a typo in brace placement in

  if (foo == (FOO || bar == BAR) && baz)

or a literal true passed as an argument to a function that rather expects an
integer bit mask, etc.  The plugin is smart enough to detect interaction with
logically boolean return/parameter types of C functions that use [unsigned] int
instead, and knows the relevant boolean typedefs (sal_Bool, gboolean, etc.).

Change-Id: I5f0e4344fe86589bec35a71018c7effdedf85e3e
2014-01-17 18:45:16 +01:00