summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
diff options
context:
space:
mode:
authorAngel Garcia Gomez <angelgarcia@google.com>2015-10-05 08:40:13 +0000
committerAngel Garcia Gomez <angelgarcia@google.com>2015-10-05 08:40:13 +0000
commitc50b9fbb84832d5f697155a6f756873deec86e95 (patch)
treeb4863421c0be6585ead00b70752b0573e1c928cf /clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
parent28ff7287874eaf4eb7c1c6667a6f9978ba0cc6bd (diff)
downloadbcm5719-llvm-c50b9fbb84832d5f697155a6f756873deec86e95.tar.gz
bcm5719-llvm-c50b9fbb84832d5f697155a6f756873deec86e95.zip
Fix bug in modernize-use-nullptr.
Summary: https://llvm.org/bugs/show_bug.cgi?id=24960 modernize-use-nullptr would hit an assertion in some cases involving macros and initializer lists, due to finding a node with more than one parent (the two forms of the initializer list). However, this doesn't mean that the replacement is incorrect, so instead of just rejecting this case I tried to find a way to make it work. Looking at the semantic form of the InitListExpr made sense to me (looking at both forms results in false negatives) but I am not sure of the things that we can miss by skipping the syntactic form. Reviewers: klimek Subscribers: cfe-commits, alexfh Differential Revision: http://reviews.llvm.org/D13246 llvm-svn: 249291
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp b/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
index b08df9addd5..ef37a91731b 100644
--- a/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
+++ b/clang-tools-extra/test/clang-tidy/modernize-use-nullptr.cpp
@@ -174,4 +174,13 @@ void test_macro_args() {
#define CALL(X) X
OPTIONAL_CODE(NOT_NULL);
CALL(NOT_NULL);
+
+#define ENTRY(X) {X}
+ struct A {
+ int *Ptr;
+ } a[2] = {ENTRY(0), {0}};
+ // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
+ // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
+ // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
+#undef ENTRY
}
OpenPOWER on IntegriCloud