Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / compilerplugins / clang / test / bufferadd.cxx
blobc8057a6f497b9f66b521a7ff44a274303cccb552
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 #include <rtl/strbuf.hxx>
11 #include <rtl/string.hxx>
12 #include <rtl/ustrbuf.hxx>
13 #include <rtl/ustring.hxx>
15 // ---------------------------------------------------------------
16 // replacing OUStringBuffer.append sequences to OUString+
17 namespace test1
19 void f1()
21 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
22 OUStringBuffer v;
23 v.append("xxx");
24 v.append("xxx");
26 void f2()
28 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
29 OUStringBuffer v;
30 v.append("xxx").append("aaaa");
32 void f3(OString class_name)
34 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
35 OStringBuffer sig_buf(5 + class_name.getLength());
36 sig_buf.append("(I)L");
37 //sig_buf.append( class_name.replace( '.', '/' ) );
38 sig_buf.append(';');
39 OString sig(sig_buf.makeStringAndClear());
40 (void)sig;
42 void f4(sal_Unicode const* pPathBegin)
44 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
45 OUStringBuffer v;
46 v.append(pPathBegin, 12);
47 v.append("aaaa");
49 void f5(OUStringBuffer& input)
51 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
52 OUStringBuffer v(input);
53 v.append("aaaa");
55 void f6(OString const& s)
57 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
58 OUStringBuffer b("foo");
59 b.append(OStringToOUString(s, RTL_TEXTENCODING_ASCII_US));
61 struct Footer
63 OStringBuffer m_descriptorStart;
64 OString m_descriptorEnd;
65 OString f8() const
67 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
68 OStringBuffer buf(m_descriptorStart);
69 buf.append(m_descriptorEnd);
70 return buf.makeStringAndClear();
75 namespace test2
77 void f2()
79 // no warning expected
80 OUStringBuffer v;
81 v.append("xxx");
82 if (true)
83 v.append("yyyy");
85 void appendTo(OUStringBuffer&);
86 void f3()
88 // no warning expected
89 OUStringBuffer v;
90 appendTo(v);
91 v.append("xxx");
93 void f4()
95 // no warning expected
96 OUStringBuffer v;
97 v.append("xxx");
98 v.setLength(0);
100 void f5()
102 // no warning expected
103 OUStringBuffer v;
104 v.append("xxx");
105 v[1] = 'x';
107 void f6()
109 // no warning expected
110 OUStringBuffer noel1("xxx");
111 while (true)
112 noel1.append("ffff").append("aaa");
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */