[PATCH] D17640: [clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 26 07:37:51 PST 2016


hokein updated this revision to Diff 49186.
hokein added a comment.

Correct test code format.


http://reviews.llvm.org/D17640

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
@@ -183,6 +183,18 @@
   // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
   // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
 #undef ENTRY
+
+#define assert1(expr) (expr) ? 0 : 1
+#define assert2 assert1
+  int *p;
+  assert2(p == 0);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+  assert2(p == NULL);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
+  // CHECK-FIXES: assert2(p == nullptr);
+#undef assert2
+#undef assert1
 }
 
 // One of the ancestor of the cast is a NestedNameSpecifierLoc.
Index: clang-tidy/modernize/UseNullptrCheck.cpp
===================================================================
--- clang-tidy/modernize/UseNullptrCheck.cpp
+++ clang-tidy/modernize/UseNullptrCheck.cpp
@@ -327,7 +327,7 @@
                NullMacros.end();
       }
 
-      MacroLoc = SM.getImmediateExpansionRange(ArgLoc).first;
+      MacroLoc = SM.getExpansionRange(ArgLoc).first;
 
       ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
       if (ArgLoc.isFileID())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17640.49186.patch
Type: text/x-patch
Size: 1281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160226/a00ea72e/attachment.bin>


More information about the cfe-commits mailing list