[PATCH] D55255: Fix a false positive in misplaced-widening-cast
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 4 03:27:42 PST 2018
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.
LG in general, but a few comments re: test.
================
Comment at: test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp:67-73
+MON = 0,
+TUE = 1,
+WED = 2,
+THR = 3,
+FRI = 4,
+SAT = 5,
+SUN = 6
----------------
No need for initializers here. Please clang-format the new code.
================
Comment at: test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp:76
+
+//do not warn for int to enum casts
+DaysEnum nextDay(DaysEnum day){
----------------
Please use proper capitalization and punctuation in comments. And put a space between `//` and the text.
================
Comment at: test/clang-tidy/bugprone-misplaced-widening-cast-explicit-only.cpp:77-88
+DaysEnum nextDay(DaysEnum day){
+ if (day < SUN)
+ day = (DaysEnum)(day + 1);
+ return day;
+}
+
+//do not warn for int to enum casts
----------------
Let's make the code a bit shorter and remove unnecessary details. For example, like this:
```
void f(DaysEnum day){
if (day < SUN)
day = (DaysEnum)(day + 1);
if (day < SUN)
day = static_cast<DaysEnum>(day + 1);
}
```
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55255/new/
https://reviews.llvm.org/D55255
More information about the cfe-commits
mailing list