diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-29 08:46:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-11-29 09:57:15 +0100 |
commit | 933660e591211f06a1be43e83c64ad1e8529bc2f (patch) | |
tree | adc0ede7c30c9ee5af7b75e649c806831f73da41 /compilerplugins/clang/test/stringconstant.cxx | |
parent | b9c9c70157e7bc5b868437ab6bda2b21ba34c627 (diff) |
loplugin:stringconstant look for unnecessary OString constructor use
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>
Diffstat (limited to 'compilerplugins/clang/test/stringconstant.cxx')
-rw-r--r-- | compilerplugins/clang/test/stringconstant.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/compilerplugins/clang/test/stringconstant.cxx b/compilerplugins/clang/test/stringconstant.cxx index 068d34f5078d..49ae3b68d035 100644 --- a/compilerplugins/clang/test/stringconstant.cxx +++ b/compilerplugins/clang/test/stringconstant.cxx @@ -19,6 +19,13 @@ extern void foo(OUString const &); struct Foo { Foo(OUString const &, int) {} Foo(OUString const &) {} + void foo(OUString const &) const {} +}; + +struct Foo2 { + Foo2(OString const &, int) {} + Foo2(OString const &) {} + void foo(OString const &) const {} }; int main() { @@ -59,7 +66,10 @@ int main() { Foo aFoo(OUString("xxx"), 1); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}} (void)aFoo; Foo aFoo2(OUString("xxx")); // expected-error {{in call of 'Foo::Foo', replace 'OUString' constructed from a string literal directly with the string literal}} - (void)aFoo2; + aFoo2.foo(OUString("xxx")); // expected-error {{in call of 'Foo::foo', replace 'OUString' constructed from a string literal directly with the string literal}} + + Foo2 aFoo3(OString("xxx")); // expected-error {{in call of 'Foo2::Foo2', replace 'OUString' constructed from a string literal directly with the string literal}} + aFoo3.foo(OString("xxx")); // expected-error {{in call of 'Foo2::foo', replace 'OUString' constructed from a string literal directly with the string literal}} (void) OUString("xxx", 3, RTL_TEXTENCODING_ASCII_US); // expected-error {{simplify construction of 'OUString' with string constant argument [loplugin:stringconstant]}} (void) OUString("xxx", 3, RTL_TEXTENCODING_ISO_8859_1); // expected-error {{suspicious 'rtl::OUString' constructor with text encoding 12 but plain ASCII content; use 'RTL_TEXTENCODING_ASCII_US' instead [loplugin:stringconstant]}} |