diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-15 09:39:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-04-15 13:54:53 +0200 |
commit | 46ce0d28b4c765076c7871358375c4e85e44534b (patch) | |
tree | b17378d5258a51185001eac455a764897e6dda11 /compilerplugins/clang/test/stringliteralvar.cxx | |
parent | 00f7309fb786efcc0bbca04fb29de80f275a16ba (diff) |
loplugin:stringliteralvar look for assignments
to O[U]String from char array literals, we can convert the char literals
to O[U]StringLiteral and avoid a runtime allocation
Change-Id: I15d8dddb2cd428b90740e39f20daf98e0941aa6d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114125
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/test/stringliteralvar.cxx')
-rw-r--r-- | compilerplugins/clang/test/stringliteralvar.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/stringliteralvar.cxx b/compilerplugins/clang/test/stringliteralvar.cxx index 535f0e36ee72..b34274c45219 100644 --- a/compilerplugins/clang/test/stringliteralvar.cxx +++ b/compilerplugins/clang/test/stringliteralvar.cxx @@ -95,4 +95,18 @@ void f10() f(OUString(literal, 3)); } +void f11(int nStreamType) +{ + // expected-error@+1 {{change type of variable 'sDocumentType' from constant character array ('const char [4]') to OUStringLiteral, and make it static [loplugin:stringliteralvar]}} + const char sDocumentType[] = "foo"; + OUString sStreamType; + switch (nStreamType) + { + case 1: + // expected-note@+1 {{first assigned here [loplugin:stringliteralvar]}} + sStreamType = sDocumentType; + break; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |