18 Commits

Author SHA1 Message Date
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
a94a0b148c Could swear I'd seen this produce a bogus compiler error
...but now it apparently works

Change-Id: Iac1b4e49788ac620ed55dec7a52c839ba2937f5b
2016-06-14 08:43:03 +02:00
Stephan Bergmann
8110dd24d1 Fix loplugin:passstuffbyref to not warn when ref param is bound to ref
cf. d150eab88ee26d5c05a6d662a2c13c6adea8ad78 "loplugin:passstuffbyref: For now
disable 'pass parm by value' warnings".  At least all the other changes in
4d49c9601c9b3e26a336e08e057d299895683480 "Let loplugin:passstuffbyref also look
at fn defn not preceded by any decl" were OK but the one reverted with
b3e939971f56d53e60448a954a616ec295544098 "coverity#1362680 Pointer to local
outside scope".

Change-Id: I022125fbcb592e7da3c288c0fd09079dd2e87928
2016-06-13 19:26:56 +02:00
Stephan Bergmann
d150eab88e loplugin:passstuffbyref: For now disable "pass parm by value" warnings
That needs fixing, to check that the parm is not bound to a reference, cf.
<https://gerrit.libreoffice.org/#/c/26189/> "coverity#1362680 Pointer to local
outside scope".

Change-Id: I3656354ccd10affafa006c9e46cf1db608b5b2a7
2016-06-13 09:22:13 +02:00
Stephan Bergmann
4d49c9601c Let loplugin:passstuffbyref also look at fn defn not preceded by any decl
Change-Id: I752bc96d2d521d790e919283cabb14b6526626f4
2016-06-08 17:14:34 +02:00
Noel Grandin
f3d9aab841 teach passstuffbyref plugin to check for..
unnecessarily passing primitives by const ref.

Suggested by Tor Lillqvist

Change-Id: I445e220542969ca3e252581e5953fb01cb2b2be6
Reviewed-on: https://gerrit.libreoffice.org/24672
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-05-06 06:48:38 +00: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
Noel Grandin
b0c435f88b turn on the passstuffbyref plugin again
now that I have committed all of the changes to return types it
found

Change-Id: Iaee121037ce83e94001e4591d232b075dfeade7c
2016-04-14 12:00:10 +02:00
Noel Grandin
7573abfdef update loplugin passstuffbyref to check return types
of methods like
   Foo getFoo() const { return m_foo; }
where we can rather do
   const Foo& getFoo() const { return m_foo; }
and let the client code decide if it wants copy Foo.

Inspired by a performance problem where we were unwittingly
copy constructing a large struct repeatedly just so client code
could interrogate the members of the struct.

When all of the changes this plugin finds are applied, I find
that 'perf stat make check' shows on average a 1.7% reduction
in CPU cycles.

Change-Id: Ic27b4f817aa98f2a2a009f2d4e4a962cbe9c613e
2016-04-13 13:27:50 +02:00
Stephan Bergmann
bb24492c76 More loplugin::TypeCheck use
Change-Id: I2f4a26a918134568f541cd45bdcf5a12b1f1d2ee
2015-12-08 22:56:02 +01:00
Jan Holesovsky
4c4999d944 tdf#96042: 'std::string::find("something") == 0' means "startsWith()".
This should fix a regression from 3bdd176731c351638f541a37b94094124f3c9f52,
apparently the cppcheck's advice is misleading.

Change-Id: I427ecaa1eb3c9841cb6112997b9b51feda4583d0
2015-12-08 12:12:53 +01:00
Noel Grandin
3bdd176731 cppcheck:stlIfStrFind
"Inefficient usage of string::find() in condition; string::compare() would be faster."

Change-Id: I90403b1d05eff6499c10be33068e5fd4fed30b62
Reviewed-on: https://gerrit.libreoffice.org/19966
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2015-11-15 06:46:07 +00:00
Stephan Bergmann
24a89b2772 Improve loplugin:passstuffbyref
Change-Id: I88ab4c51ff59312127681d3087d22b9c79192b94
2015-03-03 08:56: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
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
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