Commit Graph

57 Commits

Author SHA1 Message Date
Noel Grandin
9f4d23c151 filter out some of the AST in the plugins
by checking if the current namespace decl is in our code, so we have to
scan less stuff, which results in a 10% perf improvement for me

Change-Id: Idf0e30d57b6d0dcd13daa9ed679c28b9d233d387
Reviewed-on: https://gerrit.libreoffice.org/58942
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-14 13:02:14 +02:00
Stephan Bergmann
3cc5149a84 Avoid -Werror=deprecated-declarations with recent Clang trunk
...which first added alternative names to and then deprecated getLocBegin/End

Change-Id: Iaefb8ce259057abfa6cd20f0b63c0ef2949a96b2
Reviewed-on: https://gerrit.libreoffice.org/58820
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-08-10 15:14:03 +02:00
Stephan Bergmann
ae39b1ef2d Further loplugin:redundantcast improvements for floating-integer conversions
The code in svx/source/customshapes/EnhancedCustomShape2d.cxx started out as

> aStart.X() = (sal_Int32)( ( (double)( aStart.X() - aCenter.X() ) / fXScale ) ) + aCenter.X();
> aStart.Y() = (sal_Int32)( ( (double)( aStart.Y() - aCenter.Y() ) / fYScale ) ) + aCenter.Y();
> aEnd.X() = (sal_Int32)( ( (double)( aEnd.X() - aCenter.X() ) / fXScale ) ) + aCenter.X();
> aEnd.Y() = (sal_Int32)( ( (double)( aEnd.Y() - aCenter.Y() ) / fYScale ) ) + aCenter.Y();

in afd1cf255d "INTEGRATION: CWS sj05", then the
floating-point scaling factors got gradually removed first with
101559f880 "INTEGRATION: CWS bm3" and then
completely with d9f21c90bd "Fixes Circular arrow
distortion, Bug #46272".

Change-Id: I337d7893e513738c986d0e85efabcbf7bab912e5
Reviewed-on: https://gerrit.libreoffice.org/54434
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2018-05-17 08:23:37 +02:00
Stephan Bergmann
7ab34b51f2 loplugin:redundantcast improvements for floating-integer conversions
Change-Id: I63dbf18f144a792ae775fe6706da81657f790016
Reviewed-on: https://gerrit.libreoffice.org/54416
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2018-05-17 08:22:14 +02:00
Stephan Bergmann
8789f4f65b Check isOkToRemoveArithmeticCast in loplugin:redundantfcast too
...to avoid warnings like

> C:/lo64/core/svx/source/table/accessiblecell.cxx(400,12):  error: redundant functional cast from 'long' to 'sal_Int32' (aka 'long') [loplugin:redundantfcast]
>     return sal_Int32(0x0ffffffL);
>            ^~~~~~~~~~~~~~~~~~~~~

with clang-cl

Change-Id: I4a48a9f10ad75f76a3c6ab6152ab279df9a3fbcc
Reviewed-on: https://gerrit.libreoffice.org/51780
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2018-03-23 16:11:49 +01:00
Stephan Bergmann
9663341f92 Bump --enable-compiler-plugins to Clang 3.8.0
<https://lists.freedesktop.org/archives/libreoffice/2017-December/079107.html>
"Clang baseline bump"

Change-Id: I18fca8794ea34118fc6308458064d0c28cf5caf7
Reviewed-on: https://gerrit.libreoffice.org/46557
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-12-19 22:08:38 +01:00
Stephan Bergmann
306ddfb1b8 Replace deprecated std::mem_fun et al in reportdesign
(as std::mem_fun is gone by default at least from recent libc++ in C++17 mode)

