New loplugin:elidestringvar

Desktop / LibreOffice - Stephan Bergmann [redhat.com] - 7 June 2020 18:00 EDT

Quoting compilerplugins/clang/elidestringvar.cxx (and see there for a rationale): "Find cases where a variable of a string type (at least for now, only OUString) is initialized with a literal value (incl. as an empty string) and used only once."

(This commit includes fixes that become necessary in code changed after the preceding "Upcoming loplugin:elidestringvar" commits.)

As a follow-up TODO, uses of the

explicit OUString( sal_Unicode value )

ctor where value is char or char16_t literal should be detected too, so that e.g. one_quote would have been treated like two_quote in 4b85108773f9851f358a4daa8869eeadc638d103 "Upcoming loplugin:elidestringvar: sc"

> --- a/sc/source/core/tool/compiler.cxx > +++ b/sc/source/core/tool/compiler.cxx > @@ -1902,9 +1902,8 @@ void ScCompiler::CheckTabQuotes( OUString& rString, > if( bNeedsQuote ) > { > const OUString one_quote('\''); > - const OUString two_quote("''"); > // escape embedded quotes > - rString = rString.replaceAll( one_quote, two_quote ); > + rString = rString.replaceAll( one_quote, "''" ); > } > break; > }

Change-Id: I7b74f1735a07540e3d789df1d14c84081c824b6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95696

7a3736f908c0 New loplugin:elidestringvar
compilerplugins/clang/elidestringvar.cxx | 431 +++++++++++++++++++++
.../clang/sharedvisitor/dummyplugin.hxx | 1 +
extensions/source/propctrlr/selectlabeldialog.cxx | 7 +-
fpicker/source/office/foldertree.cxx | 3 +-
sd/source/ui/dlg/sdtreelb.cxx | 4 +-
sw/source/ui/fldui/changedb.cxx | 3 +-
sw/source/uibase/dbui/dbtree.cxx | 3 +-
7 files changed, 438 insertions(+), 14 deletions(-)

Upstream: cgit.freedesktop.org


  • Share