summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/unnecessaryoverride.cxx
AgeCommit message (Collapse)AuthorFilesLines
2019-10-08better name for a function in compilerpluginsLuboš Luňák1-2/+2
The function is not just about a spelling location. Change-Id: I96e9e9ef7e27a9763397b4b86473c1c30d0e3eeb Reviewed-on: https://gerrit.libreoffice.org/80381 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2019-03-12make (some) clang plugins share the same RecursiveASTVisitorLuboš Luňák1-12/+21
Each plugin currently uses its own recursive AST run, which adds up. This patch adds another shared plugin which internally contains all (suitable) plugins and dispatches to them from the same one recursive run. This patch converts ~25 plugins and for starmath's accessibility.cxx reduces clang build time from 5.43s to 5.14s (and it's 4.39s without any plugins). As there are almost 50 more plugins to go, this can theoretically result in 4.56s final time, although probably not all plugins can be that easily converted, if at all. This mostly requires very little change in many plugins (see e.g. BadStatics), some even work without any functionality change (e.g. CharRightShift). Traverse* calls require some changes but are often not that difficult. WalkUp* probably can't be supported, although some plugins can(?) possibly be adjusted to not rely on them. And of course some plugins can be left as they are, using their own recursive run. See description at the top of generator.cxx for description of how to convert a plugin. The sharedvisitor.cxx source is generated based on scanning relevant plugin sources using a clang-based scanner/generator. The generated source is intentionally included instead of getting always generated, as the generating currently takes some time, so it should get updated in git whenever a change in a plugin triggers a source change in it. Change-Id: Ia0d2e3a5a464659503dbb4ed6c20b6cc89b4de01 Reviewed-on: https://gerrit.libreoffice.org/68026 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2019-02-27loplugin:unnecessaryoverride look for more patternsNoel Grandin1-50/+98
like bool Foo::bar() { b = Super::bar(); return b; } Change-Id: I5e4c8005a3da7d7487c9039c35dcbb1d17e65bd7 Reviewed-on: https://gerrit.libreoffice.org/68418 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-23filter out AST in more pluginsNoel Grandin1-2/+2
I seem to have missed quite a few in commit 9f4d23c15115d64febd6bf01f870cc157badd350 filter out some of the AST in the plugins This nets me another 14% improvement Change-Id: I39b980b49ced560f768045dbedd3ddfef29306c1 Reviewed-on: https://gerrit.libreoffice.org/59501 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-10Avoid -Werror=deprecated-declarations with recent Clang trunkStephan Bergmann1-1/+1
...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-07-31loplugin:unnecessaryoverride small improvementNoel Grandin1-7/+21
when we have two definitions of the same method in a straight inheritance path up our hierarchy, we were missing a warning Change-Id: Ibc0f11644c7321a0d5618024860c2503665d8835 Reviewed-on: https://gerrit.libreoffice.org/58354 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-07-06compilerplugins: try to make these work with icecreamMichael Stahl1-3/+3
There are some problems here, this should fix one of them: the getFilename function returns "<stdin>" for spelling locations, because the input to clang is sort of preprocessed via -frewrite-includes if icecream is used and the file is built on a remote host (whereas it's apparently not preprocessed if the file is compiled locally by icecream). Using getPresumedLoc() uses the #line directives in the preprocessed input, which avoids the problem but is more expensive, so try to use it only when necessary. The getFileEntry(getMainFileID())->getName() pattern will also result in "<stdin>", but fortunately icecream passes -main-file-name, which oddly enough isn't used by the SourceManager's spelling locations, but is available separately via CodeGenOptions. This builds everything successfully with clang version 6.0.0: ICECC_PREFERRED_HOST=myremote make check gb_SUPPRESS_TESTS=t Change-Id: Ic121511683e5302d7b9d85186c8b9c4a5443fa1b Reviewed-on: https://gerrit.libreoffice.org/54993 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
2018-03-27Let prefix arguments to hasPathnamePrefix end in slashStephan Bergmann1-1/+1
...for better precision Change-Id: I5f273b7c66ba931647805c415622b5ac767ff987
2017-12-29loplugin:unnecessaryoverride fix for changing accessNoel Grandin1-1/+6
Change-Id: I61b908999be7d94eed0c421125f8e1fc07e3c2db Reviewed-on: https://gerrit.libreoffice.org/47182 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-12-19Bump --enable-compiler-plugins to Clang 3.8.0Stephan Bergmann1-16/+6
<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-11-15Make checkIdenticalDefaultArguments more preciseStephan Bergmann1-4/+11
...when creating objects involves copy/move constructors Change-Id: I0c7ccb85b7dcb584502a48817d7d2abfde25aaf2 Reviewed-on: https://gerrit.libreoffice.org/44733 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-11loplugin:unnecessaryoverride: suppress warnings when default args differStephan Bergmann1-3/+13
...instead of blacklisting such cases. Reuses the checkIdenticalDefaultArguments code that was originally in loplugin:overrideparam (and appears to work reasonably well for the default arguments that actually happen in practice). Change-Id: I9cf2db17101beb135b2039a9b7ed335bd2af2c08 Reviewed-on: https://gerrit.libreoffice.org/44594 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10loplugin:unnecessaryoverride: no warnings when fns are actually differentStephan Bergmann1-0/+9
Change-Id: I90d8af7a1affa459400b1cae4805e3a80b6c5200 Reviewed-on: https://gerrit.libreoffice.org/44593 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10No need to blacklist this loplugin:unnecessaryoverrideStephan Bergmann1-3/+0
...a using declaration should fix it just fine Change-Id: I05cf76672bcceb7a94afa602e215a0b5a32de82b Reviewed-on: https://gerrit.libreoffice.org/44591 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10No need to blacklist this loplugin:unnecessaryoverrideStephan Bergmann1-3/+0
...a using declaration should fix it just fine Change-Id: I0279994c155775e9a58e93aef8da4522d4fd93fd Reviewed-on: https://gerrit.libreoffice.org/44590 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-10No need to check both (identical) param_size() and getNumParams()Stephan Bergmann1-2/+0
Change-Id: I481cfa8b0f4bb9cbc257d28f36c372fb7367f294
2017-11-09No need to blacklist this loplugin:unnecessaryoverrideStephan Bergmann1-3/+0
This now hides one of the ScVbaFormatCondition_BASE::Operator overloads, but that doesn't get called directly at ScVbaFormatCondition anyway. (And if it were, we could add an appropriate using declaration to ScVbaFormatCondition.) Change-Id: I8440b76a5745c6874f7a3bfcbb4bc4ce5618a4c4
2017-11-08Suppress loplugin:unnecessaryoverride...Stephan Bergmann1-7/+52
...when a class derives from multiple (non-virtual) instances of one base class, and the override disambiguates which of those instances' member to call. That was the case with SwXTextDocument::queryAdapter (sw/source/uibase/uno/unotxdoc.cxx), where SwXTextDocument derives from cppu::OWeakObject through both SwXTextDocumentBaseClass and SfxBaseModel, but calling queryAdapter through a pointer to SwXTextDocumentBaseClass apparently needs to call OWeakObject::queryAdapter on the second, SfxBaseModel-inherited OWeakObject base instance, or else CppunitTest_sw_macros_test fails. Who knows what other instances of similar non-unnecessary overrides have been removed with the help of broken loplugin:unnecessaryoverride, for which there were no tests that started to fail... Turns out .clang-format lacked "ReflowComments: false" to not break the special "// expected-error {{...}}" etc. comments in compilerplugins/clang/test/. Also, use a better location to report loplugin:unnecessaryoverride, to keep clang-format and loplugin:unnecessaryoverride from fighting over how to split lines and where to put the comment in compilerplugins/clang/test/unnecessaryoverride.cxx. Change-Id: I3b24df24369db12f8ec1080d6c9f7b70ff561a16 Reviewed-on: https://gerrit.libreoffice.org/44418 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-11-07Clean away temporarily added using declarationsStephan Bergmann1-1/+1
Change-Id: I26734c13515394162d88351a1cbe2b20abdac865
2017-09-29Adapt loplugins to clang-cl's (implicit) -fdelayed-template-parsingStephan Bergmann1-2/+6
...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-05-18Adapt pathname checks to mixed usage of \ and / on WindowsStephan Bergmann1-14/+14
Change-Id: I91bc89a9076c6642e06b238f65f2d31a1d20c6b5
2017-03-13Minor loplugin:unnecessaryoverride improvementStephan Bergmann1-10/+8
Change-Id: I3afb31b642a47e767dda0614d223b6b7f22e5d54
2017-03-13Fix loplugin:unnecessaryoverrideStephan Bergmann1-0/+4
(user-provided virtual dtor in class with dependent base) Change-Id: I37b3cc3d32e76a0286ecc91f999920e3dfe706cc
2017-01-27improve "unnecessary user-declared destructor" checkNoel Grandin1-10/+47
to look for inline&empty destructors, where we can just let the compiler do it's thing Change-Id: Ibde8800bdfed6b77649c30ebc19921167c33dec3 Reviewed-on: https://gerrit.libreoffice.org/32999 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-12-05loplugin:unnecessaryoverride (dtors)Stephan Bergmann1-2/+82
Change-Id: Ia38672028668959bf3d5541fe4ddb9fb72848617
2016-11-14CXXDestructorDecl is already handledStephan Bergmann1-3/+0
...a few lines up, together with CXXConstructorDecl Change-Id: Id9afd4d3936b2efb92de3c6ab950da78d876a5a8
2016-11-01disable this chunk of loplugin code on clang < 3.8Noel Grandin1-8/+4
not worth the spaghetti of making it work across version Change-Id: I0de923b16fb6d58cbad55adc9878ab39bc0c86ae
2016-10-31No good reason for dbaccess::OCacheSet::updateRow to be pure?Stephan Bergmann1-2/+1
Most of its virtual member functions are (though insertRow is already a curious exception), even though they are defined, so smells like a copy/paste error rather than deliberate design. And appears to have been the only reason why loplugin:unnecessaryoverride filtered out such overriding of pure base functions. Change-Id: Ib2a40af9cd3cd3dbb26c4147f7d01de4e11f5f6e
2016-10-31fix unnecessaryoverride clang plugin on clang < 3.8Noel Grandin1-0/+8
Change-Id: Id78d694cf7271a6abf94234958ab623cf1cd93a5
2016-10-28update unnecessaryoverride plugin to find pure forwarding methodsNoel Grandin1-7/+86
which can be replaced with using declarations. Is there a more efficient way to code the search? Seems to slow the build down a little. Change-Id: I08cda21fa70dce6572e1acc71bf5e6df36bb951f Reviewed-on: https://gerrit.libreoffice.org/30157 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-10-13loplugin:unnecessaryoverrideNoel Grandin1-45/+79
Change-Id: I08c55a3023ec2e8990098eeb60e91cd18556e7ae Reviewed-on: https://gerrit.libreoffice.org/29656 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-07-19improve unnecessaryoverride pluginNoel Grandin1-1/+8
to ignore ImplicitCastExpr when calling superclass method Change-Id: I76a3068446acfee85aa1baeb216e57f63c7099c1 Reviewed-on: https://gerrit.libreoffice.org/27279 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
2016-07-18Adapt to older Clang that don't have CompoundStmt::body_frontStephan Bergmann1-1/+1
Change-Id: I41555c0a2b35ad950797f65e02ed1ee060c4bf0a
2016-07-15Improve loplugin:unnecessaryoverrideStephan Bergmann1-7/+55
<sberg> thorsten, remember what that "TODO" in SvxAccessibleTextPropertySet::getSupportedServiceNames was to be about exactly, in a909acb7009acadffa53e74ea05ddb88803490f1 ? <thorsten> sberg: that's a nonsense, prolly copy'n'pasted, or a 'please review me' <sberg> thorsten, OK, thanks (that override will eventually go away with loplugin:unnecessaryoverride, and the TODO comment be lost) Change-Id: Iba964c61768459aac4067bbd4e1f7d4f78f6adac Reviewed-on: https://gerrit.libreoffice.org/27232 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-07-15new loplugin unnecessary overrideNoel Grandin1-0/+114
Change-Id: I88d3e33823d68745b98625050a8a274f9ef04bcb Reviewed-on: https://gerrit.libreoffice.org/27135 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>