summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/test/simplifypointertobool.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/test/simplifypointertobool.cxx')
-rw-r--r--compilerplugins/clang/test/simplifypointertobool.cxx15
1 files changed, 14 insertions, 1 deletions
diff --git a/compilerplugins/clang/test/simplifypointertobool.cxx b/compilerplugins/clang/test/simplifypointertobool.cxx
index 901262c3d474..18e1da607bb8 100644
--- a/compilerplugins/clang/test/simplifypointertobool.cxx
+++ b/compilerplugins/clang/test/simplifypointertobool.cxx
@@ -11,11 +11,24 @@
void foo();
-void test1(std::unique_ptr<int> p2)
+bool test1(std::unique_ptr<int> p2)
{
// expected-error@+1 {{simplify, drop the get() [loplugin:simplifypointertobool]}}
if (p2.get())
foo();
+ // expected-error@+1 {{simplify, drop the get() and wrap the expression in a functional cast to bool [loplugin:simplifypointertobool]}}
+ bool b1 = p2.get();
+ //TODO:
+ bool b2 = ( // deliberately spread across multiple lines
+ p2.get());
+ return b1 && b2;
+}
+
+void test2(std::shared_ptr<int> p)
+{
+ // expected-error@+1 {{simplify, drop the get() [loplugin:simplifypointertobool]}}
+ if (p.get())
+ foo();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */