Commit Graph

13 Commits

Author SHA1 Message Date
Stephan Bergmann
d526bd7dd5 Fix StringAdd::isCompileTimeConstant
...to find StringLiteral on the RHS of +=.  Which revealed that the
VisitCompoundStmt/checkForCompoundAssign logic needed to be fixed, too, so that

  s += side_effect();
  s += "literal";
  s += side_effect();

only gets combined to

  s += side_effect() + "literal";
  s += side_effect();

and not all the way to

  s += side_effect() + "literal" + side_effect();

Change-Id: I432e3458b933a7d0ad6141c747b675cc8b0f0ba4
Reviewed-on: https://gerrit.libreoffice.org/81804
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-31 09:14:39 +01:00
Stephan Bergmann
6385e04f7e Completely remove lambda capture that is unused
...since 6d6fad522a "Introduce OStringChar" (and
had needlessly been kept alive with ce3badb157
"compilerplugins: fix -Werror,-Wunused-lambda-capture")

Change-Id: Ie34ef1197f97ecab5b8f30741f1e2c4b3a9db594
Reviewed-on: https://gerrit.libreoffice.org/81591
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-28 12:33:38 +01:00
Noel Grandin
bc539bd3c0 loplugin:stringadd improve detection
if one side of the expression is a compile-time-constant, we don't need
to worry about side-effects on the other side

Change-Id: Iee71ea51b327ef244bf39f128f921ac325d74e2b
Reviewed-on: https://gerrit.libreoffice.org/81589
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-28 12:07:54 +01:00
Miklos Vajna
ce3badb157 compilerplugins: fix -Werror,-Wunused-lambda-capture
Change-Id: I2a1374a1e79401c2107d003102ab797fac9a3d66
2019-10-25 09:09:53 +02:00
Stephan Bergmann
6d6fad522a Introduce OStringChar
...similar to OUStringChar, to be used in string concatenation expressions.  And
enable the corresponding loplugin:stringadd check, and fix its findings.

Change-Id: I35ebb2253ba82bda6c98ae6ebd2ad4f27cf9abf9
Reviewed-on: https://gerrit.libreoffice.org/81456
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-24 17:17:46 +02:00
Stephan Bergmann
754e2d9be1 Don't use broken StringAdd::getSourceAsString
it caused clang-cl to crash when processing desktop/source/app/opencl.cxx

Change-Id: I0a39697e75242cd00f12b60477d51a1e5bf96a4f
Reviewed-on: https://gerrit.libreoffice.org/81409
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-23 22:09:38 +02:00
Noel Grandin
01d28b0b85 loplugin:stringadd fix condition
Change-Id: I7752c281b1b6dd0d26bd7d6c4a6896c663f4cbc3
Reviewed-on: https://gerrit.libreoffice.org/80921
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-17 09:55:21 +02:00
Noel Grandin
3ee177a14d loplugin:stringadd look through a couple more known-good methods
Change-Id: Ifbdb3e41eae665f7dcaf5301aaba2b6e4662cf48
Reviewed-on: https://gerrit.libreoffice.org/80855
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-16 07:57:45 +02:00
Stephan Bergmann
033ecf0127 Improve loplugin:stringadd diagnostics
Change-Id: I8b87c4e56f10417acd538b765b3f8e4cc6e12fb9
Reviewed-on: https://gerrit.libreoffice.org/80844
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-15 22:24:03 +02:00
Stephan Bergmann
2d64e046e8 Improve loplugin:stringadd
...after 9b5dad13b5 "loplugin:stringadd look for
unnecessary temporaries".  There was no reason to check for implicit
MaterializeTemporaryExpr instead of explicitly written CXXFunctionalCastExpr,
and checking for the latter makes it easier to report the casted-from type,
which gives useful information how to change code that exhibits the warning.
See the comments at <https://gerrit.libreoffice.org/#/c/80724/>
"loplugin:stringadd look for unnecessary temporaries" for details.

(And while at it, remove some commented-out debug code that is probably no
longer relevant now.)

Change-Id: I7d4cab85432885d617dd7114c75163c1eb376fc2
Reviewed-on: https://gerrit.libreoffice.org/80823
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-15 16:13:54 +02:00
Tor Lillqvist
621fe7497a Comment out a lambda capture that isn't used, to avoid compiler warning
(The use of it is also commented out.)

Change-Id: Ie015a8cbd0f7a982721a389487c2134a1aba8ed1
2019-10-14 12:55:09 +03:00
Noel Grandin
9b5dad13b5 loplugin:stringadd look for unnecessary temporaries
which defeat the *StringConcat optimisation.
Also make StringConcat conversions treat a nullptr as an empty string,
to match the O*String(char*) constructors.

Change-Id: If45f5b4b6a535c97bfeeacd9ec472a7603a52e5b
Reviewed-on: https://gerrit.libreoffice.org/80724
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-14 08:26:14 +02:00
Noel Grandin
b3b8288f7f new loplugin:stringadd
look for places where we can replace sequential additions to
OUString/OString with one concatentation (i.e. +) expression, which is
more efficient

Change-Id: I64d91328bf64828d8328b1cad9e90953c0a75663
Reviewed-on: https://gerrit.libreoffice.org/79406
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2019-10-02 11:22:27 +02:00