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/.
11 #include "com/sun/star/uno/XInterface.hpp"
15 bool test1(std::unique_ptr
<int> p2
)
17 // expected-error@+1 {{simplify, drop the get() [loplugin:simplifypointertobool]}}
20 // expected-error@+1 {{simplify, drop the get() and wrap the expression in a functional cast to bool [loplugin:simplifypointertobool]}}
22 // expected-error@+3 {{simplify, drop the get() and turn the surrounding parentheses into a functional cast to bool [loplugin:simplifypointertobool]}}
23 // expected-note@+1 {{surrounding parentheses here [loplugin:simplifypointertobool]}}
24 bool b2
= ( // deliberately spread across multiple lines
29 void test2(std::shared_ptr
<int> p
)
31 // expected-error@+1 {{simplify, drop the get() [loplugin:simplifypointertobool]}}
34 // expected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}}
35 if (p
.get() == nullptr)
37 // TODOexpected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}}
40 // TODOexpected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}}
43 // expected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}}
44 if (nullptr == p
.get())
46 // expected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}}
47 if (p
.get() != nullptr)
49 // expected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}}
50 if (nullptr != p
.get())
56 // TODOexpected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}}
59 // TODOexpected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}}
64 void test2(css::uno::Reference
<css::uno::XInterface
> const& p
)
66 // expected-error@+1 {{simplify, drop the get() [loplugin:simplifypointertobool]}}
69 // expected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}}
70 if (p
.get() == nullptr)
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */