Skip to content

Commit 36b781d

Browse files
committed
Move checks for use-enum-class to single file
1 parent c371e64 commit 36b781d

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace clang::tidy::cppcoreguidelines {
1515

16-
/// Check for unscoped enums and suggest to use scoped enums (enum class).
17-
/// Optionally, ignore unscoped enums in classes via IgnoreUnscopedEnumsInClasses
16+
/// Finds unscoped (non-class) enum declarations and suggests using enum class
17+
/// instead.
1818
///
1919
/// For the user-facing documentation see:
2020
/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/use-enum-class.html

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/use-enum-class-ignore-unscoped-enums-in-classes.cpp

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,62 @@
1-
// RUN: %check_clang_tidy -std=c++11-or-later %s cppcoreguidelines-use-enum-class %t
1+
// RUN: %check_clang_tidy -std=c++11-or-later -check-suffix=ALL,DEFAULT %s \
2+
// RUN: cppcoreguidelines-use-enum-class %t --
3+
4+
// RUN: %check_clang_tidy -std=c++11-or-later -check-suffix=ALL %s \
5+
// RUN: cppcoreguidelines-use-enum-class %t -- \
6+
// RUN: -config="{CheckOptions: { \
7+
// RUN: cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true \
8+
// RUN: }}" --
29

310
enum E {};
4-
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
11+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
512

613
enum class EC {};
714

15+
enum struct ES {};
16+
817
struct S {
918
enum E {};
10-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
19+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
1120
enum class EC {};
1221
};
1322

1423
class C {
1524
enum E {};
16-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
25+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
1726
enum class EC {};
1827
};
1928

2029
template<class T>
2130
class TC {
2231
enum E {};
23-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
32+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
2433
enum class EC {};
2534
};
2635

2736
union U {
2837
enum E {};
29-
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
38+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: enum 'E' is unscoped, use 'enum class' instead
3039
enum class EC {};
3140
};
3241

3342
namespace {
3443
enum E {};
35-
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
44+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
3645
enum class EC {};
3746
} // namespace
3847

3948
namespace N {
4049
enum E {};
41-
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
50+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum class' instead
4251
enum class EC {};
4352
} // namespace N
4453

4554
template<enum ::EC>
4655
static void foo();
4756

4857
enum ForwardE : int;
49-
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'ForwardE' is unscoped, use 'enum class' instead
58+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:6: warning: enum 'ForwardE' is unscoped, use 'enum class' instead
59+
5060
enum class ForwardEC : int;
61+
62+
enum struct ForwardES : int;

0 commit comments

Comments
 (0)