diff options
| author | Alexander Kornienko <alexfh@google.com> | 2014-06-29 22:19:53 +0000 |
|---|---|---|
| committer | Alexander Kornienko <alexfh@google.com> | 2014-06-29 22:19:53 +0000 |
| commit | 276fc642d38bbaa4aca00f517ba2f6f7bd138fe3 (patch) | |
| tree | cfe7d060a2bd1dca708e721216c600f9940eaa81 /clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp | |
| parent | 9e41b5cc1252846b7e395cb10ebe1faaa481dbc3 (diff) | |
| download | bcm5719-llvm-276fc642d38bbaa4aca00f517ba2f6f7bd138fe3.tar.gz bcm5719-llvm-276fc642d38bbaa4aca00f517ba2f6f7bd138fe3.zip | |
Another attempt to add a clang-tidy check for flagging C-style casts.
Summary:
The first version failed the SubstNonTypeTempateParmExpr-related test
on some buildbots. This one uses the new substNonTypeTempateParmExpr matcher to
filter out implicit C-style casts.
This patch depends on D4327.
Reviewers: djasper
Reviewed By: djasper
Subscribers: aemerson, cfe-commits
Differential Revision: http://reviews.llvm.org/D4328
llvm-svn: 212002
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 | 24 |
1 files changed, 24 insertions, 0 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 new file mode 100644 index 00000000000..8b9feb43d93 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/avoid-c-style-casts.cpp @@ -0,0 +1,24 @@ +// RUN: clang-tidy -checks=-*,google-readability-casting %s -- | FileCheck %s + +// CHECK-NOT: warning: + +bool g() { return false; } + +void f(int a, double b) { + int b1 = (int)b; + // CHECK: :[[@LINE-1]]:12: warning: C-style casts are discouraged. Use static_cast{{.*}} + + // CHECK-NOT: warning: + int b2 = int(b); + int b3 = static_cast<double>(b); + int b4 = b; + double aa = a; + (void)b2; + return (void)g(); +} + +// CHECK-NOT: warning: +enum E { E1 = 1 }; +template <E e> +struct A { static const E ee = e; }; +struct B : public A<E1> {}; |

