From eba2857bed15028b6e2d2be3640b1de4c6957037 Mon Sep 17 00:00:00 2001 From: Zinovy Nis Date: Sat, 21 Apr 2018 15:23:56 +0000 Subject: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py The patch introduces a new command line option '-check-suffix' for check_clang_tidy.py to allow multiple %check_clang_tidy% in a single test file. Sample: // RUN: %check_clang_tidy -check-suffix=FLAG-1 %s misc-unused-using-decls %t -- -- // RUN: %check_clang_tidy -check-suffix=FLAG-2 %s misc-unused-using-decls %t -- -- ... +// CHECK-MESSAGES-FLAG-1: :[[@LINE-4]]:10: warning: using decl 'B' is unused [misc-unused-using-decls] +// CHECK-MESSAGES-FLAG-2: :[[@LINE-7]]:10: warning: using decl 'A' is unused [misc-unused-using-decls] +// CHECK-FIXES-FLAG-1-NOT: using a::A;$ +// CHECK-FIXES-FLAG-2-NOT: using a::B;$ Differential Revision: https://reviews.llvm.org/D45776 llvm-svn: 330511 --- .../test/clang-tidy/check_clang_tidy.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 clang-tools-extra/test/clang-tidy/check_clang_tidy.cpp (limited to 'clang-tools-extra/test/clang-tidy/check_clang_tidy.cpp') diff --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.cpp b/clang-tools-extra/test/clang-tidy/check_clang_tidy.cpp new file mode 100644 index 00000000000..5c1bf92eecd --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.cpp @@ -0,0 +1,21 @@ +// RUN: %check_clang_tidy -check-suffix=USING-A %s misc-unused-using-decls %t -- -- -DUSING_A +// RUN: %check_clang_tidy -check-suffix=USING-B %s misc-unused-using-decls %t -- -- -DUSING_B +// RUN: %check_clang_tidy %s misc-unused-using-decls %t + +namespace a {class A {}; class B {}; class C {}; } +namespace b { +#if defined(USING_A) +using a::A; +#elif defined(USING_B) +using a::B; +#else +using a::C; +#endif +} +namespace c {} +// CHECK-MESSAGES-USING-A: :[[@LINE-8]]:10: warning: using decl 'A' {{.*}} +// CHECK-MESSAGES-USING-B: :[[@LINE-7]]:10: warning: using decl 'B' {{.*}} +// CHECK-MESSAGES: :[[@LINE-6]]:10: warning: using decl 'C' {{.*}} +// CHECK-FIXES-USING-A-NOT: using a::A;$ +// CHECK-FIXES-USING-B-NOT: using a::B;$ +// CHECK-FIXES-NOT: using a::C;$ -- cgit v1.2.3