231 Commits

Author SHA1 Message Date
Stephan Bergmann
362d4f0cd4 Explicitly mark overriding destructors as "virtual"
It appears that the C++ standard allows overriding destructors to be marked
"override," but at least some MSVC versions complain about it, so at least make
sure such destructors are explicitly marked "virtual."

Change-Id: I0e1cafa7584fd16ebdce61f569eae2373a71b0a1
2014-04-01 19:22:54 +02:00
Stephan Bergmann
8e5f5d3eb5 Plugin to warn about/fix verriding functions not marked SAL_OVERRIDE
Change-Id: I1d49aa9ad238cd5bd2e04479c2eb916f010417df
2014-03-27 18:24:44 +01:00
Stephan Bergmann
26f6ff0829 More compat stuff
(currently only used by a not-yet committed plugin, though)

Change-Id: I4cff7eb97dbe10a44a911be9db090ea8cd10d8f0
2014-03-27 10:23:39 +01:00
Luboš Luňák
f7859e5282 fix filename detection in clang plugins
SourceManager::getFilename() returns "<stdin>" whenever icecream is used.

Change-Id: I4e3e1b90880c5fd2b53f20e4ce3e38e3a0486973
2014-03-23 16:26:53 +01:00
Noel Grandin
be878d7cc5 improve warning message in passstringbyref compiler plugin
Change-Id: Ia8470bbd04c841e6c44c182493fede3dc312f635
2014-03-19 08:57:07 +02:00
Noel Grandin
86a32589e9 Find places where OUString and OString are passed by value.
It's not very efficient, because we generally end up copying it twice -
once into the parameter and again into the destination OUString.

So I create a clang plugin that finds such places and generates a
warning so that we can convert them to pass-by-reference.

Change-Id: I5341a6ea9e3190f4b4c05c42c85595e3dcd83361
2014-03-18 08:32:26 +02:00
Stephan Bergmann
f6ff4c955a More compat stuff
(currently only used by a not-yet committed plugin, though)

Change-Id: Id62ea41031ad8ba4495ef46877ad7a10bc58fb05
2014-03-14 12:20:41 +01:00
Stephan Bergmann
d44a3aa976 Save the stdexception rewriter plugin used in...
...5e21a413c788f839a66d9e4c14e745ed18058db8 "retrofit std::exception into
overriding exception specs."

