summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2017-06-29 08:43:36 +0000
committerHaojian Wu <hokein@google.com>2017-06-29 08:43:36 +0000
commitf193bff5be04a2c9923af44668f5cf978ace74a9 (patch)
treebcdbe96cfa90eb1a7e833f4ab793e5b035f9d8e0 /clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
parent6a3f5552cc77e557af215b5084ee657228bc93cc (diff)
downloadbcm5719-llvm-f193bff5be04a2c9923af44668f5cf978ace74a9.tar.gz
bcm5719-llvm-f193bff5be04a2c9923af44668f5cf978ace74a9.zip
[clang-tidy] Fix modernize-use-nullptr only warns the first NULL argument.
Reviewers: alexfh Reviewed By: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D34526 llvm-svn: 306651
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp b/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
index 45d44602dd2..878c11473c9 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
@@ -275,3 +275,31 @@ void test_cast_nullptr() {
G(g(static_cast<char*>(nullptr)));
G(g(static_cast<const char*>(nullptr)));
}
+
+// Test on recognizing multiple NULLs.
+class H {
+public:
+ H(bool);
+};
+
+#define T(expression) H(expression);
+bool h(int *, int *, int * = nullptr);
+void test_multiple_nulls() {
+ T(h(NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+ T(h(NULL, nullptr));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+ T(h(nullptr, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr));
+ T(h(nullptr, nullptr));
+ T(h(NULL, NULL, NULL));
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
+// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: use nullptr
+// CHECK-FIXES: T(h(nullptr, nullptr, nullptr));
+}
+#undef T
OpenPOWER on IntegriCloud