hokein created this revision. Herald added a subscriber: xazax.hun. https://reviews.llvm.org/D34526
Files: clang-tidy/modernize/UseNullptrCheck.cpp test/clang-tidy/modernize-use-nullptr.cpp Index: test/clang-tidy/modernize-use-nullptr.cpp =================================================================== --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -261,3 +261,31 @@ void IgnoreSubstTemplateType() { TemplateClass<int*> a(1); } + +// 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-tidy/modernize/UseNullptrCheck.cpp =================================================================== --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -233,7 +233,7 @@ allArgUsesValid(C)) { replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd); } - return skipSubTree(); + return true; } if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) {
Index: test/clang-tidy/modernize-use-nullptr.cpp =================================================================== --- test/clang-tidy/modernize-use-nullptr.cpp +++ test/clang-tidy/modernize-use-nullptr.cpp @@ -261,3 +261,31 @@ void IgnoreSubstTemplateType() { TemplateClass<int*> a(1); } + +// 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-tidy/modernize/UseNullptrCheck.cpp =================================================================== --- clang-tidy/modernize/UseNullptrCheck.cpp +++ clang-tidy/modernize/UseNullptrCheck.cpp @@ -233,7 +233,7 @@ allArgUsesValid(C)) { replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd); } - return skipSubTree(); + return true; } if (SM.isMacroBodyExpansion(StartLoc) && SM.isMacroBodyExpansion(EndLoc)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits