Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Issue 150943005: Add a check to the FindBadConstructs.cpp clang plugin for bad enum last values. (Closed)

Created:
6 years, 10 months ago by Tom Sepez
Modified:
6 years, 9 months ago
CC:
chromium-reviews
Visibility:
Public.

Description

Add a check to the FindBadConstructs.cpp clang plugin for bad enum last values. One common coding patern is to define an enum as in: enum Color { RED, GREEN, BLUE, COLOR_LAST=BLUE }; but this is fragile when someone adds a new constant and forgets to update the COLOR_LAST constant. This change looks for enums that have a xxx_LAST or xxxLast member, and warns if there are any higher-valued constants present. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=251894

Patch Set 1 #

Patch Set 2 : Fix comment. #

Total comments: 1

Patch Set 3 : remove unused flag. #

Patch Set 4 : 500s #

Unified diffs Side-by-side diffs Delta from patch set Stats (+56 lines, -0 lines) Patch
M tools/clang/plugins/ChromeClassTester.h View 1 chunk +6 lines, -0 lines 0 comments Download
M tools/clang/plugins/ChromeClassTester.cpp View 3 chunks +16 lines, -0 lines 0 comments Download
M tools/clang/plugins/FindBadConstructs.cpp View 1 2 5 chunks +34 lines, -0 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
Tom Sepez
erg@, please review.
6 years, 10 months ago (2014-02-11 22:10:06 UTC) #1
darin (slow to review)
LGTM, but I am not an owner. https://codereview.chromium.org/150943005/diff/50001/tools/clang/plugins/FindBadConstructs.cpp File tools/clang/plugins/FindBadConstructs.cpp (right): https://codereview.chromium.org/150943005/diff/50001/tools/clang/plugins/FindBadConstructs.cpp#newcode157 tools/clang/plugins/FindBadConstructs.cpp:157: if (options_.check_bad_enum_last_value) ...
6 years, 10 months ago (2014-02-12 05:59:46 UTC) #2
Elliot Glaysher
Is this actually a common pattern? I've never seen it in chrome code, though I ...
6 years, 10 months ago (2014-02-12 20:27:16 UTC) #3
Tom Sepez
Elliot, I'll forward you the (lengthy) thread where we discussed that this is a reasonable ...
6 years, 10 months ago (2014-02-12 22:50:04 UTC) #4
Elliot Glaysher
I think that I only got a part of that thread, but I think that ...
6 years, 10 months ago (2014-02-13 18:27:32 UTC) #5
Tom Sepez
> There's a desire to turn on the warning for unhandled enums in switch > ...
6 years, 10 months ago (2014-02-13 19:10:27 UTC) #6
Tom Sepez
patch set 4 removes the flag.
6 years, 10 months ago (2014-02-18 22:02:59 UTC) #7
Tom Sepez
The CQ bit was checked by tsepez@chromium.org
6 years, 10 months ago (2014-02-18 22:03:32 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/tsepez@chromium.org/150943005/180001
6 years, 10 months ago (2014-02-18 22:09:37 UTC) #9
commit-bot: I haz the power
Change committed as 251894
6 years, 10 months ago (2014-02-19 00:20:21 UTC) #10
Nico
Please ALWAYS land new warnings behind a flag, so that if they don't work well ...
6 years, 9 months ago (2014-03-26 20:05:58 UTC) #11
Tom Sepez
On 2014/03/26 20:05:58, Nico wrote: > Please ALWAYS land new warnings behind a flag, so ...
6 years, 9 months ago (2014-03-26 20:10:14 UTC) #12
Nico
On Wed, Mar 26, 2014 at 1:10 PM, <tsepez@chromium.org> wrote: > On 2014/03/26 20:05:58, Nico ...
6 years, 9 months ago (2014-03-26 20:15:20 UTC) #13
Nico
6 years, 9 months ago (2014-03-26 20:44:16 UTC) #14
Message was sent while issue was closed.
A revert of this CL has been created in
https://codereview.chromium.org/212673008/ by thakis@chromium.org.

The reason for reverting is: Caused crbug.com/356815 and crbug.com/356816 and
doesn't have a flag to turn it off..

Powered by Google App Engine
This is Rietveld 408576698