You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[clang-tidy] Improved readability redundant casting with enums
Fixed false negatives with readability-redundant-casting when the underlying
types are the same and the option IgnoreTypeAliases is set to true.
Fixes#111137
// CHECK-MESSAGES: :[[@LINE-4]]:25: note: source type originates from referencing this non-type template parameter
222
222
// CHECK-FIXES: {{^}} T a = V;
223
223
}
224
+
225
+
enumE1 : char {};
226
+
enumclassE2 : char {};
227
+
enumE3 {};
228
+
229
+
voidtestEnum(E1e1, E2e2, E3e3){
230
+
char a = static_cast<char>(e1);
231
+
// CHECK-MESSAGES-ALIASES: :[[@LINE-1]]:12: warning: redundant explicit casting to the same type 'char' as the sub-expression, remove this casting [readability-redundant-casting]
232
+
// CHECK-MESSAGES-ALIASES: :[[@LINE-3]]:18: note: source type originates from referencing this parameter
233
+
// CHECK-FIXES-ALIASES: {{^}} char a = e1;
234
+
235
+
unsignedint d = static_cast<unsignedint>(e3);
236
+
// CHECK-MESSAGES-ALIASES: :[[@LINE-1]]:20: warning: redundant explicit casting to the same type 'unsigned int' as the sub-expression, remove this casting [readability-redundant-casting]
237
+
// CHECK-MESSAGES-ALIASES: :[[@LINE-8]]:32: note: source type originates from referencing this parameter
238
+
// CHECK-FIXES-ALIASES: {{^}} unsigned int d = e3;
0 commit comments