This revision was automatically updated to reflect the committed changes. Closed by commit rL306651: [clang-tidy] Fix modernize-use-nullptr only warns the first NULL argument. (authored by hokein).
Changed prior to commit: https://reviews.llvm.org/D34526?vs=103618&id=104607#toc Repository: rL LLVM https://reviews.llvm.org/D34526 Files: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp @@ -235,7 +235,7 @@ allArgUsesValid(C)) { replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd); } - return skipSubTree(); + return true; } if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) { Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp @@ -275,3 +275,31 @@ 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
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp @@ -235,7 +235,7 @@ allArgUsesValid(C)) { replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd); } - return skipSubTree(); + return true; } if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) { Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp @@ -275,3 +275,31 @@ 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