Change-Id: If802bbd26b91438f3f46fe18bc763d27967bac5c
2014-02-28 10:44:53 +01:00
Alexander Wilms
15e0b08ab5 Remove visual noise from compilerplugins
Change-Id: Ibfed0b64bd60804fa377b5e25e5f197a7772d605
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-02-27 11:10:28 +01:00
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
c850cdc1bc Move plain rewriters to store/ (so they don' get built needlessly)
Change-Id: I62d21e9a579bcb9c116bb272fc1236a890216cd9
2014-02-25 16:34:12 +01:00
Stephan Bergmann
cc478960dc salbool: a rewriting plugin that flags most uses of sal_Bool
...that would not lead to silent changes of the code.  That is, it does not warn
about sal_Bool parameters of virtual functions, so that (not yet rewritten)
overrides do not silently become overloads instead.

The plugin is in store/ for now, because not all of the code has been cleaned up
yet.

Change-Id: I6e9b3847eb26c3090f375045188d38097052defe
2014-02-25 10:48:55 +01:00
Stephan Bergmann
6f2774b209 ...but Flags parameter was plain unsigned int prior to Clang 3.4
Change-Id: Ife39abda6b5274ae196dcbf591d02fa3f36f6072
2014-02-25 10:15:28 +01:00
Stephan Bergmann
35f28b706e raw_fd_ostream Flags parameter no longer defaulted
...at least on trunk r202077.

Change-Id: Ieb59cc7ac70e2a57ac13eefdfcbb6bfa42e25218
2014-02-25 08:48:21 +01: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
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
Stephan Bergmann
3316202888 implicitboolconversion: support for Objective C BOOL
Change-Id: Id63f42fa8875211af9f41c21f3fa128403f8a880
2014-02-21 23:47:22 +01:00
Stephan Bergmann
fa4afe020d Handle ImplicitCastExpr w/ invalid loc from Objective C code
Change-Id: I82cb8aa53ea5fd86d6ff46af876dd3f55e1123d1
2014-02-21 23:47:22 +01:00
Stephan Bergmann
411fcfff58 ParentBuilder needs support for ObjCMethodDecl
Change-Id: I8883649da31eabbc5a0f9780fb953ad58f154e1e
2014-02-21 23:47:22 +01:00
Stephan Bergmann
5dcb634dcb Don't attempt to actually do double code removals
...that easily works around the problem that in a rewriter rewriting types of
VarDecls like

   T x, y;

it would try to replace T twice.  Also, keep the list of removals globally with
the (global) rewriter.

Change-Id: I55b8d11986c2a29e09ff40132fd114a0cc48dc90
2014-02-20 19:51:43 +01:00
Stephan Bergmann
6f69fb5d7d Run the non-rewriter plugins even when rewriters are specified
Change-Id: I8262091c52522c54f84c0fac5fd180871d4a3a9f
2014-02-17 17:55:16 +01:00
Stephan Bergmann
f7e335ddb7 const improvement
Change-Id: I03815f33117a2927b1882d221f159a5de8d3ba78
2014-02-14 16:04:31 +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
Matúš Kukan
37facd4f70 Store compilerplugin warning about classes derived from a specific class.
Useful in case someone wants to find all classes deriving from "foo" and "bar".

Change-Id: I7b12882881712d37976eb8c96fad6e9c9ac01370
2014-02-14 11:11:53 +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
Noel Grandin
15535e32dd convert SvStream::operator>> methods to ReadXXX methods
First, I updated the clang rewriter to do the conversion.
Then I lightly hand-tweaked the output for the few places where
the rewriter messed up, mostly when dealing with calls on "this".

Change-Id: I40a6a977959cd97415c678eafc8507de8aa3b1a9
Reviewed-on: https://gerrit.libreoffice.org/7879
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
2014-02-12 15:31:40 +00:00
Andrzej Hunt
b8ca3737fb DiagnosticsEngine::getCustomDiagID isn't const, so don't pass in const engine.
Change-Id: I7e4494b7f1cb62ab27851e34ab4dc6be8e04e1fa
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-01-31 16:42:08 +01:00
Jesús Corrius
82300f367d sbergman's typo
Change-Id: I36dc29659d0d6965c28e5fe0bb03759476de4781
2014-01-31 12:55:13 +01:00
Stephan Bergmann
11235e8649 clang::DiagnosticsEnginge::getCustomDiagID now needs a literal FormatString
...at least in trunk 200400 towards Clang 3.5.

Change-Id: Ibe956a7f28c16510506bd354582b3fe5a72582e5
2014-01-31 09:50:21 +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
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
81760e2702 implicitboolconversion: also warn about redundant explicit casts
Change-Id: Ib89b4c12d2cdca873a9fe9a509d7a123977652a7
2014-01-29 15:42:37 +01: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
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
Stephan Bergmann
0d824b5cc1 compilerplugins: ignore WORKDIR code
...which is typically external or generated code and causes warnings that
we cannot easily fix.

Change-Id: If86ecd96c069ec23c6b3d7f5c32bf962397393e5
2014-01-10 17:11:42 +01:00
Noel Grandin
de84529b55 Clang plugin to re-write SvStream operator<< to non-overloaded methods
Use a clang rewriter to rewrite SvStream::operator<< to methods
like WriteUInt32.
Note that the rewriter is not perfect, and hand-tweaking the output
is necessary.

Change-Id: I0291c8192ca74d6334ed3cf8cb713212b2f0c67d
Reviewed-on: https://gerrit.libreoffice.org/7307
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
2014-01-10 13:26:15 +00:00
Michael Stahl
5d8f48c81e solver doesn't solve anything...
... it is an abbreviation of "Solar Version".

Since nobody can remember that:

remove OUTDIR OUTDIR_FOR_BUILD SOLARVER SOLARVERSION solarpath
and any mention thereof.

Change-Id: Idb3031c4f25a76ac05b22ec67e3ca3e1e8e512ad
Reviewed-on: https://gerrit.libreoffice.org/6515
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2013-10-31 15:42:24 +00:00
Caolán McNamara
3656a57e88 add mode lines to new files (and idls) since last run
Change-Id: Id1e74f18c90e69d1a781c8f02e30dc3c005ed4fd
2013-09-22 12:21:34 +01:00
Luboš Luňák
b0b087cd18 move valueof compiler plugin
The mass-conversion has been already done, so it's most probably
not needed anymore.

Change-Id: I3f161b8ea122e4dd185746ea29509b0d7768d6c7
2013-08-27 18:11:21 +02:00
Luboš Luňák
64b993e046 finish deprecation of O(U)String::valueOf()
Compiler plugin to replace with matching number(), boolean() or OUString ctor,
ran it, few manual tweaks, mark as really deprecated.

Change-Id: I4a79bdbcf4c460d21e73b635d2bd3725c22876b2
2013-08-21 15:10:35 +02:00