summaryrefslogtreecommitdiffstats
path: root/compilerplugins/clang/plugin.cxx
Commit message (Collapse)AuthorAgeFilesLines
* -Werror,-Wdeprecated-declarationsStephan Bergmann2023-12-181-6/+5
| | | | | | | | | | | | | | | | | | | | | | > compilerplugins/clang/casttovoid.cxx:452:18: error: 'endswith' is deprecated: Use ends_with instead [-Werror,-Wdeprecated-declarations] > .endswith(".h")); > ^~~~~~~~ > ends_with > ~/llvm/inst/include/llvm/ADT/StringRef.h:276:19: note: 'endswith' has been explicitly marked deprecated here > [[nodiscard]] LLVM_DEPRECATED( > ^ etc. after <https://github.com/llvm/llvm-project/commit/5ac12951b4e9bbfcc5791282d0961ec2b65575e9> "[ADT] Deprecate StringRef::{starts,ends}with (#75491)" on Clang 18 trunk, where <https://github.com/llvm/llvm-project/commit/1b97645e56bf321b06d1353024339958b64fd242> "[ADT] Introduce StringRef::{starts,ends}_width{,_insensitive}" had been added towards Clang 16 Change-Id: Icb3e43b7d6be6f877815285913d846f766eddebf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160919 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
* Adapt to Clang 18 trunk Linkage reworkStephan Bergmann2023-11-041-1/+1
| | | | | | | | | | <https://github.com/llvm/llvm-project/commit/8775947633bf189e1847707932b1015f04640ea0> "[clang][NFC] Refactor clang::Linkage" Change-Id: I35e3a3c7e3de29e4f3b9ee8dfc34e39ba2aa1c70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158919 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Improve Plugin::checkIdenticalDefaultArgumentsStephan Bergmann2023-09-141-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...to avoid > In file included from /home/sbergman/lo/core/cui/source/factory/cuiexp.cxx:20: > /home/sbergman/lo/core/cui/source/factory/dlgfact.hxx:524:116: fatal error: TODO: Unexpected 'IdenticalDefaultArgumentsResult::Maybe' [loplugin:overrideparam] > 524 | const OUString& rName, const OUString& rDesc, const OUString& rTitle = "") override; > | ^~ > /home/sbergman/lo/core/include/svx/svxdlg.hxx:380:116: note: TODO: second argument is here [loplugin:overrideparam] > 380 | const OUString& rName, const OUString& rDesc, const OUString& rTitle = "" ) = 0; > | ^~ > MaterializeTemporaryExpr 0x7f6fd76d4218 'const OUString':'const class rtl::OUString' lvalue > `-CXXBindTemporaryExpr 0x7f6fd76d41f8 'const OUString':'const class rtl::OUString' (CXXTemporary 0x7f6fd76d41f8) > `-CXXConstructExpr 0x7f6fd76d41b8 'const OUString':'const class rtl::OUString' 'void (const char &[1], typename libreoffice_internal::ConstCharArrayDetector<const char[1], libreoffice_internal::Dummy>::Type)' > |-StringLiteral 0x7f6fd76d3e48 'const char[1]' lvalue "" > `-CXXDefaultArgExpr 0x7f6fd76d4170 'libreoffice_internal::Dummy':'struct rtl::libreoffice_internal::Dummy' > MaterializeTemporaryExpr 0x7f6fe30b5f58 'const OUString':'const class rtl::OUString' lvalue > `-CXXBindTemporaryExpr 0x7f6fe30b5f38 'const OUString':'const class rtl::OUString' (CXXTemporary 0x7f6fe30b5f38) > `-CXXConstructExpr 0x7f6fe30b5ef8 'const OUString':'const class rtl::OUString' 'void (const char &[1], typename libreoffice_internal::ConstCharArrayDetector<const char[1], libreoffice_internal::Dummy>::Type)' > |-StringLiteral 0x7f6fe30b48f8 'const char[1]' lvalue "" > `-CXXDefaultArgExpr 0x7f6fe30b5ea8 'libreoffice_internal::Dummy':'struct rtl::libreoffice_internal::Dummy' after c7a608a6691c790783c63f504010bc796c36af25 "tdf#155503 Add title to document title dialog" in an --enable-compiler-plugins=debug build. (Instead of trying to inspect deeper into the code that compares two StringLiteral directly in Plugin::checkIdenticalDefaultArguments, it looked simpler to just extend structurallyIdentical.) Change-Id: Ie1eecff210413f0a29213d867aad249420c1c278 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156916 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* loplugin:stringadd also check O[U]StringBuffersNoel Grandin2023-04-061-0/+26
| | | | | | | | | | | | For similar code sequences that can be improved. Also move containsComment from collapseif plugin code to plugin.cxx so we can use it from stringadd. Change-Id: Ie07d9aedf2c31cb0b2080e1b8584294d7046a8e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149217 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* Introduce a better mechanism to suppress false loplugin warningsStephan Bergmann2022-04-251-0/+177
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...by annotating occurrences of false warnings with [-loplugin:<name>] comments in source files and letting individual plugins opt-in to watch out for such suppression annotations, rather than maintaining lists of excluded source files in the individual plugins. (See the new loplugin::Plugin::suppressWarningsAt.) Instead of making all calls to loplugin::Plugin::report check for suppression annotations, the intent is that this check will only be added opt-in to those places in the plugins that are prone to emitting false warnings. In general it is better to have plugins that don't produce false warnings in the first place, or at least let those warnings be addressed with trivial and harmless source code modifications, avoiding the need for any suppression mechanism. As a proof of concept, I have removed the exclude list from loplugin:redundantfcast and instead annotated the relevant source code. (And thereby found that three of the six originally excluded files didn't need to be excluded any more at all?) For now, this mechanism looks for comments (both //... and /*...*/, even documentation-style /**...*/) that overlap the current and/or the preceding line, because at least for code controlled by clang-format it is often easier to move comments to a line of their own, preceding the commented code. Looking also at the current line (and not only at the preceding one) opens the door for erroneous over-eager annotation, where an annotation that was meant to address a false warning on the current line would also silence a potentially true warning on the following line. This probably doesn't cause much trouble in practice, but is up for potential change. Change-Id: I91ce7a0e5248886a60b471b1a153867f16bb5cea Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133365 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Bump compiler plugins Clang baseline to 12.0.1Stephan Bergmann2022-02-171-5/+2
| | | | | | | | | | | | | | ...as discussed in the mail thread starting at <https://lists.freedesktop.org/archives/libreoffice/2020-November/086234.html> "Bump --enable-compiler-plugins Clang baseline?" (and now picked up again at <https://lists.freedesktop.org/archives/libreoffice/2022-February/088459.html> "Re: Bump --enable-compiler-plugins Clang baseline?"), and clean up compilerplugins/clang/ accordingly Change-Id: I5e81c6fdcc363aeefd6227606225b526fdf7ac16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129989 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Let CppunitTest_odk_checkapi build against the SDK include directoryStephan Bergmann2022-01-191-1/+12
| | | | | | | | | | | | | | | | | | | | | | ...which contains only the URE include files, rather than against the SRCDIR one which contains many more. This would have prevented 148536afc9838398100ca2267b99ab349dcbb38c "Drop config_global.h from osl/module.h", where an URE include file had accidentally started to include a non-URE file. (The way $(INCLUDE) is now set up in odk/CppunitTest_odk_checkapi.mk is a bit hacky, and this change required teaching compilerplugins about SDKDIR to avoid false warnings. Another approach would be to make the test compile in the SDK build environment, similarly to CustomTarget_odk/build-examples, but setting up the SDK build environment from within gbuild is not supported at least on Windows for now. A smaller improvement would be to drop the need to include any CppUnit include directories, by turning the test into some kind of compile-only test similar to a gb_CompilerTest.) Change-Id: If79761909c67c3162d01f847dfb5d4f538f91ca1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128591 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* loplugin:unusedvariablecheck improveNoel Grandin2021-12-171-0/+36
| | | | | | | | | to find unused smart pointer variables Change-Id: I200bdd8949032a0e061de61f7903a156651793e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127006 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* remove debugging leftoverNoel Grandin2021-09-031-1/+0
| | | | | | | | | | from commit 8a54339fc83fe9abaaace6f9f374697e6923d684 loplugin:referencecasting look through more clang Types Change-Id: I6a8a4bbce04d6f53d8e02961c0917bb57fb69a9d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121601 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* loplugin:referencecasting look through more clang TypesNoel Grandin2021-08-231-2/+14
| | | | | | | | | | Note that because of where the fix resides, loplugin:redundantcast also notices a few more things. Change-Id: I0b66047fadfff2c5ceafcbd3eab085de00d861a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120865 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* compilerplugins: fix clang plugin allowlists for sccache-distMichael Stahl2021-03-251-0/+6
| | | | | | | | | | | | | | | | | | While icecream passes preprocessed (via -frewrite-includes) input to the compiler on stdin, sccache-dist writes it to a file at the same location as the source file in its sandbox. So we need a new heuristic to detect that the input has -frewrite-includes applied; there is not any variable that sccache sets, users could have SCCACHE_CACHE_SIZE set but only if they use the disk cache, so check CXX for now. Also set SCCACHE_EXTRAFILES to include log-areas.dox required by plugin. Change-Id: I4e00bfb0db7dab28f228fc0e85d753506e2c86b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112480 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
* systools is no longer part of the URE interfaceStephan Bergmann2021-03-161-1/+0
| | | | | | | | | | | ...since de030cd7a234fd9191364647deb1a4836ca992cb "gbuild: Remove MSVC 2013 legacy code", so no longer treat it as such in compilerplugins. (Which caused a few loplugin:includeform and loplugin:nullptr warnings.) Change-Id: I99b42e76992e31aff56b417c05738d4d29e3faf9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112575 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Revert "Adapt to changed clang::ASTContext::getParents behavior on Clang 11 ↵Stephan Bergmann2020-08-031-32/+6
| | | | | | | | | | | | | | trunk" This reverts commit 09aa5a9be8b9b3c88cf25b85e0eda28c5ef19aa4, now that <https://github.com/llvm/llvm-project/commit/ 551092bc3dfb86f1e11a55f3bee0c8ee1be6fdd6> "Revert AST Matchers default to AsIs mode" reverted the Clang commit that prompted this compilerplugins change. Change-Id: I75c8b4cb2894cd67a791db460f2886a783856c73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100026 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* add boost::intrusive_ptr to list of smart points in pluginsNoel Grandin2020-06-051-1/+2
| | | | | | | | | and fix some loplugin:simplifypointertobool warnings Change-Id: I3644c390a3339a4cb8d66d6d034a0f043de9320c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95572 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* Further fixing of loplugin:simplifypointertobool for libstdc++ std::shared_ptrStephan Bergmann2020-05-271-9/+11
| | | | | | | | | | | ...after fe6cce01c88d045a1fcf09acf049c34c22299b02 "Fix loplugin:simplifypointertobool for libstdc++ std::shared_ptr", this time for uses of oox::drawingml::chart::ModelRef, which derives from std::shared_ptr. Change-Id: I7e9620da52b3f6d26c6fe6d7909888c3a221c164 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94975 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Fix loplugin:simplifypointertobool for libstdc++ std::shared_ptrStephan Bergmann2020-05-261-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...where the get member function is defined on a std::__shared_ptr base class, so loplugin:simplifypointertobool used to miss those until now. (While e.g. using libc++ on macOS found those cases.) 366d08f2f6d4de922f6099c62bb81b49d89e0a68 "new loplugin:simplifypointertobool" was mistaken in breaking isSmartPointerType(const clang::Type* t) out of isSmartPointerType(const Expr* e); c874294ad9fb178df47c66875bfbdec466e39763 "Fix detection of std::unique_ptr/shared_ptr in loplugin:redundantpointerops" had introduced that indivisible two-step algorithm on purpose. The amount of additional hits (on Linux) apparently asked for turning loplugin:simplifypointertobool into a rewriting plugin. Which in turn showed that the naive adivce to just "drop the get()" is not sufficient in places that are not contextually converted to bool, as those places need to be wrapped in a bool(...) functional cast now. If the expression was already wrapped in parentheses, those could be reused as part of the functional cast, but implementing that showed that such cases are not yet found at all by the existing loplugin:simplifypointertobool. Lets leave that TODO for another commit. Besides the changes to compilerplugins/ itself, this change has been generated fully automatically with the rewriting plugin on Linux. Change-Id: I83107d6f634fc9ac232986f49044d7017df83e2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94888 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
* Adapt to changed clang::ASTContext::getParents behavior on Clang 11 trunkStephan Bergmann2020-05-251-6/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...since <https://github.com/llvm/llvm-project/commit/ d0da5d2bbe8305d06dc01a98706fd73e11e24a9f> "Change default traversal in AST Matchers to ignore invisible nodes". This caused failures > [CPT] compilerplugins/clang/test/constparams.cxx > ParmVarDecl 0x11d76c730 <compilerplugins/clang/test/constparams.cxx:15:12, col:18> col:18 used f1 'int *' > DeclRefExpr 0x11d76c948 'int *' lvalue ParmVar 0x11d76c730 'f1' 'int *' > ParmVarDecl 0x11d76cc80 <compilerplugins/clang/test/constparams.cxx:21:12, col:18> col:18 used f2 'int *' > DeclRefExpr 0x11d76ce60 'int *' lvalue ParmVar 0x11d76cc80 'f2' 'int *' > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/constparams.cxx Line 15: this parameter can be const Class1::Class1 [loplugin:constparams] > error: 'error' diagnostics seen but not expected: > File compilerplugins/clang/test/constparams.cxx Line 15: no parent? [loplugin:constparams] > File compilerplugins/clang/test/constparams.cxx Line 21: no parent? [loplugin:constparams] > 3 errors generated. [...] > [CPT] compilerplugins/clang/test/unusedenumconstants.cxx > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/unusedenumconstants.cxx Line 30: read Bottom [loplugin:unusedenumconstants] > error: 'error' diagnostics seen but not expected: > File compilerplugins/clang/test/unusedenumconstants.cxx Line 30: write Bottom [loplugin:unusedenumconstants] > 2 errors generated. [...] > [CPT] compilerplugins/clang/test/unusedfields.cxx > error: 'error' diagnostics expected but not seen: > File compilerplugins/clang/test/unusedfields.cxx Line 156 (directive at compilerplugins/clang/test/unusedfields.cxx:164): write m_f5 [loplugin:unusedfields] > File compilerplugins/clang/test/unusedfields.cxx Line 210 (directive at compilerplugins/clang/test/unusedfields.cxx:211): read m_f1 [loplugin:unusedfields] > 2 errors generated. For compilerplugins/clang/test/constparams.cxx at least it would have worked to fix that locally with > diff --git a/compilerplugins/clang/constparams.cxx b/compilerplugins/clang/constparams.cxx > index 95c8184009d7..70f056fa5a69 100644 > --- a/compilerplugins/clang/constparams.cxx > +++ b/compilerplugins/clang/constparams.cxx > @@ -274,7 +274,7 @@ bool ConstParams::checkIfCanBeConst(const Stmt* stmt, const ParmVarDecl* parmVar > { > for ( auto cxxCtorInitializer : cxxConstructorDecl->inits()) > { > - if ( cxxCtorInitializer->getInit() == stmt) > + if ( cxxCtorInitializer->getInit()->IgnoreImpCasts() == stmt) > { > if (cxxCtorInitializer->isAnyMemberInitializer()) > { (somewhat unintuitively, given the Clang change is apparently about ignoring more implicit nodes), but overall it appears better---at least for now---to use a getParents variant that keeps the old traversal behavior. For that, instead of using the clang::ASTContext::ParentMapCtx, we create our own loplugin::Plugin::parentMapContext_. There appear to be no uses of ASTContext::getParent across the Clang codebase itself, outside of ASTMatcher code, so it looks unlikely that creating our own ParentMapContext instance would degrade performance by no longer sharing cached data between Clang's internals and our plugin. (And given that ASTContext::getParents is deprecated with the note "New callers should use ParentMapContext::getParents() directly", this may well be the correct way in the long run, anyway.) Change-Id: I46c7912f2737e7c224fd45ab41441f69e2f10bd4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94795 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Code duplicationStephan Bergmann2020-05-251-1/+1
| | | | | | | Change-Id: I1af2948e0332044ef88bc7dbd837e8c7afe7af19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94785 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* new loplugin:simplifypointertoboolNoel Grandin2020-05-101-0/+38
| | | | | | | Change-Id: Iff68e8f379614a6ab6a6e0d1bad18e70bc76d76a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91907 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* Deref of DynTypedNode* must not outlive owning DynTypedNodeListStephan Bergmann2020-03-101-2/+3
| | | | | | | Change-Id: I8ac4a2f1e442446384b88f38bdef21644409f8a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90303 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* compilerplugins: remove unused getDeclContext()Miklos Vajna2020-03-091-18/+0
| | | | | | | Change-Id: I523cc2195be5f200b3e416d1ec3b282e3245ebbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90214 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
* improve loplugin:unusedfieldsNoel Grandin2020-03-091-1/+23
| | | | | | | | | | noticed something that wasn't being picked up, wrote some tests, and found an unhandled case in Plugin::getParentFunctionDecl Change-Id: I52b4ea273be6614e197392dfc4d6053bbc1704de Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90141 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* Adapt structurallyIdentical to current needsStephan Bergmann2020-02-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | ...since aad94d48b19135a2e46ac7b2c0f41f3bb29bb5a7 "Silence warnings in salvtables.hxx", where --enable-compiler-plugins=debug had started to fail with > In file included from vcl/source/app/salvtables.cxx:75: > vcl/inc/salvtables.hxx:128:69: fatal error: TODO: Unexpected 'IdenticalDefaultArgumentsResult::Maybe' [loplugin:overrideparam] > weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr, > ^~~~~~~ > include/vcl/weld.hxx:2138:69: note: TODO: second argument is here [loplugin:overrideparam] > weld_drawing_area(const OString& id, const a11yref& rA11yImpl = nullptr, > ^~~~~~~ > MaterializeTemporaryExpr 0x7fdff3111360 'const a11yref':'const class com::sun::star::uno::Reference<class com::sun::star::accessibility::XAccessible>' lvalue > `-CXXBindTemporaryExpr 0x7fdff3111340 'const a11yref':'const class com::sun::star::uno::Reference<class com::sun::star::accessibility::XAccessible>' (CXXTemporary 0x7fdff3111340) > `-CXXConstructExpr 0x7fdff3111308 'const a11yref':'const class com::sun::star::uno::Reference<class com::sun::star::accessibility::XAccessible>' 'void (class com::sun::star::accessibility::XAccessible *)' > `-ImplicitCastExpr 0x7fdff31112f0 'class com::sun::star::accessibility::XAccessible *' <NullToPointer> > `-CXXNullPtrLiteralExpr 0x7fdff31112b0 'nullptr_t' > MaterializeTemporaryExpr 0x7fdff39275d8 'const a11yref':'const class com::sun::star::uno::Reference<class com::sun::star::accessibility::XAccessible>' lvalue > `-CXXBindTemporaryExpr 0x7fdff39275b8 'const a11yref':'const class com::sun::star::uno::Reference<class com::sun::star::accessibility::XAccessible>' (CXXTemporary 0x7fdff39275b8) > `-CXXConstructExpr 0x7fdff3927580 'const a11yref':'const class com::sun::star::uno::Reference<class com::sun::star::accessibility::XAccessible>' 'void (class com::sun::star::accessibility::XAccessible *)' > `-ImplicitCastExpr 0x7fdff3927568 'class com::sun::star::accessibility::XAccessible *' <NullToPointer> > `-CXXNullPtrLiteralExpr 0x7fdff3927528 'nullptr_t' Change-Id: I2603180571df2248d4697ba63e1a8391d0dfc596 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89157 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* convert conststringvar plugin to shared infrastructreNoel Grandin2020-02-131-0/+25
| | | | | | | | | and move the duplicated hasExternalLinkage function to a common location Change-Id: I39a1990945666ff7a307b4ddd5e270da64ee1673 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88592 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* Adapt to Clang 11 move of DynTypedNodeListStephan Bergmann2020-01-271-0/+6
| | | | | | | | | | | | | | | | | | | | | ...in <https://github.com/llvm/llvm-project/commit/ 8a81daaa8b58aeaa192a47c4ce7f94b4d59ce082> "[AST] Split parent map traversal logic into ParentMapContext.h", causing failures like > compilerplugins/clang/constmethod.cxx: In member function ‘bool {anonymous}::ConstMethod::checkIfCanBeConst(const clang::Stmt*, const clang::CXXMethodDecl*)’: > compilerplugins/clang/constmethod.cxx:191:70: error: invalid use of incomplete type ‘class clang::DynTypedNodeList’ > 191 | auto parentsRange = compiler.getASTContext().getParents(*stmt); > | ^ > In file included from compilerplugins/clang/plugin.hxx:15, > from compilerplugins/clang/constmethod.cxx:16: > include/clang/AST/ASTContext.h:97:7: note: forward declaration of ‘class clang::DynTypedNodeList’ > 97 | class DynTypedNodeList; > | ^~~~~~~~~~~~~~~~ Change-Id: Ib82d04608fa306a715af481422017c24053a01c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87533 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Adapt to clang::MaterializeTemporaryExpr::GetTemparyExpr renameStephan Bergmann2019-11-261-1/+2
| | | | | | | | | | | ...in <https://github.com/llvm/llvm-project/commit/ b0561b3346e7bf0ae974995ca95b917eebde18e1> "[NFC] Refactor representation of materialized temporaries" Change-Id: I02fbf6765f9713e4d457f07521129cc9d8db5751 Reviewed-on: https://gerrit.libreoffice.org/83669 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Fix Plugin::containsPreprocessingConditionalInclusionStephan Bergmann2019-10-301-5/+21
| | | | | | | | | | | | | | | | ...which had been broken since dfc0dc4801707b2d8080af1540625b43bd463e17 "loplugin:casttovoid: fix containsPreprocessingConditionalInclusion()", and, when range.getEnd() was a macro loc, would typically have wandered off past the end of the intended range, until it would have encountered some #if etc. and erroneously returned true. Fixed the fallout across the code base. While at it, added a clarifying comment and made the "lexing fails" cases that should never happen fail with a fatal error in debug mode. Change-Id: Ieff44548384426d7716b6fc6c836c9069d878729 Reviewed-on: https://gerrit.libreoffice.org/81721 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* better name for a function in compilerpluginsLuboš Luňák2019-10-081-4/+4
| | | | | | | | | 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>
* do not use compiler.getSourceManager().getFilename()Luboš Luňák2019-10-071-2/+1
| | | | | | | | | | | | | | | | This is a continuation of ff002524c12471668e63837a804b6006f9136a34. When compiling with icecream, its -frewrite-includes merges all #include's into one .cxx file and marks them with with line markers. But SourceManager::getFilename() doesn't take those into account and so it reports all of those as <stdin>. So use getFileNameOfSpellingLoc(), which explicitly handles this case. And we should probably never ever use SourceManager::getFilename(). Change-Id: Ia194c2e041578e1e199aee2df2f885922ef7e31a Reviewed-on: https://gerrit.libreoffice.org/80326 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
* loplugin:referencecasting find more redundant static_castNoel Grandin2019-08-271-0/+50
| | | | | | | Change-Id: I3a51812bbd3fcdc6b11e47cb12962f0d4fa7a2ae Reviewed-on: https://gerrit.libreoffice.org/78191 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* make some plugins used the shared frameworkNoel Grandin2019-07-171-0/+11
| | | | | | | Change-Id: Ie283a4774564f25e0fde8ca35212f92be786d671 Reviewed-on: https://gerrit.libreoffice.org/75785 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* make (some) clang plugins share the same RecursiveASTVisitorLuboš Luňák2019-03-121-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* add EvaluateAsInt compat function for latest clangNoel Grandin2018-11-271-1/+1
| | | | | | | | | the old EvaluateAsInt method has been dropped as from current clang Change-Id: Ie30d1547ad8de777badff4b380d2fc9fb261e8fe Reviewed-on: https://gerrit.libreoffice.org/64107 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* Bump compiler plugins Clang baseline to 5.0.2Stephan Bergmann2018-11-231-2/+0
| | | | | | | | | | | ...as discussed at <https://lists.freedesktop.org/archives/libreoffice/2018-November/081435.html> "minutes of ESC call ..." Change-Id: Ia053da171d59747984546f38e19da808825b4f79 Reviewed-on: https://gerrit.libreoffice.org/63832 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* prevent crashes when running the global-analysis pluginsNoel Grandin2018-09-111-0/+4
| | | | | | | Change-Id: Ib50583289afd6212d5d5aedd3d6b7ede75902052 Reviewed-on: https://gerrit.libreoffice.org/60277 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* compilerplugins: try to make these work with icecreamMichael Stahl2018-07-061-2/+28
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Revert "Allow compiler plugins for online"Stephan Bergmann2018-03-231-13/+1
| | | | | | | | | | | | | | | | This reverts commit b39e627be45f847554f11fdac040b6f4da4054ba. The assumed (see comment at <https://gerrit.libreoffice.org/#/c/46769/4/compilerplugins/clang/ plugin.cxx@633>) performance bottleneck of isSamePathname -> getAbsolutePath does show up in Flamegraph inspections of LO builds. But changing (non-member function) isSamePathname to only call getAbsolutePath if (PluginHandlder member function) isLOOLMode is true would need some code reorg, and Online development doesn't seem to make too much actual use of the plugin, so conclusion on IRC was to revert. Change-Id: I0f04fdcc87087dac516630ed5e48361f5ea332ca Reviewed-on: https://gerrit.libreoffice.org/51774 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* loplugin:changetoolsgen various improvementsNoel Grandin2018-02-161-3/+3
| | | | | | | | | | - use AdjustFoo variants of methods on Rect/Size/Point - ignore double assignments - improve error messages - handle expressions that include macros by using getExpansionLoc - replace ++X() with X() + 1 Change-Id: Ida6b06b2a92e9226168aff6b1b8031f5867687b4
* fix loplugin rewriter source range checkingNoel Grandin2018-02-121-8/+32
| | | | | | | | | after commit 94ab8e4360a2a7a932656e99f718244321d0f923 Date: Fri Feb 9 15:28:41 2018 +0200 improve loplugin rewriter double source modification detection Change-Id: Ibf0a64fe4cc3dd6bf5ae16672b3d748a842196e4
* improve loplugin rewriter double source modification detectionNoel Grandin2018-02-101-4/+13
| | | | | | | | | | | | because my new rewriter easily generates overlapping rewriting. Move the code from flatten and salcall up into the pluginhandler, and drop the simpler detection logic. Change-Id: I3da51ac510954a5d4276cee0924cc5dc1fc9a734 Reviewed-on: https://gerrit.libreoffice.org/49493 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
* Allow compiler plugins for onlinePranav Kant2017-12-211-1/+13
| | | | | | | Change-Id: I8e45936ef5675d531be71496e8894b90eaf2f6e2 Reviewed-on: https://gerrit.libreoffice.org/46769 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: pranavk <pranavk@collabora.co.uk>
* New --enable-compiler-plugins=debug modeStephan Bergmann2017-12-081-0/+11
| | | | | | | | | | | | | | | | | | | | | ...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>
* Make checkIdenticalDefaultArguments more preciseStephan Bergmann2017-11-161-0/+76
| | | | | | | | | | | | | | | ...by structurally comparing complex constexpr exprs that use template functions that happen to not have been instantiated, so Expr::EvaluateAsRValue et al would fail. (Which happened with SFX_PRINTER_ALL in SfxViewShell::SetPrinter, include/sfx2/viewsh.hxx.) Now all of the LO code base should compile without causing checkIdenticalDefaultArguments to return Maybe. Change-Id: I2b103418c2c68f6d2242535c9cca3222a2508778 Reviewed-on: https://gerrit.libreoffice.org/44773 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* Avoid infinite loops in lopluginStephan Bergmann2017-11-161-0/+1
| | | | | | | | ...introduced with cab6e6836973a9ddfc5ed9df757e07138328c1c3 "Make checkIdenticalDefaultArguments more precise", causing older Clang to hang when compiling specific LO source files. Change-Id: I99cfcad2f0cd9adccd5aa84d21502f586762217f
* Make checkIdenticalDefaultArguments more preciseStephan Bergmann2017-11-151-12/+20
| | | | | | | | | ...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>
* Make checkIdenticalDefaultArguments more preciseStephan Bergmann2017-11-141-15/+31
| | | | | | | | | ...when creating objects of the same derived type Change-Id: I109b614473a2fb5b08dddd07a4fbe757086141a1 Reviewed-on: https://gerrit.libreoffice.org/44716 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
* loplugin:unnecessaryoverride: suppress warnings when default args differStephan Bergmann2017-11-111-0/+69
| | | | | | | | | | | | ...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>
* Memoize ignoreLocation resultsStephan Bergmann2017-11-071-42/+1
| | | | | | | | | | | | | | | ...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
* Adapt loplugin:includeform to Windows \ path separatorStephan Bergmann2017-10-271-8/+21
| | | | | | | | This can also call loplugin::isSamePathname with two paths that both contain backslashes, so finally make it (and hasPathnamePrefix) symmetric in which arguments my contain backslashes. Change-Id: I0465988d9d41e21c5660cbdbd1558543860ae1ad
* -Werror=unused-functionStephan Bergmann2017-10-271-67/+0
| | | | Change-Id: I2858c6cb74b96ffe6a799dc2ab02cbbe1c56abc7