This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add scoped enum constants to identifier naming check
ClosedPublic

Authored by njames93 on Oct 14 2020, 10:14 AM.

Details

Summary

Added option ScopedEnumConstant(Prefix|Case|Suffix) to readability-identitied-naming.
This controls the style for constants in scoped enums, declared as enum (class|struct).
If this option is unspecified the EnumConstant style will be used instead.

Diff Detail

Event Timeline

njames93 created this revision.Oct 14 2020, 10:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2020, 10:14 AM
njames93 requested review of this revision.Oct 14 2020, 10:14 AM
njames93 updated this revision to Diff 298200.Oct 14 2020, 11:25 AM

Small tweak to the docs

njames93 updated this revision to Diff 298349.Oct 15 2020, 4:26 AM

Removed runtime check in release mode that EnumConstant DeclContext is a EnumDecl

I think will be good idea to add test for suffix/prefix too.

I think will be good idea to add test for suffix/prefix too.

Not strictly necessary, there are tests that make sure prefixes and suffixes are applied correctly. Then there are tests that make sure a type of decl is correctly matched against its style, this is one of these tests. You'll find that's the convention with most of the style types tests in here.

aaron.ballman accepted this revision.Oct 19 2020, 7:41 AM

LGTM aside from a minor nit.

clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
410

There's no need for this assertion, the use of cast<> below will assert if the type is wrong.

This revision is now accepted and ready to land.Oct 19 2020, 7:41 AM