Author: hokein Date: Thu Jun 29 01:43:36 2017 New Revision: 306651 URL: http://llvm.org/viewvc/llvm-project?rev=306651&view=rev Log: [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 Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=306651&r1=306650&r2=306651&view=diff ============================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Thu Jun 29 01:43:36 2017 @@ -235,7 +235,7 @@ public: allArgUsesValid(C)) { replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd); } - return skipSubTree(); + return true; } if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) { Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=306651&r1=306650&r2=306651&view=diff ============================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Thu Jun 29 01:43:36 2017 @@ -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 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits