diff options
Diffstat (limited to 'compilerplugins/clang/test/simplifypointertobool.cxx')
-rw-r--r-- | compilerplugins/clang/test/simplifypointertobool.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/compilerplugins/clang/test/simplifypointertobool.cxx b/compilerplugins/clang/test/simplifypointertobool.cxx index e4bf14c40f45..05f78d52ed78 100644 --- a/compilerplugins/clang/test/simplifypointertobool.cxx +++ b/compilerplugins/clang/test/simplifypointertobool.cxx @@ -8,6 +8,7 @@ */ #include <memory> +#include "com/sun/star/uno/XInterface.hpp" void foo(); @@ -30,6 +31,44 @@ void test2(std::shared_ptr<int> p) // expected-error@+1 {{simplify, drop the get() [loplugin:simplifypointertobool]}} if (p.get()) foo(); + // TODOexpected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}} + if (p.get() == nullptr) + foo(); + // TODOexpected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}} + if (p == nullptr) + foo(); + // TODOexpected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}} + if (p != nullptr) + foo(); + // TODOexpected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}} + if (nullptr == p.get()) + foo(); + // expected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}} + if (p.get() != nullptr) + foo(); + // expected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}} + if (nullptr != p.get()) + foo(); +} + +void test2(int* p) +{ + // TODOexpected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}} + if (p == nullptr) + foo(); + // TODOexpected-error@+1 {{simplify, convert to 'x' [loplugin:simplifypointertobool]}} + if (p != nullptr) + foo(); +} + +void test2(css::uno::Reference<css::uno::XInterface> const& p) +{ + // expected-error@+1 {{simplify, drop the get() [loplugin:simplifypointertobool]}} + if (p.get()) + foo(); + // TODOexpected-error@+1 {{simplify, convert to '!x' [loplugin:simplifypointertobool]}} + if (p.get() == nullptr) + foo(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |