bump product version to 6.4.0.3
[LibreOffice.git] / compilerplugins / clang / test / bufferadd.cxx
bloba9f28b13b55a196ee0ccb0a07c7db03f84a14228
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 struct Footer
57 OStringBuffer m_descriptorStart;
58 OString m_descriptorEnd;
59 OString f8() const
61 // expected-error@+1 {{convert this append sequence into a *String + sequence [loplugin:bufferadd]}}
62 OStringBuffer buf(m_descriptorStart);
63 buf.append(m_descriptorEnd);
64 return buf.makeStringAndClear();
69 namespace test2
71 void f2()
73 // no warning expected
74 OUStringBuffer v;
75 v.append("xxx");
76 if (true)
77 v.append("yyyy");
79 void appendTo(OUStringBuffer&);
80 void f3()
82 // no warning expected
83 OUStringBuffer v;
84 appendTo(v);
85 v.append("xxx");
87 void f4()
89 // no warning expected
90 OUStringBuffer v;
91 v.append("xxx");
92 v.setLength(0);
94 void f5()
96 // no warning expected
97 OUStringBuffer v;
98 v.append("xxx");
99 v[1] = 'x';
101 void f6()
103 // no warning expected
104 OUStringBuffer noel1("xxx");
105 while (true)
106 noel1.append("ffff").append("aaa");
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */