896 Commits

Author SHA1 Message Date
Stephan Bergmann
c74688dfd4 That whitelisted code is already gone again
Change-Id: I1fa04b51823ac9707f0dd3d7c8209c69e917ef28
2016-12-22 08:58:09 +01:00
Stephan Bergmann
595ff0c6ea Also don't warn for plain C code
...as needed by clang-cl for
bean/native/win32/com_sun_star_comp_beans_LocalOfficeWindow.c

Change-Id: I862afb6b549015d951a898ee415370540ffab1f6
2016-12-22 08:54:04 +01:00
Tomaž Vajngerl
bf5f6df9e4 vcl: separate ImplImageTree - ImageTree singleton and public iface
ImplImageTree was used outside of VCL which is not consistent with
the name and the header also contains a lot of implementation
detail. This separates the implementation to ImplImageTree and
the public interface and singleton to ImageTree only.

Change-Id: I3a26444f0f6971a6b1d83472e9cef19c93192d3e
Reviewed-on: https://gerrit.libreoffice.org/32134
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
2016-12-19 07:26:24 +00:00
Noel Grandin
f9fd6390cd ScrollableWrapper -> ScrollableDialog
no point in having a template and a virtual base class when it's only
used for one type

Change-Id: Idb1a1a551064cc10896eff33652038eb5be0297e
Reviewed-on: https://gerrit.libreoffice.org/32041
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-12-19 06:04:33 +00:00
Stephan Bergmann
54aab71ff7 On Windows, #include <process.h> for getpid
Change-Id: Ibfb52800cdde99298431dab9da1cb8109658c425
2016-12-18 22:43:30 +01:00
Stephan Bergmann
35196c3275 loplugin:vclwidgets: Adapt check for 'assert' for MSVCRT
Change-Id: I12a77b5b53e3a674c1ff1554b560a71605e141a6
2016-12-18 22:43:29 +01:00
Stephan Bergmann
83ff2a4f38 loplugin:stringconstant: Adapt to definition of OSL_THIS_FUNC on Windows
Change-Id: I93a23799ad9a76ed9f4f86d69adb610d0962da20
2016-12-18 22:43:29 +01:00
Stephan Bergmann
9ed9ca611a loplugin:stringconcat: Adapt to definition of OSL_THIS_FUNC on Windows
Change-Id: I9a2be8c4265095ff2ac5e2216cb08c35c9049bf8
2016-12-18 22:43:29 +01:00
Stephan Bergmann
dbbd2c48b1 Work around problem with poor gperf-generated code under clang-cl
Change-Id: Iba3fae8bbecaf5782228be1fb99f196864d79e6b
2016-12-18 22:43:28 +01:00
Stephan Bergmann
f2ef97dee7 loplugin:fpcomparison: Whitelist some Windows-only functions
Change-Id: I94f35696ba358a049ee65764d17c62df7889aec7
2016-12-18 22:43:28 +01:00
Stephan Bergmann
09f5ffafc2 loplugin:commaoperator: Ignore occurrence in FD_SET expansion on Windows
Change-Id: I66974c273918d6d887364e7d552e3caf63e16343
2016-12-18 22:43:27 +01:00
Stephan Bergmann
c052ec5add Chose better diagnostic location
Change-Id: I502da4b93905e64ca5506f24dc1f6bf2bf990dc2
2016-12-18 22:43:27 +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
ec0665ac8b Rename cdecl -> classdecl (MSVC treats the former like a keyword)
Change-Id: I1859a92c996b907b8d511cddba25c00c9a52f398
2016-12-18 22:43:26 +01:00
Stephan Bergmann
83d2c5180d Adapt to no-longer explicit OUStringLiteral ctor
...from previous commit

Change-Id: I062b7cd212c17e7eb5274476e6859228d0477c7f
Reviewed-on: https://gerrit.libreoffice.org/32098
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-12-17 16:12:02 +00:00
Stephan Bergmann
9d7802e7fc Make move detection in loplugin::passstuffbyref work for parenthesized cases
Change-Id: I56754a718af9433c0fa654ccb8eb34da00e75420
2016-12-16 15:16:37 +01:00
Stephan Bergmann
b998313d9d Make move detection in loplugin:passstuffbyref work with MSVCRT
...where an ImplicitCastExpr happens to appear between CXXConstructExpr and
CallExpr

Change-Id: I62226cc89d87bd3d9c03743b650f10c32c18f9be
2016-12-16 15:14:23 +01:00
Noel Grandin
bd6723fd53 disable the 'two different log areas in the same file' loplugin check
too many false+ to leave it alive by default

Change-Id: I6d8f92b630c351c1ac788fad79f8d7c435ba4963
2016-12-15 14:11:16 +02:00
Noel Grandin
d15b4e2045 teach sallogareas plugin to catch inconsistencies
Change-Id: I8bcea5ffc74d48148bea78da8c17744e288c069a
Reviewed-on: https://gerrit.libreoffice.org/32004
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-12-15 06:45:14 +00:00
Stephan Bergmann
37b21a0a71 Merge shell into TaskManager base class
(arbitrarily decided to keep the latter, being the less odd class name)

Change-Id: I5c061a0f12b8f3095e283b4896f7c910948ac50f
2016-12-14 17:52:38 +01:00
Stephan Bergmann
4e9dd6e1b7 Disambiguate clang::StringLiteral
...vs. recently introduced llvm::StringLiteral (llvm/ADT/StringRef.h)

Change-Id: I4d74546b0d1401a74b0c15368bbc93794ecd0b1d
2016-12-14 15:52:33 +01:00
Stephan Bergmann
c826ddfc2c Check that VclPtr is only instantiated with appropriate types
...deriving from VclReferenceBase.  Complicated by the fact that the argument
type may be incomplete at the time of template instantiation.  So this approach
may be less precise than the change to loplugin:vclwidgets from
cbf5b21f2a65bbb342295200f6ad93a00f90733e "Catch some misuses of VclPtr
construction" when the argument type becomes complete later in the comilation
unit.  However, this approach would also catch the two misuses in UnoControls
found by cbf5b21f2a65bbb342295200f6ad93a00f90733e, so go with this approach for
now and revert the change to loplugin:vclwdigets.

Change-Id: I7888f23d2b9e2db81ae2ce4bf4c8277912317685
Reviewed-on: https://gerrit.libreoffice.org/31966
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-12-14 09:34:01 +00:00
Stephan Bergmann
385f624027 Prevent use of ORowSetValue with sal_Bool as TINYINT
sal_Bool and sal_uInt8 are typedefs for the same underlying type, so any use of
ORowSetValue with sal_Bool instead of bool, apparently intending to treat the
value as a boolean, actually treated it as a TINYINT.  (See e.g. recent
7b0c57b2faec875c790051d233d1e9abaed2a3bc "some compilers don't like implicit
bool-to-ORowSetValue conversion".)

Now that there's no way to create a sal_uInt8 ORowSetValue, getUInt8 and the
m_uInt8 union member can probably go away, too.

Change-Id: Ia27554f76e7e9edce6410284b578064573e54fd3
Reviewed-on: https://gerrit.libreoffice.org/31909
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-12-12 18:02:57 +00:00
Tor Lillqvist
2da2cfcb19 Whitelist aLogger, in FormulaLogger& FormulaLogger::get()
To avoid this:

sc/source/core/tool/formulalogger.cxx:55:26: error: bad static variable causes crash on shutdown [loplugin:badstatics]
    static FormulaLogger aLogger;
    ~~~~~~~~~~~~~~~~~~~~~^~~~~~~
sc/inc/formulalogger.hxx:42:31: note: ... due to this member of 'FormulaLogger' [loplugin:badstatics]
    const ScFormulaCellGroup* mpLastGroup = nullptr;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
sc/inc/formulacell.hxx:66:20: note: ... due to this member of 'ScFormulaCellGroup' [loplugin:badstatics]
    ScFormulaCell *mpTopCell;
    ~~~~~~~~~~~~~~~^~~~~~~~~
sc/inc/formulacell.hxx:114:21: note: ... due to this member of 'ScFormulaCell' [loplugin:badstatics]
    ScDocument*     pDocument;
    ~~~~~~~~~~~~~~~~^~~~~~~~~
sc/inc/document.hxx:312:27: note: ... due to this member of 'ScDocument' [loplugin:badstatics]
    VclPtr<SfxPrinter>    pPrinter;
    ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

Change-Id: I533e45f655ca928a801188aa48ee818d89a962ac
2016-12-12 15:52:53 +02:00
Stephan Bergmann
a9659f30d6 No need for rtl::Reference friend, no need for #include vclptr.hxx
Change-Id: I7bdd15a93e728ef7e98a53001c6eb6b56f761a6d
2016-12-09 20:01:52 +01:00
Stephan Bergmann
cbf5b21f2a Catch some misuses of VclPtr construction
...that go unnoticed due to the non-explicit VclPtr::oeprator reference_type *

Change-Id: Ia63edf8425d3ecb7c7f98eb56a710ac0cceccb67
2016-12-09 20:00:26 +01:00
Miklos Vajna
dc1925e6f0 sw: remove some inline version control in uibase
Change-Id: I7125b6f8593cac2c33916341f5649f57044ad045
Reviewed-on: https://gerrit.libreoffice.org/31761
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-12-08 16:24:12 +00:00
Stephan Bergmann
9e258eca6d Replace calls to get(Qualified)NameAsString with stuff from check.hxx
Change-Id: I14e48ea5c59bdd12ad6484222b3e8733664e78c4
Reviewed-on: https://gerrit.libreoffice.org/31712
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-12-07 07:11:32 +00:00
Noel Grandin
2e293a731c new loplugin/rewriter comparisonwithconstant
As per sberg' suggestion

Limit it to == and !=, because some people like the flow of inequalities
like: "0 < a && a < 42"

The changes to sal/ were made using the rewriter.

The rewriter still has one bug, in pipe.cxx, it managed to pick up
some random piece of macro. No idea why.

Change-Id: I01305f9c5396a4b6c7421d6e92f1b4b529388e82
Reviewed-on: https://gerrit.libreoffice.org/30962
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-12-06 05:38:14 +00:00
Stephan Bergmann
03c215ab07 loplugin:unnecessaryoverride (dtors)
Change-Id: Ia38672028668959bf3d5541fe4ddb9fb72848617
2016-12-05 09:06:14 +01:00
Noel Grandin
8cf59c6743 make passstuffbyref plugin ignore std::move'd params
request from vmiklos

Change-Id: If263beb0623d725e406003bb1660df10fe4b4e35
Reviewed-on: https://gerrit.libreoffice.org/31555
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-12-05 05:53:25 +00:00
Stephan Bergmann
51b502bb53 Missing include
Change-Id: I6af48e37b1b796a1680447ff972de8b5f5623d26
2016-12-01 23:42:09 +01:00
Noel Grandin
e6ffb539ee loplugin:vclwidgets check for assigning from VclPt<T> to T*
Inspired by a recent bug report where we were assigning the result
of VclPtr<T>::Create to a raw pointer.

As a consequence, we also need to change various methods that were
returning newly created Window subclasses via raw pointer, to
instead return those via VclPtr

Change-Id: I8118e0195a5b2b4780e646cfb0e151692e54ae2b
Reviewed-on: https://gerrit.libreoffice.org/31318
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-29 06:45:42 +00:00
Stephan Bergmann
1800862c70 loplugin:stringconstant: look into 'char const * const var = "..."'
Change-Id: I52a97b8ec273509131c2200e47527221cb62d7ee
2016-11-25 16:42:23 +01:00
Stephan Bergmann
f1eb0bf752 Clean up CLANG_VERSION check
Change-Id: Idfdffd73e9029216775d2a6ad46293ee1a4f1308
2016-11-25 11:24:12 +01:00
Stephan Bergmann
bf53daa49a Clean up PPCallbacks compatiblity fix
Change-Id: I91f1db18b7876c4ecc30f7f97283e0ef0369eba5
2016-11-25 11:22:14 +01:00
Stephan Bergmann
6eaa7a41d8 Blind fix for Clang 3.6
Change-Id: I56dc86df0d355cfa8af38661892ea2bb580c394b
2016-11-24 14:49:52 +01:00
Miklos Vajna
7aa2b5a041 CompilerTest_compilerplugins_clang: fix this to work with clang-3.7
Change-Id: I653b9c3aba53da421592b230bee3a9b69d3cb2d7
2016-11-24 12:11:59 +01:00
Noel Grandin
29a9e97db6 loplugin field-can-be-private in include/vcl..xmlscript
Change-Id: Ia03f7cccb256d825daa4dc6f4c0598448e46e6cf
Reviewed-on: https://gerrit.libreoffice.org/31069
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-23 07:17:50 +00:00
Stephan Bergmann
0de1b34a89 New loplugin:oslendian
...to catch new places where defined'ness of OSL_BIG/LITENDIAN would be checked
without osl/endian.h being included; cf.
e2f08f9def0869460ad38a1c2adb450778290f6e "connectivity, sc: add missing #include
<osl/endian.h>" and 2b14fb3a4f92b928f0a5fc536c6a5f4a6e51a9b8 "cppcanvas, oox:
add missing #include <osl/endian.h>".

Change-Id: I167c8916a01391b7dacad7325153ccf35d3ba9dc
2016-11-22 10:54:25 +01:00
Noel Grandin
6f9cdf0814 can-be-private analysis needs to ignore virtual methods
Change-Id: I1e2f28ed550ff9751912f70e3eec511ddc5b75cf
2016-11-22 08:34:16 +02:00
Stephan Bergmann
883024d657 FieldDecl::getParent fires assert for Objective C @interface members
(like in vcl/inc/osx/a11ywrapper.h's AquaA11yWrapper), at least on recent Clang
trunk, from within the call to cast() in

  cast<RecordDecl>(getDeclContext())

as the decl context apparently is something other than a RecordDecl.

Change-Id: I238bae44d6db0f04bf8f90b0032489e3b4822eee
2016-11-21 23:02:04 +01:00
Noel Grandin
04f262ace0 new loplugin datamembershadow
Change-Id: Ib14319848bafd1fe7e0e663c434bbdeef5e98ecf
Reviewed-on: https://gerrit.libreoffice.org/30963
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-21 06:19:52 +00:00
Noel Grandin
2f7ccd102a extend unusedfields loplugin to find fields that can be private
and apply the results in xmlscript

Change-Id: Ib126f6e1576639abfd171e99d9561be9715ece2f
2016-11-17 08:40:27 +02:00
Noel Grandin
92da39d5f9 update couple of loplugins for move constructors
Change-Id: I82140569a3e09225065d721e4aeac5c5fe93bc45
2016-11-16 14:16:09 +02:00
Stephan Bergmann
1034ee0c09 Reduce noise for irrelevant warnings somewhat
...other options to avoid such irrelevant warnings can be to move code to an
include file and/or to define a dummy main() accessing otherwise unreferenced
entities.

Change-Id: Ifd44e376b35ef68496f3aba6a3c046d684824000
2016-11-16 11:10:39 +01:00
Noel Grandin
7cca2c7fb3 new loplugin finalprotected
look for final classes, and make sure they don't have protected members

Change-Id: I1fa810659bba02b61a5160dbfd8e24185ec9abf4
Reviewed-on: https://gerrit.libreoffice.org/30895
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-16 09:10:16 +00:00
Stephan Bergmann
645583dfd3 New compilerplugins/clang unit tests
...to check that loplugin produces warnings/errors as expected:

* Clang has a -verify switch that makes it easy to write test input .cxx files
  that list in comments all the warnings/errors that are expected, and let Clang
  check those expectations instead of generating object code.  See
  include/clang/Frontend/VerifyDiagnosticConsumer.h in the Clang source tree for
  documentation.

* Introduce a CompilerTest gbuild class that uses the existing LinkTarget class
  as much as possible.  Checking the input files is implicitly phony, as the
  compilation step doesn't generate any object files, and the link step does
  nothing because there is no gb_LinkTarget_set_targettype for CompilerTest.
  The setup at least works for Clang on Linux (will need adaptions for Clang on
  Windows; compilers other than Clang are not relevant for now given this is
  used to check compilerplugins).

* Definition of gb_CFLAGS_WERROR in solenv/gbuild/platform/com_GCC_defs.mk needs
  to be lazy ('=' vs. ':=') so that CompilerTest can override it:  The Clang
  -verify mode wants the input files to specify whether the loplugin diagnostics
  are warnings or errros, so they consistently need to be errors independent of
  --enable-werror configuration.

* A first (example) test is in compilerplugins/clang/test/salbool.cxx.  The
  corresponding gbuild CompilerTest instance is in
  solenv/CompilerTest_compilerplugins_clang.mk for now.  The reason for that odd
  split across compilerplugins/ and solenv/ is that there is no
  compilerplugins/Modules_compilerplugins.mk file, so this setup is the easiest
  hack for now (to be cleaned up).  (Another area that could be improved is that
  all test files need to be listed explicitly in the CompilerTest_*.mk file,
  instead of, say, using all .c/.cxx/.m/.mm files in a specified directory.)

* The test is run somewhat late during a top-level 'make', after loplugin has
  already been used in compilation.  But it can be run manually (e.g., 'make
  solenv') when making changes to loplugin during development.

Change-Id: I01e12fb84887d264ac03ef2484807458c2075af4
2016-11-15 11:09:29 +01:00
Stephan Bergmann
682899e313 CXXDestructorDecl is already handled
...a few lines up, together with CXXConstructorDecl

Change-Id: Id9afd4d3936b2efb92de3c6ab950da78d876a5a8
2016-11-14 16:47:25 +01:00
Noel Grandin
391c6aeeed ignore constructors for method-can-be-private analysis
doesn't work right now

Change-Id: I43693104f4af204a6bd0c22b0f7ef53c1a14bb6e
2016-11-14 13:56:13 +02:00