156 Commits

Author SHA1 Message Date
Stephan Bergmann
9263b101c3 Activate the "suspicious cast to sal_Bool" parts of loplugin:salbool
Change-Id: I78a368ef2899b2462251b45a327fc7b1f31fe764
2014-07-01 17:49:10 +02:00
Stephan Bergmann
e50ef195bc New loplugin:stringconcat
Change-Id: Id7c517fb37bc28797c45fc0dde83e866f2aa4aac
2014-07-01 15:45:52 +02:00
Stephan Bergmann
e48a233960 loplugin:unreffun: also warn about redundant redeclarations
Change-Id: I9a812220b58cf6da00d854e65794f7c673ab239d
2014-06-27 15:27:39 +02:00
Stephan Bergmann
9a741fcad4 loplugin:unreffun: also warn about unused function templates
Change-Id: I4a6280f47ca3c4a77b4e42fe05d79ded7fc30ef1
2014-06-27 07:51:51 +02:00
Noel Grandin
a74193306a compilerplugins: move isUnoIncludeFile to base class
to reduce copy-pasted code

Change-Id: I7728d85dea7d0161998c326d6648ca681a8250d0
2014-06-24 12:48:17 +02:00
Stephan Bergmann
466ee86cab Clang trunk compat fix
Change-Id: Ic414ad0416e27e223ff702996b796b68d39709b9
2014-06-24 12:32:18 +02:00
Noel Grandin
e2080e70fe new compilerplugin returnbyref
Find places where we are returning a pointer to something, where we can
be returning a reference.
e.g.
   class A {
     struct X x;
     public X* getX() { return &x; }
   }
which can be:
     public X& getX() { return x; }

Change-Id: I796fd23fd36a18aedf6e36bc28f8fab4f518c6c7
2014-06-24 11:34:21 +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
Noel Grandin
3e82897353 improve the inlinesimplememberfunctions clang plugin
Change-Id: I6d5a952901648e01904ef5c37f953c517304d31e
2014-06-17 10:55:17 +02:00
Stephan Bergmann
5f500adec8 loplugin:staticcall
Change-Id: Id46b391c09555c9ec30916fdd93b05455835d81b
2014-06-13 17:54:38 +02:00
Stephan Bergmann
90d8b417ca New loplugin:derefnullptr (all violations already fixed)
Change-Id: I32cd8e740855699036c420a091c282029f8d4a08
2014-06-11 16:34:55 +02:00
Noel Grandin
6921edd448 compile fix
after my commit 184a00b96235f6432294ded63ce4a4a318effdb5
"loplugin: inlinesimplememberfunctions"

Change-Id: Ib46d862b90566506c3035a12eeb01892b225ed51
2014-06-09 11:37:17 +02:00
Noel Grandin
5d1e22d52a improve safety of loplugin inlinesimplememberfunctions
don't try and move functions containing comments

Change-Id: I2de8fc8be851af979acf9d1a91e7cdd9a5dc6a32
2014-06-09 10:10:14 +02:00
Noel Grandin
6f2edd4514 new loplugin: inlinesimpleaccessmethods
Create a rewriting plugin for finding methods that simply return
object fields, and should therefore be declared in the header,
so that the compiler can reduce method calls into a simple
fixed-offset load instruction.

Change-Id: I7a620fc54250b79681918dc31ed9a8f21118c037
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-06-04 14:49:08 +02:00
Stephan Bergmann
909a76c7da New loplugin:inlinevisible to flag inline functions marked DLLEXPORT
...which does not make sense.  On Linux and Mac OS X, they potentially end up
exported from multiple libs (weakly, though), while on Windows the potentially
even end up not emitted at all, which could cause link errors.

Change-Id: I092c9ba39e686c17b6e91581cdd4753f1c4d582f
2014-05-30 14:12:31 +02:00
Noel Grandin
c03efa7c6c loplugin-passbyref: ignore non-base declarations
Only consider base declarations, not overriden ones, or we warn on methods that
are overriding stuff from external libraries.

Change-Id: I08791c96f7adba5997ad237a98e7c08a759042ad
2014-05-22 07:54:54 +02:00
Noel Grandin
8d54796bf1 enhance pass-by-ref plugin to detect large arguments
Detect arguments larger than 64 chars passed by value.

Change-Id: I9b0ea9ccb99d115984a26eab67c9cf6afd5f6cae
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
2014-05-20 11:17:22 +02:00
Noel Grandin
97d50c425f combine the pass-by-ref clang plugins
Change-Id: Idac24afb7cb67fa2d539553fb9fa049c2d61ecf0
2014-05-16 11:18:45 +02:00
Noel Grandin
248145f99e Find places where uno::Sequence is passed by value.
Implement a clang plugin to find them, and clean up existing code
to pass them by reference.

Change-Id: If642d87407c73346d9c0164b9fc77c5c3c4354b8
Reviewed-on: https://gerrit.libreoffice.org/9351
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2014-05-14 08:10:22 +00:00
Thomas Arnhold
72bc94cc8b salbool: fix comment
accidently removed by 5babf1b9037eb283798322eecd8334e6ff1db655

maybe obsolete now

Change-Id: Id1b8ce21e08ce2df5668252406bad6fb549b5206
2014-04-15 21:22:05 +02:00
Stephan Bergmann
e5199d3d78 Flag unreferrenced functions only declared in the main file, not an include
...which appears to be a good heuristic to identify functions that are either
unused or should better be declared just once in an include file.  (It also
filters out SAL_DLLPUBLIC extern "C" function definitions, which are most likely
meant to be referenced dynamically via dlsym.)

Change-Id: I7fb78cb836b971791704851535dcfbda2b2f5bc0
2014-04-15 16:57:23 +02:00
Stephan Bergmann
b2ecb3485b Better be specific
Change-Id: Ibb9b5b8f53ab8fdeba6d3db295339ead4bde7b6e
2014-04-15 15:42:00 +02:00
Noel Grandin
ffbc86f5ac add "include/comphelper" to list of includes to ignore
since it only contains a single sal_Bool site now, and we want
to leave that alone since it's a copy of similar stuff in cppuhelper.

Change-Id: I3cf4cf5f67e95d5b6f70371181f77c5451fcbf50
2014-04-15 15:23:28 +02:00
Noel Grandin
5babf1b903 remove unnecessary scope qualifier from sal_Bool uses
i.e. convert "::sal_Bool" to "sal_Bool"

Change-Id: Ie5943aee4fee617bf2670655558927ed25b7e067
2014-04-03 13:54:02 +02:00
Stephan Bergmann
b4e5b8bc1d Add compat::isInMainFile
Change-Id: I0e155c6c68a43020110a8e1c0cb29cabdcade454
2014-04-02 17:53:43 +02:00
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