61 Commits

Author SHA1 Message Date
Stephan Bergmann
419d664fb7 Adapt loplugins to clang-cl's (implicit) -fdelayed-template-parsing
...which is there for MSVC compatibility, but can cause getBody() to return null
even when doesThisDeclarationHaveABody() is true.

And in staticmethods.cxx we need to check doesThisDeclarationHaveABody() instead
of hasBody():  For some class template member functions that are only defined
outside their class definition, as is the case for
OSequenceIterator::hasMoreElements in include/comphelper/sequence.hxx, hasBody()
may be true for the original member function declaration inside the class (as
there is some later definition that does have a body), but
isLateTemplateParsed() is not (it is only true for the later definition).  So
just skip any such declarations that are not definitions (which is sane anyway,
as otherwise such functions could pointlessly be inspected multiple times).

Change-Id: I724f652a8f060a931f8b5fc3e4feb5f307a922bf
Reviewed-on: https://gerrit.libreoffice.org/42914
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-29 13:31:23 +02:00
Noel Grandin
0281b18775 make oncevar plugin ignore methods with #ifdef-ery
Change-Id: I8a9cf2c4b81b95bf654f7e90306328d72e3d3408
Reviewed-on: https://gerrit.libreoffice.org/40280
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-22 08:46:34 +02:00
Noel Grandin
4c0198b02c reformat some loplugin code
to match our more normal conventions.

Also drop the 'using std' and some other cruft

Change-Id: I02ef81c5427188bc03a20b157a57a900a9d7bf0d
2017-06-20 10:26:46 +02:00
Noel Grandin
3b60f59bc5 loplugin:unusedfields fix false positive
When the field in question is read from inside a constructor
initializer.

In the process, create some needed infrastructure in the plugin classes.

Change-Id: I2f440efa6912801a236727c9fe3180404616958c
Reviewed-on: https://gerrit.libreoffice.org/38960
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-06-20 07:49:27 +02:00
Stephan Bergmann
8584b7f57c Refuse to rewrite in workdir
...instead of merely getting a warning from PluginHandler::HandleTranslationUnit
after the fact.  Such automatic rewriting should probably never be what one
wants.

Change-Id: I3829007224a197ebb4d55d24323b375cbbdf815c
2017-05-18 14:18:58 +02:00
Stephan Bergmann
df8d092c3a Adapt pathname checks to mixed usage of \ and / on Windows
Change-Id: I91bc89a9076c6642e06b238f65f2d31a1d20c6b5
2017-05-18 09:56:01 +02:00
Samuel Mehrbrodt
6f20dd1815 gpg4libre: Remove deprecated dynamic exception specifications
Change-Id: I3bec4570149af50fad5eef33bafb9842ab598798
Reviewed-on: https://gerrit.libreoffice.org/34967
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2017-03-08 10:31:47 +00:00
Samuel Mehrbrodt
88ac77c0bc gpg4libre: List and view GPG keys
* Add GPG implementation of css::xml::crypto UNO interfaces (part of that is only stub atm)
* List gpg keys along with other certificates
* Viewing gpg certificates: Not all properties are implemented yet

Change-Id: I7f60b26efe949a94bf8fe1b8d4d428002c2995b1
Reviewed-on: https://gerrit.libreoffice.org/33843
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Siegmund Gorr <siegmund.gorr@cib.de>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2017-03-04 10:26:43 +00: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
d6ff3d49df Plugin::isInUnoIncludeFile should not cover WORKDIR
...that got in, for no apparent reason, when various, slightly different
implementations of isInUnoIncludeFile got consolidated into one.

Change-Id: I64a9eb62703d57a0b7b57720ec9f251ffa780691
2016-10-19 10:56:35 +02:00
Noel Grandin
40fd53a238 loplugins: extract some common functionality
Change-Id: If470e1d9b481c9eda0829aa985152baf8fb46d7a
2016-10-18 08:51:07 +02:00
Noel Grandin
3468dab9ff clang plugins: do "dotdot" normalisation
which fixes some false positives

Change-Id: I555349180b5ca819f29695789f1545ba2177bd09
Reviewed-on: https://gerrit.libreoffice.org/29320
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-09-27 12:08:52 +00:00
Stephan Bergmann
4c70a1a666 Check harder whether file is really under WORKDIR
1977b57bc9aaea71252358fa502110c348153c70 "vcl: loplugin:override" had only hit
in out-of-tree builds, where the #include in the generated
workdir/CustomTarget/vcl/unx/kde4/tst_exclude_socket_notifiers.moc is an
absolute path.  For in-tree builds, the generated #include line is
"../../../../../vcl/unx/kde4/tst_exclude_socket_notifiers.hxx", so the returned
getFileName() is .../workdir/../../../../../vcl/..., so was erroneously
considered to be under WORKDIR.

Change-Id: I9abef04b90ecb4921087a53ff196b833940085e5
2016-09-22 08:50:43 +02:00
Stephan Bergmann
733198de1b Remove support for Clang < 3.4
Change-Id: I81e97c5f720535b33dd3ce72d01151765e4e93a0
2016-06-29 09:15:25 +02:00
Noel Grandin
442dd6a153 loplugin: move parentFunctionDecl() into common code
Change-Id: Ia10a76a98a63c6ea3b516d9146281f672b213ab3
2016-06-28 14:53:17 +02:00
Stephan Bergmann
d9adda92cc Ignore external code
Change-Id: Ie527703e9687a42bfc39439952b9d1a83d7cad24
2016-04-18 15:30:06 +02:00
Noel Grandin
778e9a65bf new loplugin: find write-only fields
Change-Id: I0f83939babacf92485420ee63f290a297d7cb717
Reviewed-on: https://gerrit.libreoffice.org/22498
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>
2016-02-19 11:23:57 +00:00
Noel Grandin
86bb6fdf9c update unusedmethods loplugin to update unused return values
Change-Id: I825d022d09282bc9b6cffd9178e40e4090d335da
2016-01-11 10:49:24 +02:00
Benjamin Ni
be729e7721 tdf#94269: Replace "n" prefix for bool variables with "b"
Change-Id: I178545792c7354a362658ac7ef8b1d4cf0865797
Signed-off-by: Michael Stahl <mstahl@redhat.com>
2015-11-02 23:40:57 +01:00
Stephan Bergmann
a51ac4d2bb Add variadic PartialWeakComponentImplHelper, remove need for implbase_var.hxx
Change-Id: Iad3417822b2ab3afb75da09c311a0bf07af5e2e4
2015-06-22 21:48:36 +02:00
Stephan Bergmann
383cace9ee Fix for BUILDDIR != SRCDIR
Change-Id: I3ea2a0a6d8f54afcc1959b54c36f90bb849995b4
2015-06-22 17:59:26 +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
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
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
f7e335ddb7 const improvement
Change-Id: I03815f33117a2927b1882d221f159a5de8d3ba78
2014-02-14 16:04:31 +01:00
Stephan Bergmann
1f078fcadd Prepare dual-mode compiler plugin feature
...which can act as either a rewriter or a non-rewriter that emits warnings.

Also added COMPILER_PLUGIN_WARNINGS_ONLY=X to demote warnings from plugin X from
errors to warnings, even under --enable-werror.

Change-Id: I05361936240a890515c6bba2459565417c1746b7
2014-01-27 13:12:33 +01:00
Stephan Bergmann
0d824b5cc1 compilerplugins: ignore WORKDIR code
...which is typically external or generated code and causes warnings that
we cannot easily fix.

Change-Id: If86ecd96c069ec23c6b3d7f5c32bf962397393e5
2014-01-10 17:11:42 +01:00
Michael Stahl
5d8f48c81e solver doesn't solve anything...
... it is an abbreviation of "Solar Version".

Since nobody can remember that:

remove OUTDIR OUTDIR_FOR_BUILD SOLARVER SOLARVERSION solarpath
and any mention thereof.

Change-Id: Idb3031c4f25a76ac05b22ec67e3ca3e1e8e512ad
Reviewed-on: https://gerrit.libreoffice.org/6515
Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
2013-10-31 15:42:24 +00:00
Caolán McNamara
3656a57e88 add mode lines to new files (and idls) since last run
Change-Id: Id1e74f18c90e69d1a781c8f02e30dc3c005ed4fd
2013-09-22 12:21:34 +01:00
Luboš Luňák
75f41baab6 warn when rewriter should modify something involving a macro
Apparently Clang rewriter API doesn't properly bail out if the range
given is not inside one file, so check explicitly.

Change-Id: I27be6d396a131d385231e9c0dfa8c84d9fa15ccc
2013-08-21 15:08:16 +02:00
Luboš Luňák
4f60eb885a helper for getting location after current token
Given that locations often point to a (start of) token, even if it's
e.g. getLocEnd(), this should be very useful.

Change-Id: I266e4c0a234262e99158c8f495b631f54f8a5608
2013-08-21 15:08:16 +02:00
Luboš Luňák
0809d7d792 update/rework the Rewriter wrapper functions
Some improvements, like making it simple to actually remove a statement
or a token including its associated whitespace.

Change-Id: I02a5bd919f1fadae1dcd45a76f9d25df353ac518
2013-08-21 15:08:16 +02:00
Stephan Bergmann
653cdcf50c error: cannot use dynamic_cast with -fno-rtti
...with recent Clang trunk towards 3.4

Change-Id: Ie0991c7bd560c30551aeaada426382a889b46391
2013-08-06 17:59:09 +02:00
Luboš Luňák
9d65113efe fix finding all parents for AST nodes
Ctor bodies can also have code inside of member variables initialization,
which is not considered to be inside function body.

Change-Id: Id68960093a51396b9486f1364b1a361526c3431d
2013-07-15 23:12:12 +02:00
Luboš Luňák
ade47d3d67 make it easy to get a parent of an AST node
Clang API doesn't provide this, but it's occasionally needed, and so far
the way has been inspecting the highest possible node in AST and walking down
and remembering, which is complicated, error-prone and annoying.

Change-Id: Id5b72cb5ebfc069e90efe6d673c0ef18ebcdab61
2013-06-20 07:21:31 +02:00
Luboš Luňák
6d114cda2c make compiler plugin warnings follow WaE
Change-Id: I72f1a11ce86d66e773e66116c725310df77fce39
2013-05-31 20:00:54 +02:00
Luboš Luňák
9cb21a3342 check for double modifications in compiler plugins
A different way to do 1c0669af2f1f58e6431b5e489ac48a883e242ba7.
Sometimes one piece of code can be represented several times in the AST,
e.g. with default function arguments.

Change-Id: Ic7799fa0bd918a638bdc8ebef69e6aa91d355bdc
2013-05-06 16:51:45 +02:00
Luboš Luňák
d01768c31a Revert "ignore already seen locations in compiler plugins"
This does not always work well, e.g. when building a return value
in a return statement from a temporary, there is CXXConstructExpr
containing CXXTemporaryObjectExpr, which both share the same location.
This reverts commit 1c0669af2f1f58e6431b5e489ac48a883e242ba7.
2013-05-06 16:49:36 +02:00
Luboš Luňák
a0da672521 ignore already seen locations in compiler plugins
Change-Id: Icba8dfa61aee7237af569b2414b1cf4ce93ca476
2013-05-06 16:49:36 +02:00
Luboš Luňák
6f16cfb5a6 Fix handling range in removeText().
Turns out removeText( SourceRange ) treats it as a token range, so it's
not always character-exact if used for removal of only several characters
from a token (e.g. an identifier).

Change-Id: I0223d52da90f9535d9ef1d48b0f56d69131536c8
2013-05-06 16:49:36 +02:00
Luboš Luňák
153a69cad2 pass around CompilerInstance rather than ASTContext
It's possible to get the latter from the former, and the former
is useful for other things too (access to the preprocessor, for example).

Change-Id: I708d709129fd3a35bf7c63da4de09c2e696b382d
2013-03-28 18:01:00 +01:00
Luboš Luňák
276953ef21 remove not needed #include
Change-Id: I0fa791733407199db5be2cc9606ac9be1da64188
2013-02-02 22:59:45 +01:00
Luboš Luňák
f5ee30c3ee append [loplugin] automatically in report() rathen than manually everywhere
Change-Id: I2f98622f152ae0c7ac8d1113d6380f686ac7234c
2013-02-02 22:59:45 +01:00
Luboš Luňák
b4392c575e always use the report() helper
Change-Id: I2966fdb5bd98b1ddf718079584acf90a3e3a3700
2013-02-02 22:59:45 +01:00
Luboš Luňák
a1c61eb112 move documentation of plugins to the .cxx files
It's mostly there already anyway, no need to duplicate it.

Change-Id: I5b066f90725a064fb0746e1411900e835e3f66c3
2013-02-02 22:59:44 +01:00
Luboš Luňák
a7c3adb773 avoid having to manuall modify sources when adding a new clang plugin
Now each one registers in its .cxx file.

Change-Id: I811c0d4400c2bdccc1c287269378d7e8ad8743ce
2013-02-02 22:59:44 +01:00
Luboš Luňák
b8f932b6a5 move plugin handling to separate source files
Change-Id: Ifa1af34121bda9ca3250d09a3b8a46ea226795ed
2013-02-02 22:59:44 +01:00
Luboš Luňák
d9a5c6bdf0 fix detection whether to ignore a source file or not
When compiling using icecream, the whole input is one file fed from stdin,
so getBufferName() is "<stdin>", so get the filename from #line directives.

Change-Id: Ie87937b10b0c7e8ddfa57a405b80fd9bde68dd0a
2013-01-11 14:58:58 +01:00
Luboš Luňák
62532ad485 do not set our clang timestamp to the timestamp of the clang binary
If the clang binary comes from a package which had been built before
any of our clang related sources were changed the last time, the timestamp
would be older and so there would be no rebuild. So do the stamp handling
the usual way, clang upgrades will work fine, downgrades will not, but
that's the same problem like with downgrading a library and its headers.

To somewhat mitigate the problem (Clang plugin doesn't get cleaned by
'make clean'), include the full Clang version (which includes SVN revision)
in config_clang.h and make all Clang plugin code include that, so
at least configure re-run will trigger a rebuild if necessary.

Change-Id: I993197f79e92e36105092c92c33b2e1db343e975
2013-01-06 18:23:04 +01:00