Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / stringviewvar.cxx
blob4f5a8fd3def794974b5840d508410bcaff3c963c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #undef NDEBUG
12 #include "sal/config.h"
13 #include <string_view>
14 #include "rtl/string.hxx"
15 #include "rtl/ustring.hxx"
16 #include "rtl/ustrbuf.hxx"
17 #include "sal/types.h"
19 void f1(std::string_view sv)
21 // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OString' with 'std::string_view' [loplugin:stringviewvar]}}
22 OString s1(sv);
23 (void)s1;
26 void f2(const OString s1)
28 // no warning expected
29 OString s2(s1);
30 (void)s2;
33 std::string_view f3a();
34 void f3()
36 // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OString' with 'std::string_view' [loplugin:stringviewvar]}}
37 OString s1 = OString(f3a());
38 (void)s1;
41 void f4a(const OString&);
42 void f4(std::string_view sv)
44 // no warning expected
45 OString s1(sv);
46 f4a(s1);
49 void f5(std::string_view sv)
51 // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OString' with 'std::string_view' [loplugin:stringviewvar]}}
52 OString s1(sv);
53 if (s1 == "xxxx")
54 f5(sv);
57 void f6(std::u16string_view sv)
59 // expected-error-re@+1 {{replace var of type '{{(rtl::)?}}OUString' with 'std::u16string_view' [loplugin:stringviewvar]}}
60 OUString s6;
61 s6 = sv;
62 (void)s6;
65 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */