This revision was automatically updated to reflect the committed changes.
Closed by commit rL263221: [clang-tidy] Make 'modernize-use-nullptr' check 
ignores NULL marcos used in… (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D17958?vs=50409&id=50414#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17958

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
@@ -226,6 +226,12 @@
     if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
       SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
                      FileLocEnd = SM.getFileLoc(EndLoc);
+      SourceLocation ImmediateMarcoArgLoc, MacroLoc;
+      // Skip NULL macros used in macro.
+      if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc) ||
+          ImmediateMarcoArgLoc != FileLocStart)
+        return skipSubTree();
+
       if (isReplaceableRange(FileLocStart, FileLocEnd, SM) &&
           allArgUsesValid(C)) {
         replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
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
@@ -195,6 +195,16 @@
   // CHECK-FIXES: assert2(p == nullptr);
 #undef assert2
 #undef assert1
+
+#define ASSERT_EQ(a, b) a == b
+#define ASSERT_NULL(x) ASSERT_EQ(static_cast<void *>(NULL), x)
+  int *pp;
+  ASSERT_NULL(pp);
+  ASSERT_NULL(NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
+  // CHECK-FIXES: ASSERT_NULL(nullptr);
+#undef ASSERT_NULL
+#undef ASSERT_EQ
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.


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
@@ -226,6 +226,12 @@
     if (SM.isMacroArgExpansion(StartLoc) && SM.isMacroArgExpansion(EndLoc)) {
       SourceLocation FileLocStart = SM.getFileLoc(StartLoc),
                      FileLocEnd = SM.getFileLoc(EndLoc);
+      SourceLocation ImmediateMarcoArgLoc, MacroLoc;
+      // Skip NULL macros used in macro.
+      if (!getMacroAndArgLocations(StartLoc, ImmediateMarcoArgLoc, MacroLoc) ||
+          ImmediateMarcoArgLoc != FileLocStart)
+        return skipSubTree();
+
       if (isReplaceableRange(FileLocStart, FileLocEnd, SM) &&
           allArgUsesValid(C)) {
         replaceWithNullptr(Check, SM, FileLocStart, FileLocEnd);
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
@@ -195,6 +195,16 @@
   // CHECK-FIXES: assert2(p == nullptr);
 #undef assert2
 #undef assert1
+
+#define ASSERT_EQ(a, b) a == b
+#define ASSERT_NULL(x) ASSERT_EQ(static_cast<void *>(NULL), x)
+  int *pp;
+  ASSERT_NULL(pp);
+  ASSERT_NULL(NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
+  // CHECK-FIXES: ASSERT_NULL(nullptr);
+#undef ASSERT_NULL
+#undef ASSERT_EQ
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to