1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <rtl/strbuf.hxx>
11 #include <rtl/string.hxx>
12 #include <rtl/ustrbuf.hxx>
13 #include <rtl/ustring.hxx>
15 void call_view(std::u16string_view
) {}
16 void call_view(std::string_view
) {}
17 struct ConstructWithView
19 ConstructWithView(std::u16string_view
) {}
20 ConstructWithView(std::string_view
) {}
25 void f1(std::u16string_view s1
)
27 // no warning expected
30 void f1(std::string_view s1
)
32 // no warning expected
37 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
38 call_view(s1
.copy(1, 2));
39 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
40 call_view(s1
.copy(1));
41 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
42 ConstructWithView(s1
.copy(1, 2));
43 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
44 ConstructWithView(s1
.copy(1));
48 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
49 call_view(s1
.copy(1, 2));
50 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
51 call_view(s1
.copy(1));
52 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
53 ConstructWithView(s1
.copy(1, 2));
54 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
55 ConstructWithView(s1
.copy(1));
63 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
64 OUString s2
= s1
.copy(1, 2) + "xxx";
65 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
66 s2
= s1
.copy(1) + "xxx";
67 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
68 s2
= "xxx" + s1
.copy(1);
69 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
74 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
75 OString s2
= s1
.copy(1, 2) + "xxx";
77 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
78 OString s3
= s1
.copy(1) + "xxx";
85 void f4(OUString s1
, OUString s2
)
87 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
88 sal_Unicode x
= s2
.copy(1, 2)[12];
90 // expected-error@+1 {{rather than copy, pass with a view using subView() [loplugin:stringview]}}
91 if (s2
.copy(1, 2) < s1
)
98 // expected-error@+1 {{instead of an empty 'rtl::OString', pass an empty 'std::string_view' [loplugin:stringview]}}
100 // expected-error@+1 {{instead of an empty 'rtl::OUString', pass an empty 'std::u16string_view' [loplugin:stringview]}}
101 call_view(OUString());
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */