23 Commits

Author SHA1 Message Date
Pranav Kant
b39e627be4 Allow compiler plugins for online
Change-Id: I8e45936ef5675d531be71496e8894b90eaf2f6e2
Reviewed-on: https://gerrit.libreoffice.org/46769
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
2017-12-21 15:37:36 +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
32c31c03d0 New --enable-compiler-plugins=debug mode
...to enable debug-only code in the plugins.  Some situations in the plugin code
should never happen, yet must not by default report errors or trigger
assertions, as some newly written LO code could trigger them nevertheless (in
which case the plugin code will likely need to be adapted, to cater for these
presumed-impossible situations).

Such code can now be included in the plugins behind an if(isDebugMode()) guard,
and can explicitly be enabled with --enable-compiler-plugins=debug.

I deliberately made this a runtime rather than a compile time option (using
some #ifdef guards in the plugin code, say), as it IMO keeps the code more
readable, and also allows overridding COMPILER_PLUGINS_DEBUG=... on the make
command line.

Change-Id: Iea4f0c2783ad968a0de097fa710b3be1a248de73
Reviewed-on: https://gerrit.libreoffice.org/46096
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-12-08 21:09:39 +01:00
Stephan Bergmann
07b8711526 Memoize ignoreLocation results
...which, according to callgrind, reduces instruction fetch count spent on
compiling sw/source/core/layout/paintfrm.cxx (randomly selected because it is
rather large) by 5% from 41,992,064,226 to 39,861,989,855 (function main() in
clang-6.0).

This is best done by forwarding ignoreLocation calls from Plugin to the
PluginHandler signleton, but due to the tight mutual coupling between plugin.hxx
and pluginhandler.hxx that unfortunately required some reorganization (and two
outstanding TODO clean-ups of temporarily introduced using declarations in
plugin.hxx).

Change-Id: Ia4270517d194def7db7ed80cb6894e9c473e9499
2017-11-07 11:19:30 +01:00
Stephan Bergmann
15dce20e8b Fully ignore inappropriately named loplugins in unit-test mode
...even if they implement PPCallbacks, so filtering them out in
HandleTranslationUnit was ineffective.

Change-Id: I9df8103a50739f3176e6d63accfd0334da7faa9a
Reviewed-on: https://gerrit.libreoffice.org/43575
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2017-10-20 08:31:30 +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
Noel Grandin
45c06838e9 only unit-test one loplugin at a time
tell the plugin code when we are unit-testing it, so we can suppress all
the warnings except for the plugin we are currently testing

Change-Id: I240c8e37eba90c219e53c29531a3a43bc841a1c8
2017-06-19 11:34:15 +02:00
Chris Sherlock
da64d198ec tools: svstream.hxx needs only errcode.hxx & not errinf.hxx
Change-Id: Ia28e35ae5af4f601e9a586a3deffbcd61702b0ca
Reviewed-on: https://gerrit.libreoffice.org/36896
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
2017-04-25 09:31:31 +02:00
Stephan Bergmann
2ac66f5a36 Enable Clang plugin warnings in Bison source code
-Werror is generally suppressed in Bison-generated C/C++ code (as in all other
generated code) to silence warnings from the Bison skeleton code.  And the Clang
plugins suppress warnings in generated WORKDIR code based on the presumed source
location (i.e., taking #line directives into account).  So introduce a new
PLUGIN_WARNINGS_AS_ERRORS mode where warnings from Clang plugins are reported as
errors even if -Werror is suppressed.  That way, any warnings in the Bison
skeleton code still do not lead to compilation errors, while (at least plugin-
emitted) warnings in the genuine source code do.

Unfortunately this cannot also be enabled for Flex source code, as at least
Flex 2.5.39 generates poor code that does not properly prefix all skeleton code
with appropriate #line directives, so that some skeleton code would be mistaken
for genunie source code, and compilation would fail due to errors.

Also, %glr-parser Bison input appears to generate no #line directives at all (at
least with Bison 3.0.4), so all of connectivity/source/parse/sqlbison.y is
considered generated code and plugin warnings are still suppressed throughout.

Change-Id: Id746e81cbfa5f77628b0a34c7b82780948e7db08
2016-04-26 17:49:11 +02:00
Stephan Bergmann
01f3b95884 These version checks are about the Clang the plugins are built /against/
...not the (Clang) compiler they are being built /with/.  (Also simplifies the
checking #if code.)

Change-Id: I416321be4ef4478785be40571f81500fd3b6feb8
2016-02-26 14:34:29 +01:00
Stephan Bergmann
311fb9d5e6 Adapt compilerplugins to Clang trunk towards 3.6
Change-Id: I0b7be1616a3e4206982f9f925de141ed9d53b96e
2014-08-11 15:16:08 +02: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
6f69fb5d7d Run the non-rewriter plugins even when rewriters are specified
Change-Id: I8262091c52522c54f84c0fac5fd180871d4a3a9f
2014-02-17 17:55:16 +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
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
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
a0d320096c mark all virtuals in the clang plugin as override
In order to help catch Clang API changes.

Change-Id: I5738f5dff405f7a2dd377c983fb32c1c7a2ff921
2013-05-31 20:00:53 +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
857a392654 make it possible to limit what files will be modified by a compiler plugin
Change-Id: I4e3e8f5ca5e5b5b59b1bd067281f90940dd893b1
2013-02-09 18:48:31 +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
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