[PATCH] D17849: [clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested implicit cast expressions.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 4 01:00:41 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL262698: [clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17849?vs=49736&id=49802#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17849

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp

Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
@@ -327,6 +327,21 @@
   // CHECK-FIXES: const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(nullptr));
 }
 
+void test_nested_implicit_cast_expr() {
+  int func0(void*, void*);
+  int func1(int, void*, void*);
+
+  (double)func1(0, 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: use nullptr
+  // CHECK-FIXES: (double)func1(0, nullptr, nullptr);
+  (double)func1(func0(0, 0), 0, 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-3]]:30: warning: use nullptr
+  // CHECK-MESSAGES: :[[@LINE-4]]:33: warning: use nullptr
+  // CHECK-FIXES: (double)func1(func0(nullptr, nullptr), nullptr, nullptr);
+}
 
 // FIXME: currently, the check doesn't work as it should with templates.
 template<typename 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
@@ -252,7 +252,7 @@
     }
     replaceWithNullptr(Check, SM, StartLoc, EndLoc);
 
-    return skipSubTree();
+    return true;
   }
 
 private:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17849.49802.patch
Type: text/x-patch
Size: 1605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160304/4e0c77de/attachment-0001.bin>


More information about the cfe-commits mailing list