231 Commits

Author SHA1 Message Date
Noel Grandin
c4a9241f72 new clang plugin: staticmethods
Genius suggestion from Tor Lillqvist, write a clang plugin that finds
methods that can be static.

Change-Id: Ie6684cc95d088e8750b300a028b49f763da00345
2015-03-27 10:51:08 +02:00
Stephan Bergmann
1c78277801 const_cast: convert some C-style casts and remove some redundant ones
Change-Id: I876736d18db6676629c283fccd65e1b6fb2bb2be
2015-03-26 15:33:41 +01:00
Noel Grandin
6aa542445f move the constantfunction plugin into /store
as sberg points out, it needs a massive blacklist, which is going
to be a pain to maintain. Until I can think of a way to make this
more resilient, move it where it can't bother people.

Change-Id: I64fc498146a3cb4ea9c1e37150c4ef50023b7bd5
2015-03-26 14:24:43 +02:00
Stephan Bergmann
1f1ce7e01a loplugin:constantfunction: vcl/unx/gtk3
Change-Id: I66ffc0c3a73d45e9d4b54f46092a65913b753d26
2015-03-26 10:52:35 +01:00
Stephan Bergmann
6409db7838 loplugin:constantfunction: vcl/unx/gtk3
Change-Id: Ieedf89bebb59e783dfe13ef2d5ae7ba3347cdc62
2015-03-26 10:30:52 +01:00
Stephan Bergmann
82f4f6b19f loplugins:constantfunction: properly detect overloaded operators
Change-Id: I484e1206d1f17305d21f7e750b8aca9d1c8d809b
2015-03-26 09:25:13 +01:00
Stephan Bergmann
44753f7cf0 Expr::EvaluateAs... does not work for type-dependent expressions
Change-Id: Iea1cd468528d00ffa07e13b2063ca5fce5cc4fae
2015-03-25 21:37:48 +01:00
Noel Grandin
c7a50d072f new constantfunction loplugin
Change-Id: Ie9b7a0c41fc4dbd2560ceff6bae9ab85357f518b
2015-03-25 08:55:31 +02:00
Noel Grandin
5229726b4d loplugin: add Dialog to unusedvariablecheck
so that we find dialog that have been instantiated but not actually
executed

Change-Id: Ia308e832780627c0a8de71a9d64dabcb3b861a9c
2015-03-17 11:15:28 +02:00
Stephan Bergmann
62b124b270 Ensure RTTI symbol visibility for Linux Clang -fsanitize=function,vptr
The problem being that any lib later loaded via osl_loadModule (e.g.,
libgcc3_uno.so) would not bind to the same global (RTTI-related) symbols as
libsofficeapp.so and its dependencies (so, e.g., -fsanitize=function would
erroneously assume that bridges/source/cpp_uno/shared/component.cxx's
uno_initEnvironment is called with a different, non-matching uno_Environment
type).

Change-Id: I08b0cbc1f9eb74641eb617c46587a0a528a56c31
2015-03-11 10:56:06 +01:00
Stephan Bergmann
5035225803 Fix copy/paste error
Change-Id: I3fd9d6447adfa365a823ca6e87f0939670bcb39b
2015-03-11 10:56:06 +01:00
Stephan Bergmann
24a89b2772 Improve loplugin:passstuffbyref
Change-Id: I88ab4c51ff59312127681d3087d22b9c79192b94
2015-03-03 08:56:01 +01:00
Stephan Bergmann
88a031e593 Missing initialization
Change-Id: I45eabbe9d1a4e3f85f16c2869c4031fc06f5ef31
2015-03-02 17:47:23 +01:00
Stephan Bergmann
9e6c2369a1 plugin:literaltoboolconversion: Recurse into comma operator's rhs
...inspired by <http://www.viva64.com/en/b/0308/#ID0EE4BI>'s V639 finding.

Change-Id: I3b49f00dd4a593ed0b94d81398fa89ff64f6c79b
2015-03-02 17:14:33 +01:00
Stephan Bergmann
193957750a Adapt compilerplugins to Clang trunk towards 3.7
Change-Id: I5b41039bf63a4c2f313fe7a57c0f6934dcb0752d
2015-02-26 17:22:01 +01:00
Stephan Bergmann
92db2f17b3 Adapt loplugin:passstuffbyref to Clang 3.2
Change-Id: I24d0b7531feba32f86f761daf18170397cfe5d2f
2015-02-09 10:40:19 +01:00
Stephan Bergmann
a6f8766d35 loplugin:deletedspecial (Mac OS X)
Change-Id: Ia09e2e7b3e40bd04da64b52fe29258017b90b156
2015-02-07 17:24:43 +01:00
Stephan Bergmann
d2e9b222d7 loplugin:deletedspecial to help add SAL_DELETED_FUNCTION annotations
...to special member function declarations that were left undefined.  Helps
compilers do a better job at identifiying unused class members.  This plugin
uses heuristics and whitelists do identify applicable declarations, but is not
appropriate for "unattended" use so is placed into store/.