Change-Id: Ib66134bd4072dfe0ce3bc36aa684cee710921235
Reviewed-on: https://gerrit.libreoffice.org/45868
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-12-05 18:11:15 +01:00
Stephan Bergmann
b35bb38f18 Clean away temporarily added using declarations
Change-Id: I26734c13515394162d88351a1cbe2b20abdac865
2017-11-07 11:50:47 +01:00
Stephan Bergmann
5807952ef7 loplugin:redundantcast: Do warn about convoluted dynamic_cast to self
...that the compiler is free to elide anyway.  (See
4e7ffc0a69 "Avoid compiler eliding#redundant
dynamic_cast" and 380d6afe5f "Remove redundant
asserts involving dynamic_cast".)

Change-Id: I3f75154fee3e978b7ba95a5a27589417065599bd
2017-10-22 11:57:44 +02:00
Noel Grandin
ead920a48a loplugin:redundantcast handle dynamic_cast
Change-Id: I7855c76e820efce96778b1c19ec71dffcc4b4abb
Reviewed-on: https://gerrit.libreoffice.org/43621
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-10-21 15:44:11 +02:00
Stephan Bergmann
d883e3556a loplugin:redundantcast: cstyle_cast within reinterpret_cast
Change-Id: Ie31c9dd6d8741aa856553b798bb5b7f695a3fe0f
Reviewed-on: https://gerrit.libreoffice.org/42776
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-26 10:01:54 +02:00
Stephan Bergmann
7282b25f22 Fix loplugin:redundantcast's VisitCXXFunctionalCastExpr
...when t1 is ElaboratedType sugar (which isn't only used when the type is
written with an elaborated type keyword, but also when it is written with a
qualified name).

(I originally wrote testArithmeticTypedefs to track down a different issue,
which turned out to be a non-issue, with this fix as fall-out.  So that test
doesn't quite match the theme of this commit, but is a worthwhile addition
nonetheless.)

Change-Id: Ic447da4399853d7d045e3e2e7ade8ddf52d89749
2017-09-15 18:50:45 +02:00
Noel Grandin
5685ee25aa improve redundantcast loplugin
to find c-style casts where the expression is a templated method

Change-Id: Ifbd1e2cdc72d906fc95a7ec0f9408c3f6d2a836b
Reviewed-on: https://gerrit.libreoffice.org/42275
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-09-14 14:43:43 +02:00
Stephan Bergmann
c5616014bb loplugin:redundantcast: suppress warnings in reworked glibc assert macro
Change-Id: I20be230b3ff5d11395f33a9896d0a575c3051fb7
2017-08-25 20:21:25 +02:00
Stephan Bergmann
d7a9abdce5 Report full type info (plus the desugared type as "aka")
Change-Id: I647b1c3e479e0be01ed7ea16e1ad3dd9bed9ba6a
2017-08-18 10:23:42 +02:00
Noel Grandin
3281628e1c loplugin:redundantcast ignore functional casts involving typedefs
<sberg> noelgrandin, 718cdd43c2 now also
looks through typedef sugar, e.g. complaining about a gdouble -> double
expl. conversion in configmgr/source/dconf.cxx;
I think we want to remain silent about such conversions involving typedefs
<noelgrandin> sberg, ah, good point.

Change-Id: Icbb0d6be273f53e507c91556cf0ccb5a5c03e5a1
Reviewed-on: https://gerrit.libreoffice.org/41175
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-15 15:45:34 +02:00
Noel Grandin
718cdd43c2 loplugin:redundantcast, find more functional casts
In the enum types that caused the problem look like this when I dump
then:

EnumType 0xdb45770 'enum SvxFrameDirection'
`-Enum 0xdb456d8 'SvxFrameDirection'

SubstTemplateTypeParmType 0xdb61200 'enum SvxFrameDirection' sugar
|-TemplateTypeParmType 0xd7518f0 'EnumT' dependent depth 0 index 0
| `-TemplateTypeParm 0xd7518a8 'EnumT'
`-EnumType 0xdb45770 'enum SvxFrameDirection'
  `-Enum 0xdb456d8 'SvxFrameDirection'

Change-Id: Id8fedabe43b7a27df61a2320a9acbf54d2dc7882
Reviewed-on: https://gerrit.libreoffice.org/41169
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-15 13:46:29 +02:00
Stephan Bergmann
0f84a32f5b Improved loplugin:redundantcast, const/static_cast combinations
Change-Id: I3b24327835cd4e1842ee6e9b87ab06efa25a4bbf
2017-06-05 21:17:59 +02:00
Stephan Bergmann
0763d8413e Reduce loplugin:redundantcast warnings about functional casts even futher
Change-Id: I8884e17c453831e048c43012ee176093c5b2f99e
2017-06-05 21:17:55 +02:00
Andrea Gelmini
ac341548dc Fix typos
Change-Id: I9eb05432732a04e816946fbb13001df100a31f73
Reviewed-on: https://gerrit.libreoffice.org/38395
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2017-06-05 17:58:20 +02:00
Stephan Bergmann
c855400e96 Reduce loplugin:redundantcast warnings about functional casts even futher
Change-Id: Ieae9b5c9c7c6d9b8459e5d163f55d8f5024adfae
2017-06-02 14:00:08 +02:00
Stephan Bergmann
95645cbf0a Improved loplugin:redundantcast const_cast handling
Change-Id: I4c24ff5d9d5e74bef2a4040c6308c504282af55d
2017-06-02 13:31:37 +02:00
Stephan Bergmann
1fce984051 Make loplugin:redundantcast functional cast warnings more verbose
(useful when types involve typedefs)

Change-Id: I93e8962fd4b9c4ef79990e057dfa07538380008c
2017-06-02 10:35:05 +02:00
Stephan Bergmann
beae2dd6c8 Improved loplugin:redundantcast static_cast handling
Change-Id: I74e4ebda40f95661c5ae344132fcabbbf08ab0a4
2017-06-02 09:38:15 +02:00
Stephan Bergmann
93aeaa75a4 Improve suppression of loplugin:redundantcast in CPPUNIT_ASSERT
Change-Id: I65f95e7245f08592ea11cc75e1cf34dcbdf16b40
2017-06-01 14:37:02 +02:00
Stephan Bergmann
bef247d137 DataRecursionQueue was only introduced in Clang 3.8
(r253948 "Use data recursion in RecursiveASTVisitor when traversing Stmt and
Expr nodes")

Change-Id: I393474048ecbe0f6b7f19f00c2f830f495b2b6f0
2017-05-31 09:18:08 +02:00
Stephan Bergmann
7d858ad057 Restrict loplugin:redundantcast to "real" casts
Change-Id: Ifc9de898e5c9a084cbfd739625c679185c3a1534
2017-05-30 15:46:55 +02:00
Stephan Bergmann
3dda91dda8 Traverse InitListExpr only once
Arbitrarily chosing to traverse the semantic instead of the syntactic form.

Change-Id: Id1b4e49421a5550bb2fa9f0d7e6f83bf7abb6ebb
2017-05-30 14:39:23 +02:00
Stephan Bergmann
f6dda4e160 Make loplugin:redundantcast accept bool(FD_ISSET(...)) again
Change-Id: I4e96c55c246cf806f17df31844a00d0e8a5e4f56
2017-05-30 13:40:53 +02:00
Noel Grandin
2ccde70d60 teach redundantcast plugin about functional casts
Change-Id: Iac8ccd17d9e46ebb2cb55db7adb06c469bbd4ea0
Reviewed-on: https://gerrit.libreoffice.org/37910
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-05-30 08:50:31 +02:00
Stephan Bergmann
8b1fcedcd1 ...and re-eanble loplugin:stringcopy again
<http://reviews.llvm.org/D22128> "Make CastExpr::getSubExprAsWritten look
through implicit temporary under CK_ConstructorConversion" was biting me again.
(I had originally developed loplugin:stringcopy against a Clang build that
includes my local fix for that issue.  I really need to see to get that resolved
upstream...)

(And while 9578741684 "loplugin:stringcopy" was
actually a false positive, it doesn't hurt either, so just keep it.)

Change-Id: I726956adfbe67681005173cfdfed2e4b4cd6253d
2017-05-19 23:57:03 +02:00
Noel Grandin
f12096272e spelling, implictly->implicitly
Change-Id: I2d733ed3ce9395d11700d739cbd6d123649b4013
2017-05-03 11:18:21 +02:00
Noel Grandin
be8b9b4d29 loplugin:redundantcast find cstyle arithmetic casts
Change-Id: If7c259f0d12a41182f476ddb558f7cb5f76f9577
Reviewed-on: https://gerrit.libreoffice.org/36253
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-07 12:16:13 +00:00
Noel Grandin
26e7c6d6ab loplugin:redundantcast check for c-style char casts
Change-Id: Id6881262e370fd563ec29db95e4af5cfcb04ea34
Reviewed-on: https://gerrit.libreoffice.org/36247
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-07 07:07:40 +00:00
Stephan Bergmann
6b4a4bab6d Improved loplugin:redundantcast, static_cast on arithmetic types
Change-Id: I6e1f76de4b1ebf76ad02e7d0cd1374b4def83932
2017-04-06 18:33:20 +02:00
Noel Grandin
6768a9b602 loplugin:redundantcast check for c-style casts to void
Change-Id: Ic8b99f590436f94825e471bc61411c69fd768862
Reviewed-on: https://gerrit.libreoffice.org/36208
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-06 13:03:06 +00:00
Noel Grandin
f1945405b0 loplugin:redundantcast check for c-style float casts
Change-Id: I86b6f58887cb398a80698f8d8564b5bc3f55eabb
Reviewed-on: https://gerrit.libreoffice.org/36198
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-06 11:41:46 +00:00
Noel Grandin
7662e92c64 loplugin:redundantcast find cstyle double casts
Change-Id: I5507be190dac781e5cdb545a60acf3d50056c9f8
Reviewed-on: https://gerrit.libreoffice.org/36187
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-06 07:47:30 +00:00
Noel Grandin
572e9cde74 loplugin:redundantcast find c-style bool casts
Change-Id: I3237b93babc67de12c3771aa84766c2141ca93b2
Reviewed-on: https://gerrit.libreoffice.org/36137
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-04-05 12:21:19 +00:00
Stephan Bergmann
3c7652203c Teach loplugin:redundantcast about C-style casts in macro bodies
Change-Id: Ic1fbc8dd16c4d78772fc11a9c2ce09f056e36c79
Reviewed-on: https://gerrit.libreoffice.org/35680
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-03-25 12:51:54 +00:00
Noel Grandin
ed76d1d350 loplugins:redundantcast teach it about c-style typedef casts
Change-Id: I1ac11a2481c0f4d8be1e1fd7c7637ac0ece3d65c
Reviewed-on: https://gerrit.libreoffice.org/35558
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-03-23 09:48:10 +00:00
Noel Grandin
7299481834 loplugin:redundantcast find redundant c-style enum casts
Change-Id: I2dab376d87804521aed6b6bd41ad7762830fa349
Reviewed-on: https://gerrit.libreoffice.org/35467
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-03-22 06:47:35 +00:00
Stephan Bergmann
be06700309 Silence loplugin:redundantcast false warning
...that is curiously only reported when building with clang -std=gnu++17:

> sc/qa/unit/ucalc_condformat.cxx:185:80: error: redundant const_cast from 'ScConditionalFormat *' to 'const ScConditionalFormat *', result is implictly cast to 'const ScConditionalFormat *const' [loplugin:redundantcast]
>     CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong conditional format instance.", pCheck, const_cast<const ScConditionalFormat*>(pFormat));
>     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> workdir/UnpackedTarball/cppunit/include/cppunit/TestAssert.h:230:32: note: expanded from macro 'CPPUNIT_ASSERT_EQUAL_MESSAGE'
>                               (actual),                \
>                               ~^~~~~~~
> 1 error generated.
> make[1]: *** [solenv/gbuild/LinkTarget.mk:270: workdir/CxxObject/sc/qa/unit/ucalc_condformat.o] Error 1

Change-Id: If2e8577bad4ec7454d584eb59106734d47f876ad
2017-02-16 17:56:08 +01:00
Stephan Bergmann
440720e14d loplugin:redundantcast: Avoid double warnings on some const_cast
Change-Id: I1e6140fef55054899dd32465726e804fc6006394
2017-02-16 17:43:23 +01:00
Stephan Bergmann
0f22790e6b Generalize typedef-to-void* check in loplugin:redundantcast
...to also cover cases like conversion betwen LPVOID and HANDLE in Windows-only
code

Change-Id: I934fe89372ee7a12462e7ad4284b9ea2cc73ce5a
2016-12-18 22:43:26 +01:00
Stephan Bergmann
9d80c032fe loplugin:redundantcast: redundant static_casts
Change-Id: I4d50b77745d68a23136221ef06f327137e89fa7e
2016-07-08 16:47:31 +02:00
Stephan Bergmann
733198de1b Remove support for Clang < 3.4
Change-Id: I81e97c5f720535b33dd3ce72d01151765e4e93a0
2016-06-29 09:15:25 +02:00
Stephan Bergmann
1ce7176ba1 Remove support for Clang < 3.3
Change-Id: I185852a738bac10dc6d331afccfcbc7ae1225cb1
2016-06-29 08:55:27 +02:00
Stephan Bergmann
779f06f9a8 Ambiguity between clang:: and llvm::PointerType
Change-Id: I2727ef17b9ab780c608878aaca9ce0fda01b9c22
2016-03-20 13:29:50 +01:00
Stephan Bergmann
0571f3c503 loplugin:redundantcast: const_cast to same type
Change-Id: I1abdc2ab0b145e12f7fb00db529f52c11e4d7cfd
2015-05-29 12:05:09 +02:00