diff options
author | Ariel J. Bernal <ariel.j.bernal@intel.com> | 2013-04-05 20:32:36 +0000 |
---|---|---|
committer | Ariel J. Bernal <ariel.j.bernal@intel.com> | 2013-04-05 20:32:36 +0000 |
commit | 005daf1bc6aabef451f92fcbdb46e0c62b866e4d (patch) | |
tree | 33b9153cae0b19e94846019e1a7126d661b64086 /clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp | |
parent | 713eef4f7ca2bb26a1a1d39713ac167a397b65b3 (diff) | |
download | bcm5719-llvm-005daf1bc6aabef451f92fcbdb46e0c62b866e4d.tar.gz bcm5719-llvm-005daf1bc6aabef451f92fcbdb46e0c62b866e4d.zip |
Fix UseNullptr fails to replace explict casts surrounded by another implicit
cast
UseNullptr previously matched the implicit cast to const pointer as well as
the explicit cast within that has an implicit cast to nullptr as a descendant.
-Refactored UseNullptr to avoid special-casing certain kinds of cast sequences
-Added test cases.
llvm-svn: 178907
Diffstat (limited to 'clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp')
-rw-r--r-- | clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp b/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp index c84758e1cd2..b7c5d5e3516 100644 --- a/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp +++ b/clang-tools-extra/test/cpp11-migrate/UseNullptr/basic.cpp @@ -221,6 +221,8 @@ struct Bam { void ambiguous_function(int *a) {} void ambiguous_function(float *a) {} +void const_ambiguous_function(const int *p) {} +void const_ambiguous_function(const float *p) {} void test_explicit_cast_ambiguous1() { ambiguous_function((int*)0); @@ -251,3 +253,26 @@ void test_explicit_cast_ambiguous5() { k = (int*)0; // CHECK: k = (int*)nullptr; } + +void test_const_pointers_abiguous() { + const_ambiguous_function((int*)0); + // CHECK: const_ambiguous_function((int*)nullptr); +} + +// Test where the implicit cast to null is surrounded by another implict cast +// with possible explict casts in-between. +void test_const_pointers() { + const int *const_p1 = 0; + // CHECK: const int *const_p1 = nullptr; + const int *const_p2 = NULL; + // CHECK: const int *const_p2 = nullptr; + const int *const_p3 = (int)0; + // CHECK: const int *const_p3 = nullptr; + const int *const_p4 = (int)0.0f; + // CHECK: const int *const_p4 = nullptr; + const int *const_p5 = (int*)0; + // CHECK: const int *const_p5 = (int*)nullptr; + int *t; + const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(0)); + // CHECK: const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(nullptr)); +} |