The following commits contain the results of running this plugin, per module:

* Declarations of undefined special member functions are mmarked
  SAL_DELETED_FUNCTION (aka "= delete", which is deemed superior to deriving the
  class from boost::noncopyable, cf. Howard Hinnant's reply to
  <http://stackoverflow.com/questions/7823990/what-are-the-advantages-of-boostnoncopyable>.

* Any redundant "explicit" or SAL_DLLPRIVATE markers are removed from the
  deleted definitions.

* Some redundant declarations of undefined default ctors are simply removed;
  smelled like clueless cargo-cult to have them declared at all.

* Some declarations of undefined operator == etc. are left in (and marked
  SAL_DELETED_FUNCTION) for now, to be on the safe side, though they are likely
  clueless cargo-cult, too.

* Most "static-only" classes are replaced with namespaces (and some where that
  would be non-trivial due to private members are marked TODO for later).

* Newly identified unused class members are removed.

Change-Id: Ibeaae4fd579d7a0971a2c2a654a2263acd13414a
2015-02-07 12:35:55 +01:00
Stephan Bergmann
0a1c6d4554 Extend loplugin:passstuffbyref to handle lambdas
...even if it is known to be dangerous

Change-Id: Ied96284e33b966bf072d0961054479ec7f891dea
2015-02-05 16:54:10 +01:00
Stephan Bergmann
331faca18e Extract loplugin:redundantcast from loplugin:cstylecast
Change-Id: I08f17dd9cc092206083ff41bbbc178e0322e86d0
2015-01-29 22:21:04 +01:00
Stephan Bergmann
4e3da621fe Some more loplugin:cstylecast clean-up
Change-Id: I132d22e2af3cf673c17d8964f690d48990834884
2015-01-28 13:50:37 +01:00
Noel Grandin
414d84232d move these plugins into /store
we don't need to run them on an ongoing basis, and the current code
does not compile with older versions of clang.

Change-Id: I07ccacf7ff7b00e8e2453fff91a3f487dd5abed9
2015-01-26 09:39:18 +02:00
Noel Grandin
b44cbb26ef new loplugin: change virtual methods to non-virtual
Where we can prove that the virtual method is never overriden.

In the case of pure-virtual methods, we remove the method entirely.
Sometimes this leads to entire methods and fields being
eliminated.

Change-Id: I138ef81c95f115dbd8c023a83cfc7e9d5d6d14ae
2015-01-26 08:42:28 +02:00
Stephan Bergmann
3adaad3e36 loplugin:cstylecast: Warn about more of the potentially suspicious ones
Change-Id: Id7a596344c21e9265e35188c477e60ce510bcc6e
2015-01-22 08:13:42 +01:00
Stephan Bergmann
31498259bb loplugin:cstylecast: warn about certain redundant reinterpret_casts
Change-Id: Iaa46849742c215798722d03d9ee59bb39d8033f7
2015-01-09 16:42:42 +01:00
Tor Lillqvist
5d17e1ec85 Fix typo
Change-Id: Ifdbcbcc51c29dc14b2a3b4c845481b45300313d6
2015-01-08 12:41:26 +02:00
Stephan Bergmann
44d0e286c8 loplugin:cstylecast: improve detection of C code
Change-Id: Id5dd1ee1a29c4e1c7cb2b58419d6ccb1f032bffe
2015-01-08 10:59:39 +01:00
Stephan Bergmann
61e02d6ffc loplugin:cstylecast: No need to exclude include/cppuhelper
Change-Id: Ie74be926c1e071fa9b311920b1cf1d4dd5bbd30d
2015-01-07 20:26:04 +01:00
Stephan Bergmann
a4b0078ba9 tools/solar.h already filtered out via filename.endsWith(".h")
Change-Id: I8a4483a6425f51fea0eae5c809c6c41ef56388a2
2015-01-07 14:42:08 +01:00
Stephan Bergmann
25fb442651 loplugin:cstylecast: bridges
Change-Id: I7c41b90c9af045fd452ee62ed0c5d9b261236855
2015-01-07 14:42:07 +01:00
Stephan Bergmann
7b1261f6f9 loplugin:cstylecast: sal
Change-Id: I0ad9681a8b31d78cefce5b66040415154a1c7a99
2015-01-07 14:42:07 +01:00
Stephan Bergmann
1887d4f5e9 Minor beautification
Change-Id: I1300d1d696878c1b646decc2841f13d489d3cadc
2015-01-07 14:42:07 +01:00
Stephan Bergmann
52e5b6e38a loplugin:cstylecast: Exclude only sal, not salhelper
Change-Id: Ib09f2b794ce7a1e650275750a67c6c8ad5d7c808
2015-01-07 14:42:07 +01:00
Stephan Bergmann
1b9d9680d9 Work around loplugin:cstylecast under -fsanitize=*
Change-Id: I467d032296607d22e850c95e56c452fe7e62cebe
2015-01-06 14:34:34 +01:00
Stephan Bergmann
f569c4197c Improve loplugin:revisibility
(for non-Windows--only code, as MSVC would complain about such cases anyway)

Change-Id: Id6daf61b79bd31529bdaeb7c6df4f354731ae7d7
2015-01-05 17:25:51 +01:00
Stephan Bergmann
9720e8e5ef Some loplugin:revisibility clean-up
Stumbled across such redundant visibility re-specifications when looking at the
odd case of cppu_unsatisfied_iquery_msg declared CPPU_DLLPUBLIC in
cppu/source/cppu/cppu_opt.cxx and used in inline code in
include/com/sun/star/uno/Reference.hxx with only a declaration lacking
CPPU_DLLPUBLIC visible, and wondering how that actually works on Windows.

However, this plugin is probably not worth it being run all the time, so
committing it to compilerplugins/clang/store/.

Change-Id: Ibc3c4e7499213de1b419ce7eb85455cb832e1510
2015-01-05 13:10:48 +01:00
Stephan Bergmann
f266c81b2d Don't call isIntegerConstantExpr if isValueDependent
...some paths trough clang::Expr::isIntegerConstantExpr (esp. if
non-CPlusPlus11) assert the assumption that the given expr is not
value-dependent, so it appears to be a prereq

Change-Id: Ibc5fe472ea3f91b31c8cb7f06c4b7c7f4d6831a3
2014-12-21 22:00:40 +01:00
Stephan Bergmann
2a52591bfe Extend loplugin:literalalternative to loplugin:stringconstant
Change-Id: Ie425af19019126b6a15ac03f52e32d186a46db35
2014-12-19 10:03:52 +01:00
Stephan Bergmann
a349a4763f loplugin:saloverride does not make sense for external code
...where SAL_OVERRIDE is not available

Change-Id: I49d447ba90516f4f744c21302607bff97ad3c4d5
2014-12-18 17:29:31 +01:00
Stephan Bergmann
afcac82eea loplugin:cstylecast: warn about casts involving incomplete types
...the worst kind of all

Change-Id: I6b98a324735a79ed9060003b491acce733f74f06
2014-12-07 15:18:08 +01:00
Noel Grandin
c20a0120d8 move the cstylecast clang plugin out of /store
Change-Id: Iee78bd688ddb3e02deb1a3636d6a604838e97b09
2014-12-04 13:38:53 +02:00
Stephan Bergmann
a0db0648f6 Problematic casts in gendata.hxx are already under control
Change-Id: If3b0f667b379b7973364c93be4b88347e5768223
2014-12-04 11:57:31 +01:00
Noel Grandin
14c94c97ff cstylecast plugin - exclude some more files
Change-Id: I4dc6cc7f461fa11d12bf6fd9700befe4bbdac62c
2014-12-04 11:19:19 +02:00
Stephan Bergmann
eff69c6b4c Run loplugin:cstylecast on C++ and Ojbective C++ code
Change-Id: I4035318d35d468fa93d4dcfe56f9b0434fd1dfe7
2014-12-04 08:22:09 +01:00
Bjoern Michaelsen
6e226f5ed8 also look for cascading assignments
Change-Id: I7fa18403698530eec379589c76631f0aa367b215
Reviewed-on: https://gerrit.libreoffice.org/12991
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2014-11-20 18:17:03 +00:00
Bjoern Michaelsen
395d6a96aa cascading conditional operators, give a hint on complexity
Change-Id: Ie9d0b07a32cc17705db735ea18f70f28d57badd4
Reviewed-on: https://gerrit.libreoffice.org/12990
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2014-11-20 18:16:02 +00:00
Bjoern Michaelsen
b736204f3b add clang plugin for detecting cascading condops
Change-Id: I1b782bb04b09bee5c3db2261f9390a7b2edf4564
Reviewed-on: https://gerrit.libreoffice.org/12967
Reviewed-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
Tested-by: Björn Michaelsen <bjoern.michaelsen@canonical.com>
2014-11-19 14:58:40 +00:00
Andrea Gelmini
da40cac540 Fix common typos. No automatic tools. Handmade…
Change-Id: I1ab4e23b0539f8d39974787f226e57a21f96e959
Reviewed-on: https://gerrit.libreoffice.org/12164
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2014-11-12 11:04:11 +00:00
Noel Grandin
5f15cc01b3 new loplugin: use more efficient find() methods
(Original idea from Kendy)
Look for code that is calling std::find on a sorted container
(set/map/vector) and warn about it - the code should be using
the find method on the container itself, since that is considerably faster.

Change-Id: Ib74e5d3faa836eeb0df16a736d202696626bdfd2
2014-11-05 15:59:23 +02:00
Stephan Bergmann
a995f82799 Remove excess [%1 %2] that doesn't match any arguments
...and is apparently a leftover from temporary debug output in
e36badb98d0bb5866a297cb51c3e95cdce62d8da "Fix workaround for bug in Clang 3.2
FunctionDecl::isInlined."

Change-Id: I3213981c5d236a7b67083014692566f75a2bcd51
2014-10-01 17:35:12 +02:00