diff options
| author | Alexander Kornienko <alexfh@google.com> | 2014-07-16 13:38:48 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2014-07-16 13:38:48 +0000 |
| commit | 1f317d6c052daaa8c3dfcf64d114a95e003b2592 (patch) | |
| tree | a706ef3f88f5dd00b0d19202ae8a72d1a4e78f54 /clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp | |
| parent | 692d6bb544338c65550a46d76b81db668d4901f5 (diff) | |
| download | bcm5719-llvm-1f317d6c052daaa8c3dfcf64d114a95e003b2592.tar.gz bcm5719-llvm-1f317d6c052daaa8c3dfcf64d114a95e003b2592.zip | |
Avoid adding redundant parens.
Reviewers: bkramer
Reviewed By: bkramer
Subscribers: cfe-commits, sbenza
Differential Revision: http://reviews.llvm.org/D4534
llvm-svn: 213149
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp')
| -rw-r--r-- | clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp b/clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp index a81c26246b0..9ae63207fd3 100644 --- a/clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp +++ b/clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp @@ -17,7 +17,7 @@ void f(int a, double b, const char *cpc, const void *cpv, X *pX) { char *pc2 = (char*)(cpc + 33); // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: C-style casts are discouraged. Use const_cast. {{.*}} - // CHECK-FIXES: char *pc2 = const_cast<char *>((cpc + 33)); + // CHECK-FIXES: char *pc2 = const_cast<char *>(cpc + 33); const char &crc = *cpc; char &rc = (char&)crc; @@ -33,6 +33,20 @@ void f(int a, double b, const char *cpc, const void *cpv, X *pX) { // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: C-style casts are discouraged. Use const_cast. {{.*}} // CHECK-FIXES: char ****ppppc = const_cast<char ****>(ppcpcpc); + char ***pppc = (char***)*(ppcpcpc); + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: C-style casts are discouraged. Use const_cast. {{.*}} + // CHECK-FIXES: char ***pppc = const_cast<char ***>(*(ppcpcpc)); + + char ***pppc2 = (char***)(*ppcpcpc); + // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged. Use const_cast. {{.*}} + // CHECK-FIXES: char ***pppc2 = const_cast<char ***>(*ppcpcpc); + + char *pc5 = (char*)(const char*)(cpv); + // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: C-style casts are discouraged. Use const_cast. {{.*}} + // CHECK-MESSAGES: :[[@LINE-2]]:22: warning: C-style casts are discouraged. Use reinterpret_cast. {{.*}} + // CHECK-FIXES: char *pc5 = const_cast<char *>(reinterpret_cast<const char *>(cpv)); + + int b1 = (int)b; // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: C-style casts are discouraged. Use static_cast. [google-readability-casting] // CHECK-FIXES: int b1 = static_cast<int>(b); |

