summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/test
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-07-09 13:04:19 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-07-09 15:07:05 +0200
commitf020784e14a55c82418e4f231855040177ac9f82 (patch)
treea2d5c1d2b5778e564b9ee529de0453c73907ce70 /compilerplugins/clang/test
parentac7bba3cc1e13824732f5ab69af602848e4ba227 (diff)
Make loplugin:stringadd slightly more aggressive
...by assuming that all const member functions are side-effect free. (This presumably means that some of the special cases in StringAdd::isSideEffectFree are obsoleted by this more general case, but any such removal is postponed to later clean-up.) (Came across this when idly wondering why 8b7f948d9d79393bc6c1b11d239706666fd5d7de "sc, VmlFormControlExporter: avoid OStringBuffer style" had not been found by the plugin before.) Change-Id: I6bca10df53885b14a590543aabd61f23b3748572 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118675 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang/test')
-rw-r--r--compilerplugins/clang/test/stringadd.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/stringadd.cxx b/compilerplugins/clang/test/stringadd.cxx
index fb805ce519b9..a20b64698433 100644
--- a/compilerplugins/clang/test/stringadd.cxx
+++ b/compilerplugins/clang/test/stringadd.cxx
@@ -235,4 +235,28 @@ void f2(char ch)
s = s + OString(ch);
}
}
+
+namespace test10
+{
+struct C
+{
+ OString constStringFunction(int) const;
+ OString nonConstStringFunction();
+ int constIntFunction() const;
+ int nonConstIntFunction();
+};
+
+C getC();
+
+void f1(C c)
+{
+ OString s;
+ // expected-error@+1 {{simplify by merging with the preceding assignment [loplugin:stringadd]}}
+ s += c.constStringFunction(c.constIntFunction());
+ s += c.constStringFunction(c.nonConstIntFunction());
+ s += c.nonConstStringFunction();
+ s += getC().constStringFunction(c.constIntFunction());
+}
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */