diff options
author | Alexander Kornienko <alexfh@google.com> | 2017-01-24 11:40:23 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2017-01-24 11:40:23 +0000 |
commit | c456e686a9c1f7bab5add9a7c4636f9aea4566cb (patch) | |
tree | 31cb5581afb5958ea8ed3327914ae1e1e521ce30 | |
parent | 504400977a1d85e62867d4ce5befc7dcb490e6d4 (diff) | |
download | llvm-c456e686a9c1f7bab5add9a7c4636f9aea4566cb.zip llvm-c456e686a9c1f7bab5add9a7c4636f9aea4566cb.tar.gz llvm-c456e686a9c1f7bab5add9a7c4636f9aea4566cb.tar.bz2 |
[clang-tidy] Add more tests for modernize-use-using.
llvm-svn: 292917
-rw-r--r-- | clang-tools-extra/test/clang-tidy/modernize-use-using.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp b/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp index 7a439e6..c117c0c 100644 --- a/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp +++ b/clang-tools-extra/test/clang-tidy/modernize-use-using.cpp @@ -94,3 +94,45 @@ typedef Foo Bar; // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' // CHECK-FIXES: #define Bar Baz // CHECK-FIXES: using Baz = Foo; + +#define TYPEDEF typedef +TYPEDEF Foo Bak; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: #define TYPEDEF typedef +// CHECK-FIXES: TYPEDEF Foo Bak; + +#define FOO Foo +typedef FOO Bam; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: #define FOO Foo +// CHECK-FIXES: using Bam = Foo; + +typedef struct Foo Bap; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: using Bap = struct Foo; + +struct Foo typedef Bap2; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: using Bap2 = struct Foo; + +Foo typedef Bap3; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: using Bap3 = Foo; + +typedef struct Unknown Baq; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: using Baq = struct Unknown; + +struct Unknown2 typedef Baw; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: using Baw = struct Unknown2; + +int typedef Bax; +// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' +// CHECK-FIXES: using Bax = int; + +// FIXME: Avoid incorrect fixes in these cases. +//typedef struct Q1 { int a; } S1; +//typedef struct { int b; } S2; +//struct Q2 { int c; } typedef S3; +//struct { int d; } typedef S4; |