summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/stringconstant.cxx
AgeCommit message (Collapse)Author
2019-10-21Make loplugin:stringcostant find some misuses of OUStringBuffer::appendStephan Bergmann
...like the one manually found at 06845c14a17146b0ec50dd3704b6af9ee13927bc "This should have become a UTF-16 string literal". (No further misuses were found across the code base.) Change-Id: I0b604bdaaa38bd9248440ff7bd7bf0545fc6426a Reviewed-on: https://gerrit.libreoffice.org/81250 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-17Rename OUStringLiteral1 to OUStringCharStephan Bergmann
It started out as a wrapper around character literals, but has by now become a wrapper around arbitrary single characters. Besides updating the documentation, this change is a mechanical for i in $(git grep -Fl OUStringLiteral1); do sed -i -e s/OUStringLiteral1/OUStringChar/g "$i"; done Change-Id: I1b9eaa4b3fbc9025ce4a4bffea3db1c16188b76f Reviewed-on: https://gerrit.libreoffice.org/80892 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-08better name for a function in compilerpluginsLuboš Luňák
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-10-07fix various warnings in compilerpluginsLuboš Luňák
These are triggered when using llvm-config --cxxflags for building, and sometimes there's -Werror. The warnings were mostly unused variables because of being used only in assert(), or default case in switch that covers all enums (it's better to not handle default to get warning if a case is not handled). Change-Id: I0ecdd1f27390aadf033852b0d1ee0ca424ae3c37 Reviewed-on: https://gerrit.libreoffice.org/80317 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
2019-07-31Improved loplugin:stringconstant (now that GCC 7 supports it)Stephan Bergmann
Change-Id: I8f83c1941b8f39b261005939f4dcf3577ae9fc6f Reviewed-on: https://gerrit.libreoffice.org/76702 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-07-15Revert "convert some plugins to use the sharedplugin infrastructure"Noel Grandin
This reverts commit fc1b213d157afa57704cec5a0fb65ae8c11d7822. I didn't convert these correctly, the Traverse calls need adjusting.
2019-07-15convert some plugins to use the sharedplugin infrastructureNoel Grandin
Change-Id: I690d9df436abdadc51a6d3f7df686a2e37f79f73 Reviewed-on: https://gerrit.libreoffice.org/75624 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-30revert part of "improve loplugin:stringconstant"Noel Grandin
Revert part of commit dd8d5e5795358d732a9f7a8af7c35f662321e332 Date: Mon Apr 29 11:18:21 2019 +0200 improve loplugin:stringconstant sberg's original gerrit comment: but there can also be other problematic overloads for parameters like `void const *` or `std::string_view`. I'm not sure this change is worth the potential false positives. and continuing IRC discussion: <noelgrandin> I'll revert the compilerplugins/ part <sberg> noelgrandin, my main concern is that /if/ somebody eventually runs into such an overload situation, it's really hard to get the warnings/errors fixed for those people, short of going into the plugin itself Change-Id: I4916ce8943c4319d7ef9084e22d6a0eeb430b15c
2019-04-30improve loplugin:stringconstantNoel Grandin
to find more places we can elide the OUString() constructor at call sites Change-Id: Ie09f3c61f2c4b4959c97dc98ebcbaf7c51d5d713 Reviewed-on: https://gerrit.libreoffice.org/71514 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-04-29Fix typoAndrea Gelmini
Change-Id: I6e04287504cc8d4c0e3d09632ee1c7355157e5ee Reviewed-on: https://gerrit.libreoffice.org/71500 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2018-11-29loplugin:stringconstant look for unnecessary OString constructor useNoel Grandin
and tweak the methods in check.hxx to make them more flexible when called with dc.Class(xxx ? "foo" : "bar") Change-Id: I881fe628f22121ced4d8849715d6b1c92b092da1 Reviewed-on: https://gerrit.libreoffice.org/64207 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-11-27add EvaluateAsInt compat function for latest clangNoel Grandin
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>
2018-08-14filter out some of the AST in the pluginsNoel Grandin
by checking if the current namespace decl is in our code, so we have to scan less stuff, which results in a 10% perf improvement for me Change-Id: Idf0e30d57b6d0dcd13daa9ed679c28b9d233d387 Reviewed-on: https://gerrit.libreoffice.org/58942 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-08-10Avoid -Werror=deprecated-declarations with recent Clang trunkStephan Bergmann
...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-06compilerplugins: try to make these work with icecreamMichael Stahl
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-01-29Fix typosAndrea Gelmini
Change-Id: Iedd82d035454c940d76a94c7e910c81827c1389c Reviewed-on: https://gerrit.libreoffice.org/48828 Reviewed-by: Julien Nabet <serval2412@yahoo.fr> Tested-by: Julien Nabet <serval2412@yahoo.fr>
2017-11-07Clean away temporarily added using declarationsStephan Bergmann
Change-Id: I26734c13515394162d88351a1cbe2b20abdac865
2017-09-28loplugin:stringconstant: Simplify construction of non-ASCII OUStringStephan Bergmann
Change-Id: If80c53978106789824e6154db396baeecc1969dd Reviewed-on: https://gerrit.libreoffice.org/42876 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-27loplugin:stringconstant: Also handle u8"..." stringsStephan Bergmann
(just in case) Change-Id: Id8ce7436bacba874d9bc04915e42622e3cfca67a
2017-09-22loplugin:stringconstant: warn about explicit length mismatchStephan Bergmann
(just in case) Change-Id: I9eaf6e920fc7fc3ebc8c705df1cdf34b325db74a Reviewed-on: https://gerrit.libreoffice.org/42614 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-09-22Also handle OUString with non-RTL_TEXTENCODING_ASCII_US encodingStephan Bergmann
(just in case) Change-Id: I7ba2967c1cef81a3f6604077d876c8b993f7f16a Reviewed-on: https://gerrit.libreoffice.org/42609 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2017-05-18Adapt pathname checks to mixed usage of \ and / on WindowsStephan Bergmann
Change-Id: I91bc89a9076c6642e06b238f65f2d31a1d20c6b5
2017-02-11SourceManager::getFilename returns StringRefStephan Bergmann
Change-Id: I77db8565efe2e0d366afc8470308d7801a2a7337
2017-02-10Remove unnecessary blacklists from loplugin:stringconstantStephan Bergmann
Change-Id: I866a421a2b3e8830aaa7096adaef945a2264195e
2017-02-02Fix copy/move ctor checkStephan Bergmann
Change-Id: I2993d5809204098e29a7560d666fa1aafb024a89
2017-02-02loplugin:stringconstant, this should be a breakNoel Grandin
after commit dce867e8c4863c969eea3515a988630b74708a43 "loplugin:stringconstant handle calls to constructors with one arg" Change-Id: Ib572d904a95aa96aab3c799f9b7cfb505fcee5e6
2017-02-01Fix ctor checkStephan Bergmann
Change-Id: Ie261d5412c510c045b4d93a6bf1a3d4cf4371897
2017-02-01loplugin: use TypeCheck instead of getQualifiedNameAsStringNoel Grandin
since the latter is rather slow Change-Id: Ib73cdb923585580777c2265b561c1808e93b2baa Reviewed-on: https://gerrit.libreoffice.org/33585 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-02-01loplugin:stringconstant handle calls to constructors with one argNoel Grandin
Change-Id: Ide9148a908bef46ba14640dfa6f556beaf6e3f60 Reviewed-on: https://gerrit.libreoffice.org/33772 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-31teach lolugin:stringconstant about calling constructorsNoel Grandin
so we can remove unnecessary calls to the OUString(literal) constructor when calling constructors like this: Foo(OUString("xxx"), 1) Change-Id: I1de60ef561437c86b27dc9cb095a5deb2e103b36 Reviewed-on: https://gerrit.libreoffice.org/33698 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-28loplugin:stringconstant check for unnecessary OUString constructor..Noel Grandin
..calls when creating exceptions Change-Id: I3bc58a5aa4dc6f0508ecb88b3a843b96b8c7ebfe Reviewed-on: https://gerrit.libreoffice.org/33617 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-01-27fix spelling containging->containingNoel Grandin
Change-Id: I49f736c049735e89ce9f71740f5c308120378a9a
2017-01-25Minor loplugin:stringconstant improvementsStephan Bergmann
Change-Id: I0b39526c0f0854ddbb29e77ece303cf2bdd842c4
2017-01-11Remove leftover codeStephan Bergmann
Change-Id: I3f6e9ec0343074b506cb07b1ad5c9b3e1ef20b5e
2017-01-11loplugin:stringconstant: handle OStringBuffer::appendStephan Bergmann
Change-Id: I283da52c0ee2b63c19e31e9a61ab24997c037a6a
2017-01-11Some loplugin:conststringvar/stringconstant improvementsStephan Bergmann
Change-Id: I73f694e6dedb84b3fb3b63ffb9dcda2481bc403c
2017-01-10New loplugin:conststringvarStephan Bergmann
Change-Id: I16648b018ed0f69a085322cfb88481ee2a0c27ca
2016-12-18loplugin:stringconstant: Adapt to definition of OSL_THIS_FUNC on WindowsStephan Bergmann
Change-Id: I93a23799ad9a76ed9f4f86d69adb610d0962da20
2016-12-18Rename cdecl -> classdecl (MSVC treats the former like a keyword)Stephan Bergmann
Change-Id: I1859a92c996b907b8d511cddba25c00c9a52f398
2016-12-14Disambiguate clang::StringLiteralStephan Bergmann
...vs. recently introduced llvm::StringLiteral (llvm/ADT/StringRef.h) Change-Id: I4d74546b0d1401a74b0c15368bbc93794ecd0b1d
2016-11-25loplugin:stringconstant: look into 'char const * const var = "..."'Stephan Bergmann
Change-Id: I52a97b8ec273509131c2200e47527221cb62d7ee
2016-08-30loplugin:stringconstant: adapt to improved OUStringLiteral1Stephan Bergmann
Change-Id: I5c9bfbb97f0eabe1ea691faf522d22070243d234
2016-08-29Adapt loplugin:stringconstant to improved OUStringLiteral1Stephan Bergmann
Change-Id: Ibc5128df8bcf8cb5f2f09551c0de6dfdb46bdee0 Reviewed-on: https://gerrit.libreoffice.org/28447 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2016-06-29Further clean-upStephan Bergmann
Change-Id: I884acbc85108f9cbd5e244c73a1f4c58a8c89613
2016-06-29Remove support for Clang < 3.4Stephan Bergmann
Change-Id: I81e97c5f720535b33dd3ce72d01151765e4e93a0
2016-06-29Remove support for Clang < 3.3Stephan Bergmann
Change-Id: I185852a738bac10dc6d331afccfcbc7ae1225cb1
2016-06-28More Clang 3.4 "(anonymous namespace)" fixesStephan Bergmann
Change-Id: I7cb43f915565dadd611b90ee30373e472f97efb5 Reviewed-on: https://gerrit.libreoffice.org/26748 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-06-28loplugin:stringconstant: Don't warn about "OUString(OSL_THIS_FUNC)"Stephan Bergmann
Change-Id: Id5f021bd798cb94b7246faed539304dae04b4700
2016-06-03Teach loplugin:stringconstant about RTL_CONSTASCII_STRINGPARAMStephan Bergmann
Change-Id: I8ff0e104aad045f3835dc8facc760a8339b1d088
2016-02-26-Werror=return-typeStephan Bergmann
Change-Id: I7691fa50d827b688cab299c85c933adabb29994c