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/ustring.hxx>
11 // expected-note@rtl/ustring.hxx:* 2 {{the presumed corresponding negated operator for 'rtl::OUString' and 'rtl::OUString' is declared here [loplugin:simplifybool]}}
12 #include <rtl/string.hxx>
13 // expected-note@rtl/string.hxx:* {{the presumed corresponding negated operator for 'rtl::OString' and 'rtl::OString' is declared here [loplugin:simplifybool]}}
14 #include <basegfx/vector/b3dvector.hxx>
15 // expected-note@basegfx/tuple/b3dtuple.hxx:* {{the presumed corresponding negated operator for 'basegfx::B3DVector' and 'basegfx::B3DVector' is declared here [loplugin:simplifybool]}}
24 { // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
29 void f2(float a
, float b
)
31 // no warning expected
39 // Consistently either warn about all or none of the below occurrences of "!!":
51 E2
operator&(E2 e1
, E2 e2
);
62 W
operator&(E3 e1
, E3 e2
);
64 bool f0(int n
) { return !!(n
& 1); }
66 bool f1(E1 e
) { return !!(e
& E1_1
); }
68 bool f2(E2 e
) { return !!(e
& E2_1
); }
70 bool f3(E3 e
) { return !!(e
& E3::E1
); }
78 bool operator==(const Record1
&) const;
83 bool operator==(const Record2
&) const;
84 bool operator!=(const Record2
&) const;
85 // expected-note@-1 {{the presumed corresponding negated operator for 'group3::Record2' and 'group3::Record2' is declared here [loplugin:simplifybool]}}
92 bool operator==(const Record3
&, const Record3
&);
93 bool operator!=(const Record3
&, const Record3
&);
94 // expected-note@-1 {{the presumed corresponding negated operator for 'group3::Record3' and 'group3::Record3' is declared here [loplugin:simplifybool]}}
100 // no warning expected, because a negated operator does not exist
101 bool v
= !(a1
== a2
);
105 // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
109 // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
113 // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
117 // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
119 // the operator != is in a base-class, and the param is a base-type
120 basegfx::B3DVector f1
;
121 basegfx::B3DVector f2
;
123 // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
128 bool operator==(Record4
const&) const;
129 bool operator!=(Record4
const& other
) const
131 // no warning expected
132 bool v
= !operator==(other
);
133 v
= !(*this == other
);
137 // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
145 bool foo1(bool a
, bool b
)
148 // expected-error@-1 {{logical negation of logical op containing negation, can be simplified [loplugin:simplifybool]}}
150 bool foo2(int a
, bool b
)
152 return !(a
!= 1 && !b
);
153 // expected-error@-1 {{logical negation of logical op containing negation, can be simplified [loplugin:simplifybool]}}
155 bool foo3(int a
, bool b
)
157 // no warning expected
158 return !(a
!= 1 && b
);
164 bool foo1(std::map
<int, int>* pActions
, int aKey
)
166 auto aIter
= pActions
->find(aKey
);
167 //TODO this doesn't work yet because I'd need to implement conversion operators during method/func lookup
168 return !(aIter
== pActions
->end());
169 // expected-error@-1 {{logical negation of comparison operator, can be simplified by inverting operator [loplugin:simplifybool]}}
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */