[clang-tools-extra] r262024 - [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:34:35 PST 2016
Author: hokein
Date: Fri Feb 26 09:34:35 2016
New Revision: 262024
URL: http://llvm.org/viewvc/llvm-project?rev=262024&view=rev
Log:
[clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D17640
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=262024&r1=262023&r2=262024&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Fri Feb 26 09:34:35 2016
@@ -327,7 +327,7 @@ private:
NullMacros.end();
}
- MacroLoc = SM.getImmediateExpansionRange(ArgLoc).first;
+ MacroLoc = SM.getExpansionRange(ArgLoc).first;
ArgLoc = Expansion.getSpellingLoc().getLocWithOffset(LocInfo.second);
if (ArgLoc.isFileID())
Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=262024&r1=262023&r2=262024&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp Fri Feb 26 09:34:35 2016
@@ -183,6 +183,18 @@ void test_macro_args() {
// 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.
More information about the cfe-commits
mailing list